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:
inv up
cp .env.example .env
./manage.py migrate
To build JavaScript and CSS files, first install npm packages:
npm install
npm run dev
./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:
celery -A gpt_playground worker -l INFO
Or with celery beat (for scheduled tasks):
celery -A gpt_playground worker -l INFO -B
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:
./manage.py test
Or to test a specific app/module:
./manage.py test apps.utils.tests.test_slugs
On Linux-based systems you can watch for changes using the following:
find . -name '*.py' | entr python ./manage.py test apps.utils.tests.test_slugs
To test a bot, first create an experiment. This can be done in the Django admin.
After doing that you can use the UI to create a new chat session against the experiment.
Note that celery needs to be running and your OPENAI_API_KEY
needs to be set in order to get responses from the bot.
You can also run experiments on the command line using:
python manage.py run_experiment <experiment_pk>
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()
.