A supportive and empathetic AI-powered chatbot built with OpenAI's GPT-3.5 that acts as a therapeutic conversation partner. The chatbot provides a safe, non-judgmental space for users to express their thoughts and feelings.
- Empathetic conversation partner
- Real-time responses
- Chat history maintenance
- Clean and intuitive UI using Gradio
- Supportive and non-judgmental interaction
- Secure API integration with OpenAI
- Python 3.11.5
- OpenAI GPT-3.5
- Gradio (UI Framework)
- Jupyter Notebook
- OpenAI API
Before running this project, make sure you have:
- Python 3.11+ installed
- OpenAI API key
- OpenAI organization key
- Required Python packages installed
- Clone the repository:
git clone https://github.com/yourusername/ai-therapist-chatbot.git
cd ai-therapist-chatbot- Install required packages:
pip install -r requirements.txt-
Set up your environment variables:
- Create a
.envfile in the root directory - Add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
- Create a
-
Update the organization key in the notebook:
openai.organization = "your-organization-key"- Start Jupyter Notebook:
jupyter notebook-
Open
chat_bot_custom.ipynb -
Run all cells in the notebook
-
The Gradio interface will launch at
http://127.0.0.1:7861 -
Start chatting with your AI therapist!
The chatbot uses three main components:
- OpenAI Integration: Connects to GPT-3.5 for generating responses
def ai_response(query):
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[...]
)- Chat History: Maintains conversation context
def create_ui(query, past):
output = ai_response(query)
past.append((query, output))
return None, past- Gradio UI: Provides the user interface
with gr.Blocks(theme=gr.themes.Glass()) as demo:
gr.Markdown("<h1><center>Your AI Therapist</center></h1>")
chatbot = gr.Chatbot()
msg = gr.Textbox(placeholder="Write your message here")- This is a prototype and should not replace professional medical advice or therapy
- Keep your API keys secure and never commit them to version control
- The chatbot's responses are generated by AI and should be treated as such
- Monitor your API usage to manage costs
- No conversation data is stored permanently
- Chat history is maintained only during the active session
- API keys should be stored as environment variables
- Use HTTPS when deploying to production
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License
For support, please open an issue in the GitHub repository or contact me @ Itsrobintomar@gmail.com.