Experiments with AI, GPT and LLMs. See this wiki for more information.
This project uses Invoke for dev automation. You can view the list of available commands with:
inv -l
New commands / updates can be made to the tasks.py
file.
Setup a virtualenv and install requirements:
python -m venv venv
pip install -r dev-requirements.txt
Python 3.11 is recommended.
inv setup-dev-env
This will:
pre-commit install --install-hooks
Start the database and redis services and run the DB migrations:
docker compose -f docker-compose-dev.yml up -d # equivalent of `inv up`
cp .env.example .env
./manage.py migrate
To build JavaScript and CSS files, first install npm packages:
inv npm --install
# or
npm install
npm run dev
Note
You should be using node >= 18.0.0. If you have nvm
installed, you can run nvm use
to switch to the correct version.
To check which version you are using use node --version
.
./manage.py createsuperuser
./manage.py runserver
Celery can be used to run background tasks.
Note: Celery is required to run in order to get a response from an LLM, so you'll need to run this if you want to test end-to-end conversations.
You can run it using:
inv celery
# or
celery -A gpt_playground worker -l INFO -B --pool=solo
To run a celery process more similar to production, you can use the following command:
inv celery --gevent
# or
celery -A gpt_playground worker -l INFO -B --pool gevent --concurrency 10
inv translations
inv requirements
Options:
-p STRING, --upgrade-package=STRING
-u, --upgrade-all
To install the Git commit hooks run the following:
$ pre-commit install --install-hooks
Once these are installed they will be run on every commit.
To run tests:
pytest
Or to test a specific app/module:
pytest apps/utils/tests/test_slugs.py
By default the signup page is disabled
. To enable it, you should set the SIGNUP_ENABLED
environment variable to true
To test the webhooks, you can use a tool like ngrok to forward webhook data to your local machine.
We use the django-field-audit library for auditing. Please see the table of audited methods and familiarize yourself on how to audit "special" functions like QuerySet.bulk_create()
.
We use ruff for linting and formatting. You can run it directly or with the inv ruff
command:
Usage: inv ruff [--options]
Docstring:
Run ruff checks and formatting. Use --unsafe-fixes to apply unsafe fixes.
Options:
-n, --no-fix
-u, --unsafe-fixes