To contribute to Chainlit, you first need to set up the project on your local machine.
- Python >=
3.10 - uv (See how to install)
- NodeJS >=
24(See how to install) - Pnpm (See how to install)
Note If you are on windows, some pnpm commands like
pnpm run formatPythonwon't work. You can fix this by changing the pnpm script-shell to bash:pnpm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"(default x64 install location, Info)
With this setup you can easily code in your fork and fetch updates from the main repository.
- Go to https://github.com/Chainlit/chainlit/fork to fork the chainlit code into your own repository.
- Clone your fork locally
git clone https://github.com/YOUR_USERNAME/YOUR_FORK.git- Go into your fork and list the current configured remote repository.
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)- Specify the new remote upstream repository that will be synced with the fork.
git remote add upstream https://github.com/Chainlit/chainlit.git- Verify the new upstream repository you've specified for your fork.
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
> upstream https://github.com/Chainlit/chainlit.git (fetch)
> upstream https://github.com/Chainlit/chainlit.git (push)The following command will install Python dependencies, Node (pnpm) dependencies and build the frontend.
cd backend
uv sync --extra tests --extra mypy --extra dev --extra custom-dataStart by running backend/chainlit/sample/hello.py as an example.
cd backend
uv run chainlit run chainlit/sample/hello.pyYou should now be able to access the Chainlit app you just launched on http://127.0.0.1:8000.
If you've made it this far, you can now replace chainlit/sample/hello.py by your own target. 😎
First, you will have to start the server either from source or with chainlit run.... Since we are starting the UI from source, you can start the server with the -h (headless) option.
Then, start the UI.
cd frontend
pnpm run devIf you visit http://localhost:5173/, it should connect to your local server. If the local server is not running, it should say that it can't connect to the server.
This will run the backend's unit tests.
cd backend
uv run pytest --cov=chainlitYou may need additional configuration or dependency installation to run Cypress. See the Cypress system requirements for details.
This will run end to end tests, assessing both the frontend, the backend and their interaction. First install cypress with pnpm exec cypress install, and then run:
// from root
pnpm test // will do cypress run
pnpm test -- --spec cypress/e2e/copilot // will run single test with the name copilot
pnpm test -- --spec "cypress/e2e/copilot,cypress/e2e/data_layer" // will run two tests with the names copilot and data_layer
pnpm test -- --spec "cypress/e2e/**/async-*" // will run all async tests
pnpm test -- --spec "cypress/e2e/**/sync-*" // will run all sync tests
pnpm test -- --spec "cypress/e2e/**/spec.cy.ts" // will run all usual tests(Go grab a cup of something, this will take a while.)
For debugging purposes, you can use the interactive mode (Cypress UI). Run:
pnpm test:interactive // runs `cypress open`
Once you create a pull request, the tests will automatically run. It is a good practice to run the tests locally before pushing.
Make sure to run uv sync again whenever you've updated the frontend!
Causes the Electron browser to be shown on screen and keeps it open after tests are done. Extremely useful for debugging!
SINGLE_TEST=password_auth CYPRESS_OPTIONS='--headed --no-exit' pnpm test