Skip to content

🛠️ Development

Version Python versions Image size Pull requests welcome
Test package Coverage Publish package
Hatch project linting - Ruff code style - Black types - Mypy

📥 Install for development

Clone the repository and go to the project folder:

git clone https://github.com/vemonet/libre-chat
cd libre-chat

For development we use Hatch, it will automatically handle virtual environments, and make sure all dependencies are installed when you run a script in the project. Install it with pipx or pip:

pipx install hatch
Optionally you can enable hatch terminal completion

See the official documentation for more details. For ZSH you can run these commands:

_HATCH_COMPLETE=zsh_source hatch > ~/.hatch-complete.zsh
echo ". ~/.hatch-complete.zsh" >> ~/.zshrc

🧑‍💻 Development workflow

Start a conversational chat web service, without vectorstore:

hatch run dev

Start a documents-based question answering service, using a vectorstore:

hatch run vector

Use the CLI to build a vectorstore at a specific path:

hatch run libre-llm build --documents documents2 --vector vectorstore/db2

✅ Run the tests

Make sure the existing tests still work by running the test suite, mypy, and linting checks. .

Run the tests locally:

hatch run test

Run only a specific test, and display all logs:

hatch run test tests/test_api.py::test_post_prompt_conversation -s
Run the tests on the different versions of python available on your machine

Not required as it is done by the GitHub Actions workflow, but can be useful for debugging:

hatch run all:test

📖 Generate the docs

The documentation (this website) is automatically generated and published by a GitHub Actions workflow from the markdown files in the docs/ folder, and python docstring comments.

To check the documentation website locally, serve it with:

hatch run docs

♻️ Reset the environment

In case you are facing issues with dependencies not updating properly you can easily reset the virtual environment with:

hatch env prune

Manually trigger the installation of dependencies in a local virtual environment (done automatically when you run any script):

hatch -v env create

Enter a new shell with the environment activated:

hatch shell

🏷️ Publish a new release

The deployment of new releases is done automatically by a GitHub Actions workflow when a new release is created on GitHub. To release a new version:

  1. Make sure the PYPI_TOKEN secret has been defined in the GitHub repository (in Settings > Secrets > Actions). You can get an API token from PyPI at pypi.org/manage/account.

  2. Increment the version number in the src/libre_chat/__init__.py file:

    hatch version 0.1.0
    # Or bump using semver: patch, minor, major
    hatch version patch
    
  3. Commit, push, and create a new release on GitHub, which will automatically trigger a workflow to publish the new release to PyPI.

Or perform the release locally
  1. Update the version:

    hatch version 0.1.0
    # Or bump using semver: patch, minor, major
    hatch version patch
    
  2. Build and publish:

    hatch build
    hatch publish
    
  3. Create the release on GitHub, manually or with the gh CLI:

    gh release create