Skip to content

Development environment

OpenGateLLM is composed of several services:

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.

  1. Create a Python virtual environment (recommended)

  2. Install the dependencies

    Terminal window
    pip install ".[api,playground,dev,test]"
  3. Install the pre-commit hooks

    Terminal window
    pre-commit install
  4. Launch services locally

    Start services locally with the following command:

    Terminal window
    make dev

    The API will be available at http://localhost:8000 and the playground at http://localhost:8501.

  5. Create the API key for the admin user

    The default created user will be admin as email and its password changeme.

    Open another terminal and create a new API key with the following command:

    Terminal window
    make create-api-key
  6. Setup your models

    To add your models, you can refer to the documentation to setup your models.

Please respect the following convention for your commits:

[doc|feat|fix](theme) commit object (in english)
# example
feat(collections): collection name retriever

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:

Terminal window
git pull --rebase origin main

Rewrite or clean up your last x commits before opening/updating a PR:

Terminal window
git rebase -i HEAD~x

For 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:

Terminal window
git rebase -i HEAD~3

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:

Terminal window
pre-commit install

To run the linter manually:

Terminal window
make lint

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:

Terminal window
make semgrep