This ChatGPT demo is built with Django, Hotwire, Celery and OpenAI API.
If you want to check more details, please check the Tutorial Series: How to create ChatGPT-alike interface with Hotwire, Django and Celery.
- Streaming: With OpenAI streaming API call, the response is sent back incrementally in chunks via an event stream, so user do not need to wait seconds for long response.
- Supports Markdown and code highlighting
- The input box can autofocus and message list can auto scroll to display the new messages.
- The input box height can auto grow with the content, so user can see the whole content when typing.
- Press
Ctrl + Enter
to send message, without clicking the submit button
Add your OpenAI API key in openai_factory.py
:
# build frontend assets, if you have no Node.js, please install it first
$ npm install
$ npm run build
If you have no Redis server running, please install it first or use docker: docker run --name some-redis -p 6379:6379 -d redis
# create python virtualenv
$ pip install requirements.txt
$ python manage.py migrate
# run django server
$ python manage.py runserver
# run celery worker
$ watchfiles --filter python 'celery -A chatgpt_django_app worker --loglevel=info'
Open http://localhost:8000/chat/, try to send message to the bot.