This project is a django implementation of using OpenAI API key to have a custom ChatGPT client. Notice: You need OpenAI API key so you can use this project. Get it from here
- The default settings of the project is that the admin creates users in the database and each user can have its own chat history.
- Users have to login to to have access to the chat.
- After each refresh or login user sees 10 recent messages.
- Admin can create users and give them access to use the chat. Also Admin can limit how many tokens they can use. The default for free trial is 4096 tokens. Learn more about tokens in chatgpt here
- The send function checks the token limit of the user and sends the best number of messages in history of user's chat, so it doesn't get token limit error.
- Clone the project
- Go to the project's directory
cd DjangoChatGPT
- Create a virtual env
python3 -m venv venv
- Activate the venv
- Linux:
source venv/bin/activate
- Windows:
venv\Scripts\activate.bat
-
Install requirements
pip install -r requirements.txt
-
Add your API key in "chatgptclient/settings.py"
API_KEY = "YOUR OPENAI API KEY"
-
Run the project: Make sure venv is activated
cd chatgptclient
python manage.py makemigrations
python manage.py migrate
- Create superuser (admin) so you can access admin page
python manage.py createsuperuser
python manage.py runserver
- In the browser the website runs on "http://127.0.0.1:8000" by default.
- You can go to "http://127.0.0.1:8000/admin/" to add Users.
- Also you have to add your admin user or any new user in ExtUser Table to allow access to use their own chat.