This is a Flask-based AI chatbot application that integrates with OpenAI's GPT-3.5 API. It includes Google OAuth for user authentication and is designed to be deployed on Heroku. The chatbot can handle user inputs and generate responses using the GPT-3.5 model.
- AI Chatbot: Leverages OpenAI's GPT-3.5 API for generating responses to user queries.
- Google OAuth: Secure login using Google OAuth 2.0.
- Asynchronous Requests: Non-blocking API requests for faster responses.
- Heroku Deployment: Ready to be deployed on Heroku with minimal setup.
- Environment-based Configuration: All sensitive information is stored in environment variables using a
.env
file.
- Python 3.7+
- Heroku CLI (for deployment)
- OpenAI API Key
- Google OAuth Client ID & Secret
Follow these steps to get the project up and running locally or on Heroku.
git clone https://github.com//EfremMic/ai-chatbot-app.git
cd ai-chatbot-app
It's recommended to use a virtual environment to manage your dependencies.
python3 -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
pip install -r requirements.txt
Run the provided script to generate a SECRET_KEY
for your Flask application:
python generate_secret_key.py
This will append a SECRET_KEY
to your .env
file. The .env
file stores sensitive information and should never be pushed to version control.
Create a .env
file in the project root with the following content:
# .env
SECRET_KEY=your_generated_secret_key
OPENAI_API_KEY=your_openai_api_key
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
flask run
You can now access the application at http://127.0.0.1:5000/
.
If you want to deploy the app to Heroku, follow these steps:
heroku create your-app-name
Set your environment variables on Heroku:
heroku config:set SECRET_KEY=your_secret_key
heroku config:set OPENAI_API_KEY=your_openai_api_key
heroku config:set GOOGLE_CLIENT_ID=your_google_client_id
heroku config:set GOOGLE_CLIENT_SECRET=your_google_client_secret
git add .
git commit -m "Initial commit"
git push heroku master
heroku open
Your application should now be live on Heroku!
- Flask: A micro-framework for Python web development.
- OpenAI API: For generating AI-based responses.
- Authlib: For integrating Google OAuth 2.0.
- Gunicorn: A production-grade WSGI server for serving the Flask app on Heroku.
This project is licensed under the MIT License - see https://github.com/EfremMic/ai-chatbot-app/blob/main/LICENSE for details.
Feel free to submit issues or pull requests to enhance the application. Contributions are welcome!
If you run into issues, here are a few steps you can take:
- Make sure your
.env
file contains the correct keys. - Check that you have set up Google OAuth correctly by creating OAuth credentials in your Google Cloud Console.
- For deployment issues, ensure that you have the correct environment variables set up on Heroku using the
heroku config
command.