2023-06-15 16:51:12 +00:00
# Contributing
To contribute to this tool, first checkout the code. Then create a new virtual environment:
2024-01-26 20:05:58 +00:00
```bash
cd llm
python -m venv venv
source venv/bin/activate
```
2023-06-15 16:51:12 +00:00
Or if you are using `pipenv` :
2024-01-26 20:05:58 +00:00
```bash
pipenv shell
```
2023-06-15 16:51:12 +00:00
Now install the dependencies and test dependencies:
2024-01-26 20:05:58 +00:00
```bash
pip install -e '.[test]'
```
2023-06-15 16:51:12 +00:00
To run the tests:
2024-01-26 20:05:58 +00:00
```bash
pytest
```
2025-05-13 14:59:14 +00:00
## Updating recorded HTTP API interactions and associated snapshots
This project uses [pytest-recording ](https://github.com/kiwicom/pytest-recording ) to record OpenAI API responses for some of the tests, and [syrupy ](https://github.com/syrupy-project/syrupy ) to capture snapshots of their results.
If you add a new test that calls the API you can capture the API response and snapshot like this:
```bash
PYTEST_OPENAI_API_KEY="$(llm keys get openai)" pytest --record-mode once --snapshot-update
```
Then review the new snapshots in `tests/__snapshots__/` to make sure they look correct.
2023-09-19 04:13:42 +00:00
## Debugging tricks
2024-01-26 18:42:38 +00:00
The default OpenAI plugin has a debugging mechanism for showing the exact requests and responses that were sent to the OpenAI API.
2023-09-19 04:13:42 +00:00
2024-01-26 18:42:38 +00:00
Set the `LLM_OPENAI_SHOW_RESPONSES` environment variable like this:
2023-09-19 04:13:42 +00:00
```bash
2024-01-26 18:42:38 +00:00
LLM_OPENAI_SHOW_RESPONSES=1 llm -m chatgpt 'three word slogan for an an otter-run bakery'
```
This will output details of the API requests and responses to the console.
Use `--no-stream` to see a more readable version of the body that avoids streaming the response:
```bash
LLM_OPENAI_SHOW_RESPONSES=1 llm -m chatgpt --no-stream \
'three word slogan for an an otter-run bakery'
2023-09-19 04:13:42 +00:00
```
2023-06-15 16:51:12 +00:00
## Documentation
Documentation for this project uses [MyST ](https://myst-parser.readthedocs.io/ ) - it is written in Markdown and rendered using Sphinx.
To build the documentation locally, run the following:
2024-01-26 20:05:58 +00:00
```bash
cd docs
pip install -r requirements.txt
make livehtml
```
2023-06-15 16:51:12 +00:00
This will start a live preview server, using [sphinx-autobuild ](https://pypi.org/project/sphinx-autobuild/ ).
The CLI `--help` examples in the documentation are managed using [Cog ](https://github.com/nedbat/cog ). Update those files like this:
2024-01-26 20:05:58 +00:00
```bash
just cog
```
2023-09-03 03:48:00 +00:00
You'll need [Just ](https://github.com/casey/just ) installed to run this command.
2023-06-17 15:48:01 +00:00
## Release process
To release a new version:
1. Update `docs/changelog.md` with the new changes.
2025-04-10 23:57:53 +00:00
2. Update the version number in `pyproject.toml`
2023-06-17 15:48:01 +00:00
3. [Create a GitHub release ](https://github.com/simonw/llm/releases/new ) for the new version.
4. Wait for the package to push to PyPI and then...
2023-06-17 21:43:14 +00:00
5. Run the [regenerate.yaml ](https://github.com/simonw/homebrew-llm/actions/workflows/regenerate.yaml ) workflow to update the Homebrew tap to the latest version.