Overview
Functions are BAML-powered LLM functions that you can:- Create and edit with structured inputs and outputs
- Run evaluations against test cases
- Re-run with different models and configurations
- Version and publish for production use
Creating a Function
- Navigate to Functions in the main navigation
- Click Create Function
- Enter a name for your function (e.g.,
ExtractName) - Define your function using BAML syntax
Example Function
Function Editor
The function editor provides:- Syntax Highlighting: BAML syntax is highlighted for readability
- Error Checking: Syntax errors are shown inline
- Auto-save: Changes are saved automatically as drafts
- Version History: View and restore previous versions
Function Tabs
Each function has multiple views:| Tab | Description |
|---|---|
| Editor | Write and edit your BAML code |
| Behaviors | Run evaluations and manage test cases |
| Versions | Browse and restore previous versions |
Behaviors (Evaluations)
The Behaviors tab is where you run evaluations against your function:Test Cases
Add test cases to evaluate your function:- Go to the Behaviors tab
- Click Add Test Cases
- Add inputs as JSON or import from captures
Running Evaluations
- Select test cases to run
- Choose which function version to evaluate
- Click Run
- Review outputs and compare with expected results
Importing from Captures
Build test cases from real production data:- Go to Labeling and find relevant captures
- Label them with appropriate tags
- Import labeled captures as test cases
Versioning
Every time you save a function, a new version is created:- Draft: Unsaved changes (not deployed)
- Published: The active version used by the SDK
- Previous Versions: Historical versions you can restore
Publishing Changes
- Make changes in the editor
- Click Save to create a draft
- Click Publish to make the version active
Restoring a Version
- Open the Versions tab
- Find the version you want to restore
- Click Restore
- Review and publish when ready
BAML Syntax
Functions are defined using BAML. Here are the key concepts:Classes
Define structured output types:Enums
Define categorical outputs:Functions
Define the function signature and prompt:Clients
Configure which LLM provider to use:Best Practices
- Descriptive Names: Use clear, descriptive function names like
ExtractInvoiceDatainstead ofExtract - Typed Outputs: Always define a class for your output to ensure type safety
- Clear Prompts: Write clear, specific prompts with examples when needed
- Build Evaluations: Create test cases from real captures to ensure quality
- Version Control: Test before publishing new versions