This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Overview> | |
BAML (Basically, A Made-Up Language) is a domain-specific language for building LLM prompts as functions. | |
You can build an agentic workflow with BAML. | |
</Overview> | |
<Schema> | |
// Define output schemas using classes | |
class MyObject { | |
// Optional string fields use ? | |
// @description is optional, but if you include it, it goes after the field. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel, Field | |
from typing import Optional, List, Literal | |
from datetime import datetime | |
class LogMetadata(BaseModel): | |
environment: str = Field(description="Production, staging, development") | |
resource_id: str = Field(description="ID of the resource generating the log") | |
duration: Optional[int] = Field( | |
None, description="Duration of the operation in milliseconds" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import fire | |
from pdf2image import convert_from_bytes | |
from PIL import Image | |
import io | |
def convert_pdf_to_image(pdf_path: str, output_path: str, page: int = 1, dpi: int = 200): | |
try: | |
# Read PDF file | |
with open(pdf_path, 'rb') as file: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<AuthProvider authUrl={process.env.NEXT_PUBLIC_AUTH_URL!}> | |
<PHProvider> | |
<body className={inter.className}> | |
<PostHogPageView /> | |
<SignedIn> | |
<RootDashboardLayout>{children}</RootDashboardLayout> | |
</SignedIn> | |
<SignedOut> | |
<RedirectToSignIn /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Generate a prompt using BAML. | |
The BAML programming language is used to write LLM prompts with certain inputs and outputs. | |
The syntax looks like this: | |
<BAML Example> | |
```baml | |
class ExtractedResume { | |
name string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In engine/baml-runtime/tests/test_runtime.rs | |
``` | |
// #[cfg(feature = "internal")] | |
mod internal_tests { | |
use std::collections::HashMap; | |
use baml_runtime::BamlRuntime; | |
use baml_runtime::InternalRuntimeInterface; |