Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jezbravo/django-chatbot
AI chatbot with the power of Gemini.
https://github.com/jezbravo/django-chatbot
ai chatbot chatgpt django gemini gemini-api gemini-pro python
Last synced: about 15 hours ago
JSON representation
AI chatbot with the power of Gemini.
- Host: GitHub
- URL: https://github.com/jezbravo/django-chatbot
- Owner: jezbravo
- Created: 2024-03-15T23:32:44.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-13T04:48:13.000Z (6 months ago)
- Last Synced: 2024-05-13T06:41:51.709Z (6 months ago)
- Topics: ai, chatbot, chatgpt, django, gemini, gemini-api, gemini-pro, python
- Language: Python
- Homepage: https://django-chatbot-production.up.railway.app/login
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DJANGO CHATBOT
## Description
This is a general-purpose chatbot application, similar to Open AI's famous ChatGPT, but instead uses Google's Gemini 1.0 Pro model. It also has the advantage of being able to be configured to provide personalized responses.
### Stack
- HTML
- CSS
- Django
- PostrgeSQL
- Railway## Setup
First of all you must clone the repository:
```sh
git clone https://github.com/jezbravo/django-chatbot.git
cd django-chatbot
```Create a virtual environment to install dependencies in and activate it:
```python
python.exe -m venv venv
.\venv\Scripts\activate
```Then install the dependencies:
```python
(venv)pip install -r requirements.txt
```Note the `(venv)` in front of the prompt. This indicates that this terminal session operates in a virtual environment set up by "venv".
### Environment Variables
To make the program work, it is necessary to configure the following environment variables in an **.env** file at the root of the project:
```python
SECRET_KEY=
GENAI_API_KEY=
DATABASE_URL=
```The `SECRET_KEY` is the Django project key and can be generated by:
```python
(venv)python.exe .\manage.py shellfrom django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
```The `GENAI_API_KEY` and the `DATABASE_URL` are provided by the Google API and by the database service (in this case, PostgreSQL) respectively.
### Database configuration
Perform the migration of the tables:
```python
(venv)python.exe .\manage.py migrate
```Once everything is ready:
```python
(venv)python.exe .\manage.py runserver
```And navigate to: http://localhost:8000/login
## Additional settings
### Administrator credentials
Run the following command:
```python
(venv)python.exe .\manage.py createsuperuser
```and follow the instructions. Then navigate to: http://localhost:8000/admin and log in to manage the project from the Django administration panel.
### AI Assistant Name and Custom Responses
In the **views.py** file from "chatbot" folder, edit the ask_genai function, for example:
```python
{
"role": "user",
"parts": ["You are an AI virtual assistant. Your name is Luna."]
},
```## Walkthrough
There are two simple login and register templates to access the chat page. Once inside, the virtual assistant will answer all questions and each user's conversation history will be stored privately so they can consult it.
You can test a version deployed to production at the following link: https://django-chatbot-production.up.railway.app/login