Skip to content
/ aichat Public

Real time chat consuming OpenAI API. This project is using Django Channels, Redis memory layer, React, Docker and production ready to Railway. I've written a blog post about this application on dev.to (not published yet).

License

Notifications You must be signed in to change notification settings

grbeno/aichat

Repository files navigation

Real Time AI-Chat using Django and React

✅ Asynchronous chat (Channels, WebSocket)
✅ AI/LLM API consuming (OpenAI)
✅ Chat memory using Redis layer
✅ Production: Docker, Railway

For development or testing purposes

Add a .env file with the necessary variables to the root/project directory

OPENAI_API_KEY=<api-key>
SECRET_KEY=<secret-key>
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1

The app uses OpenAI API-key, but any provider's API should work (read the provider's documentation)

https://platform.openai.com/docs/quickstart?api-mode=chat

If Python is installed, a secret key can be generated with this command

Set to 32 [nbytes] for a 64 long key.

python -c "import secrets;print(secrets.token_hex(32))"

Running application as Docker image

docker build .
docker-compose -f docker-compose-dev.yml up --build

Removing containers:

docker-compose -f docker-compose-dev.yml down

Run the app in the web browser

http://localhost:8000

On Production

This app can be deployed to Railway

https://railway.com/

Key steps

  • Add new project from GitHub
  • Set domain on the port 8080
  • Set the same variables except DEBUG in the Settings panel but change ALLOWED_HOSTS to the new domain
  • Use Start Command: daphne -b 0.0.0.0 -p 8080 config.asgi:application
  • Grab docker-compose-railway.yml from your file browser and drop on project canvas

About

Real time chat consuming OpenAI API. This project is using Django Channels, Redis memory layer, React, Docker and production ready to Railway. I've written a blog post about this application on dev.to (not published yet).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published