A Flask-based AI chatbot application that uses OpenAI's GPT-4 model to provide intelligent responses while maintaining a knowledge base of previous interactions. The application includes features for user feedback and response streaming.
- Interactive chat interface
- Integration with OpenAI's GPT-4 model
- PostgreSQL database for storing chat history and knowledge base
- Real-time response streaming
- User feedback system
- Docker support for easy deployment
- Custom data enrichment for API requests
- Python 3.x
- PostgreSQL database
- OpenAI API key
- Docker (optional, for containerized deployment)
The following environment variables need to be set:
DB_HOST=localhost
DB_NAME=chatdb
DB_USER=chatuser
DB_PASS=yourpassword
DB_PORT=5432
OPENAI_API_KEY=your_openai_api_key
- Clone the repository:
git clone <repository-url>
cd aichatbot- Install dependencies:
pip install -r requirements.txt- Set up the PostgreSQL database and create the required tables:
# The tables will be automatically created when the application startspython app.pydocker build -t aichatbot .
docker run -p 5000:5000 aichatbotgunicorn -c gunicorn.conf.py app:appGET /: Main chat interfacePOST /chat: Send a message and receive a responseGET /chat: Stream response for a given questionPOST /feedback: Submit feedback for a chat response
.
├── app.py # Main application file
├── Dockerfile # Docker configuration
├── gunicorn.conf.py # Gunicorn configuration
├── requirements.txt # Python dependencies
├── static/ # Static files
└── templates/ # HTML templates
- Stores chat history with questions, answers, and user feedback
- Fields: id, question, answer, feedback
- Maintains a knowledge base of previous Q&A pairs
- Fields: id, question, answer
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.