Development environment
OpenGateLLM is composed of several services:
- API (FastAPI)
- Playground (Reflex)
- Dependencies (see dependencies)
To simplify development, we have created a make command that allows you to launch the services locally in development mode. Follow the steps below to setup your development environment.
-
Create a Python virtual environment (recommended)
-
Install the dependencies
Terminal window pip install ".[api,playground,dev,test]" -
Install the pre-commit hooks
Terminal window pre-commit install -
Launch services locally
Start services locally with the following command:
Terminal window make devThe API will be available at http://localhost:8000 and the playground at http://localhost:8501.
-
Create the API key for the admin user
The default created user will be
adminas email and its passwordchangeme.Open another terminal and create a new API key with the following command:
Terminal window make create-api-key -
Setup your models
To add your models, you can refer to the documentation to setup your models.
Commit
Section titled “Commit”Commit convention
Section titled “Commit convention”Please respect the following convention for your commits:
[doc|feat|fix](theme) commit object (in english)
# examplefeat(collections): collection name retrieverRebase (required)
Section titled “Rebase (required)”Keep a linear history: update your branch with rebase, never with merge commits (git merge main / git pull without --rebase).
Linear history keeps reviews and bisects readable.
Update your branch on top of main:
git pull --rebase origin mainRewrite or clean up your last x commits before opening/updating a PR:
git rebase -i HEAD~xFor each commit, you can use the following options:
- f (fixup) : apply the commit on the previous commit (like a squash but without the commit message)
- s (squash) : merge the commit into the previous commit (like a fixup but with the commit message)
- r (reword) : change the commit message
If the branch was already pushed, update the remote with git push --force-with-lease after a rebase.
Example:
git rebase -i HEAD~3Dependencies
Section titled “Dependencies”The dependency versions are locked in uv.lock, which the API and playground images install from. The CI fails a pull request whose uv.lock does not match pyproject.toml.
After changing the dependencies in pyproject.toml, update the lock with uv and commit it with your change:
uv lockIf a rebase conflicts on uv.lock, keep either version, then run uv lock again to regenerate it.
Dependabot proposes the updates as pull requests:
- security fixes, as soon as an alert is published, in one pull request for Python and one for the documentation;
- other Python updates, once a week, for releases at least 14 days old: minor and patch updates in one pull request, each major update in its own;
- GitHub Actions updates, once a week, in one pull request.
Linter
Section titled “Linter”The project linter is Ruff. The specific project formatting rules are in the pyproject.toml file.
Please install the pre-commit hooks to run the linter at each commit:
pre-commit installTo run the linter manually:
make lintSemgrep
Section titled “Semgrep”Semgrep is a fast, open-source, static analysis tool for finding bugs and enforcing code standards. To run the semgrep manually, you can use the following command:
make semgrep