Overview
Functions are the core of Simforge. Each function defines:- Inputs: The data your function accepts
- Outputs: The structured data your function returns
- Prompt: The instructions for the LLM
- Provider: Which LLM to use (OpenAI, Anthropic, etc.)
Creating a Function
- Navigate to Functions in the sidebar
- 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
Editor Tabs
| Tab | Description |
|---|---|
| Editor | Write and edit your BAML code |
| Test | Run your function with sample inputs |
| Traces | View execution history for this function |
| Versions | Browse and restore previous versions |
Testing Functions
Test your function directly in the portal:- Open a function
- Click the Test tab
- Enter input values in the form
- Click Run
- View the output and execution details
Test Inputs
Enter test inputs as JSON or use the form fields: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
- The version is copied to a new draft
- 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
- Test Thoroughly: Test with various inputs before publishing
- Version Control: Use meaningful changes between versions