First off, thanks for your interest in contributing to BAML! We appreciate all the help we can get in making it the best way to build any AI agents or applications.
- How to Contribute
- Setting up the BAML Compiler and Runtime
- Running Integration Tests
- Grammar Testing
- VSCode Extension Testing
- Testing PromptFiddle.com
- Join our Community:
- Please join our Discord and introduce yourself in the
#contributing
channel. Let us know what you're interested in working on, and we can help you get started.
- Check Existing Issues:
- Look at the issue tracker and find and issue to work on.
Issues labeled
good first issue
are a good place to start.
- Creating an Issue:
- If you find a bug or have a feature request, please tell us about in the discord channel and then open a new issue. Make sure to provide enough details and include a clear title.
- Fork the Repository:
- Fork the repository and clone your fork locally. Work on your changes in a feature branch.
- Submit a Pull Request (PR):
- Submit your pull request with a clear description of the changes you've made. Make sure to reference the issue you're working on.
-
Fix parsing issues: PR #1031
-
Coerce integers properly: PR #1023
-
Fix syntax highlighting and a grammar parser crash: PR #1013
-
Implement literal types (e.g.,
sports "SOCCER" | "BASKETBALL"
): PR #978 -
Fix issue with OpenAI provider: PR #896
-
Implement
map
type: PR #797
<TBD — we will write more details here>
-
baml-cli/ VSCode
generatesbaml_client
, containing all the interfaces people use to call thebaml-runtime
. -
Pest grammar -> AST (build diagnostics for linter) -> Intermediate Representation (IR): The runtime parses BAML files, builds and calls LLM endpoints, parses data into JSONish, and coerces that JSONish into the schema.
-
Install Rust
-
Run
cargo build
inengine/
and make sure everything builds on your machine. -
Run some unit tests:
cd engine/baml-lib/baml/
and runcargo test
to execute grammar linting tests.
-
Run the integration tests.
- Setup your environment variables in an
.env
file with:
OPENAI_API_KEY=”your key”
(you mainly just need this one).
- Ensure the environment variables are into the test process. You can use dotenv-cli to do this.
-
Install poetry https://python-poetry.org/docs/
-
Navigate to the Python integration tests:
cd integ-tests/python/
-
Run the following commands:
poetry shell
poetry lock && poetry install
env -u CONDA_PREFIX poetry run maturin develop --manifest-path ../../engine/language_client_python/Cargo.toml
poetry run baml-cli generate --from ../baml_src
poetry run python -m pytest -s
- To run a specific test:
poetry run python -m pytest -s -k "my_test_name"
-
Install pnpm: https://pnpm.io/installation
-
Navigate to the Language Client TypeScript directory and install dependencies:
cd engine/language_client_typescript/
pnpm i
-
Navigate to the TypeScript integration tests:
cd integ-tests/typescript/
-
Run the following commands:
pnpm i
(install dependencies)pnpm build:debug
(builds your new compiler changes)pnpm generate
(generatesbaml_client
for your tests with any new changes)pnpm integ-tests
orpnpm integ-tests -t "my test name"
-
Navigate to the test directory:
cd engine/baml-runtime/tests/
-
Run tests with:
cargo test --features internal
This will run the baml-serve server locally, and ping it. You may need to change the PORT variable for your new test to use a different port (we don’t have a good way of autoselecting a port).
Instructions for testing a particular OpenAPI client are TBD.
-
Test new syntax in the pest playground.
-
Update the following:
- Pest grammar: Modify the
.pest
file. - AST parsing: Update the AST parsing of the new grammar.
- IR: Modify the Intermediate Representation (IR).
- Pest grammar: Modify the
-
Ensure all tests pass:
- Run
cargo test
inengine/baml-lib/
- Ensure integration tests still pass.
- Run
-
Modify the grammar for the PromptFiddle.com syntax rendering that uses Lezer, if necessary.
This requires a macos or linux machine, since we symlink some playground files between both PromptFiddle.com website app, and the VSCode extension itself.
Note: If you are just making changes to the VSCode extension UI, you may want to go to the section: Testing PromptFiddle.com.
-
Navigate to the TypeScript directory:
cd typescript/
-
Install dependencies:
pnpm i
-
Build and launch the extension:
npx turbo build --force
- Open VSCode and go to the Run and Debug section (play button near the extensions button).
- Select "Launch VSCode Extension" and press the play button.
- This will open a new VSCode window in Debug mode.
- You can open a simple BAML project in this window (refer to our quickstart guide to set up a simple project, or clone the
baml-examples
repository).
-
Reload the extension:
- Use
Command + Shift + P
to reload the extension when you change any core logic. - Alternatively, close and reopen the playground if you rebuild the playground.
- Use
To rebuild the playground UI:
cd typescript/vscode-ext/packages/web-panel
pnpm build
- Close and open the playground in your “Debug mode VSCode window”
Testing promptfiddle.com
This is useful if you want to iterate faster on the Extension UI, since it supports hot-reloading.
-
Navigate to the Fiddle Frontend directory:
cd typescript/fiddle-frontend
-
Start the dev server:
pnpm dev
-
Modify the files in
typescript/playground-common
-
Use the
vscode-
prefixed tailwind classes to get proper colors.