Test Cases
You can test your BAML functions in the VSCode Playground by adding a test
snippet into a BAML file:
See the interactive examples
The BAML playground will give you a starting snippet to copy that will match your function signature.
BAML doesn’t use between key-value pairs :
except in function parameters
Complex object inputs
Objects are injected as dictionaries
Images
For a function that takes an image as input, like so:
You can define test cases using image files, URLs, or base64 strings.
Using a file
Committing a lot of images into your repository can make it slow to clone and pull your repository. If you expect to commit >500MiB of images, please read GitHub’s size limit documentation and consider setting up large file storage.
The path to the image file, relative to the directory containing the current BAML file.
Image files must be somewhere in baml_src/
.
The mime-type of the image. If not set, and the provider expects a mime-type to be provided, BAML will try to infer it based on first, the file extension, and second, the contents of the file.
Using a URL
The publicly accessible URL from which the image may be downloaded.
The mime-type of the image. If not set, and the provider expects a mime-type to be provided, BAML will try to infer it based on the contents of the file.
Using a base64 string
The base64-encoded image data.
The mime-type of the image. If not set, and the provider expects a mime-type to be provided, BAML will try to infer it based on the contents of the file.
If base64
is a data URL, this field will be ignored.
Audio
For a function that takes audio as input, like so:
You can define test cases using audio files, URLs, or base64 strings.
Using a file
Committing a lot of audio files into your repository can make it slow to clone and pull your repository. If you expect to commit >500MiB of audio, please read GitHub’s size limit documentation and consider setting up large file storage.
The path to the audio file, relative to the directory containing the current BAML file.
audio files must be somewhere in baml_src/
.
The mime-type of the audio. If not set, and the provider expects a mime-type to be provided, BAML will try to infer it based on first, the file extension, and second, the contents of the file.
Using a URL
The publicly accessible URL from which the audio may be downloaded.
The mime-type of the audio. If not set, and the provider expects a mime-type to be provided, BAML will try to infer it based on the contents of the file.
Using a base64 string
The base64-encoded audio data.
The mime-type of the audio. If not set, and the provider expects a mime-type to be provided, BAML will try to infer it based on the contents of the file.
If base64
is a data URL, this field will be ignored.