Access functions
Several places in the UI, for example the custom scorer menu in the playground, allow you to define functions. You can also bundle them in your code and push them to Braintrust withbraintrust push and braintrust eval --push. Technically speaking,
functions are a generalization of prompts and code functions, so when you define a custom prompt, you are technically defining
a “prompt function”.
Organizing functions into projects
Functions are organized into projects using theprojects.create() method:
- TypeScript
- Python
If a project already exists,
projects.create() returns a handle. There is no separate .get() method.- Well-defined parameters and return types
- Streaming and non-streaming invocation
- Automatic tracing and logging in Braintrust
- Prompts can be loaded into your code in the OpenAI argument format
- Prompts and code can be easily saved and uploaded from your codebase
Sandbox
Functions are executed in a secure sandbox environment. If you are self-hosting Braintrust, then you must:- Set
EnableQuarantinetotruein the Cloudformation stack - Set
ALLOW_CODE_FUNCTION_EXECUTIONto1in the Docker configuration