Experiments with AI, GPT and LLMs. See this wiki for more informaton.
Setup a virtualenv and install requirements (this example uses virtualenvwrapper):
python -m venv venv
pip install -r dev-requirements.txt
Python 3.11 is recommended, though anything between 3.9 and 3.11 should work.
Create a database named gpt_playground
.
createdb gpt_playground
or if you're using docker, start the container with
docker run -d --name gpt-postgres -p 5432:5432 -e POSTGRES_PASSWORD=*** -e POSTGRES_USER=postgres -e POSTGRES_DATABASE=gpt_playground postgres:14
then create the DB
docker exec -it gpt-postgres createdb -U postgres gpt_playground
Create database migrations:
./manage.py makemigrations
Create database tables:
./manage.py migrate
To build JavaScript and CSS files, first install npm packages:
npm install
Then build (and watch for changes locally):
npm run dev-watch
./manage.py runserver
Redis is needed by Celery to run background tasks.
You can set up Redis in docker using:
docker run -d -p 6379:6379 --name gpt-redis redis
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
Docker:
make translations
Native:
./manage.py makemessages --all --ignore node_modules --ignore venv
./manage.py makemessages -d djangojs --all --ignore node_modules --ignore venv
./manage.py compilemessages
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
Copy the .env.example
file to .env
and set any values that you need.
You should also add your OpenAI key to this file:
OPENAI_API_KEY="sk-***"
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.