test
Tests are first-class citizens in BAML, designed to make testing AI functions straightforward and robust. BAML tests can be written anywhere in your codebase and run with minimal setup.
Overview
A BAML test consists of:
- Test name and metadata
- Functions under test
- Input arguments
- Optional testing configuration
- Optional assertions
Test Declaration
Syntax
Components
name
: Test identifier (unique per function)functions
: List of functions to testargs
: Input parameters for the test case
Input Types
Basic Types
Simple values are provided directly:
Complex Objects
Objects are specified using nested structures:
Arrays
Arrays use bracket notation:
Media Inputs
Images
Images can be specified using three methods:
- File Reference
- URL Reference
- Base64 Data
Audio
Similar to images, audio can be specified in three ways:
- File Reference
- URL Reference
- Base64 Data
Multi-line Strings
For long text inputs, use the block string syntax:
Testing Multiple Functions
This requires each function to have teh exact same parameters:
Integration with Development Tools
VSCode Integration
- Tests can be run directly from the BAML playground
- Real-time syntax validation
- Test result visualization