An AI-powered chatbot built with Streamlit and OpenAI's GPT models to help patients navigate medical specialties and clinic services. This virtual assistant provides empathetic, professional guidance to help patients understand which medical specialty they should consult based on their symptoms and needs.
This project demonstrates the practical application of AI in healthcare communication. The chatbot serves as a first point of contact for patients, helping them:
- Understand medical specialties - Get clear explanations of what each specialty treats
- Navigate symptoms - Receive guidance on which specialist to consult based on symptoms
- Access clinic information - Learn about office hours, insurance acceptance, and appointment scheduling
- Get empathetic support - Interact with a professional, welcoming AI assistant
The assistant is designed to be informative without making medical diagnoses, always encouraging patients to schedule proper in-person consultations for accurate medical evaluation.
- Real-time streaming responses using OpenAI's GPT models
- Context-aware conversations with session memory
- Empathetic and professional tone tailored for healthcare
- Symptom-to-specialty guidance without making diagnoses
- Multilingual potential (currently configured for English)
flowchart TD
A[Patient Opens Chatbot] --> B[Welcome Message Displayed]
B --> C[Patient Enters Question/Symptom]
C --> D{Question Type?}
D -->|Symptom-based| E[AI Analyzes Symptoms]
D -->|General Info| F[AI Provides Clinic Info]
D -->|Specialty Question| G[AI Explains Specialty]
E --> H[Suggest Appropriate Specialty]
F --> I[Share Hours/Insurance/Scheduling]
G --> J[Detail Specialty Coverage]
H --> K[Recommend In-Person Consultation]
I --> K
J --> K
K --> L[Display Response with Streaming]
L --> M[Save to Conversation History]
M --> N{Continue Conversation?}
N -->|Yes| C
N -->|No| O[End Session]
style A fill:#e1f5ff
style L fill:#fff4e1
style K fill:#ffe1e1
style O fill:#e1ffe1
- Python 3.8 or higher
- OpenAI API key (Get one here)
- pip (Python package manager)
-
Clone the repository
-
Install dependencies
pip install streamlit openaiOr create a requirements.txt:
streamlit>=1.28.0
openai>=1.3.0Then install:
pip install -r requirements.txt- Configure OpenAI API Key
Create a .streamlit/secrets.toml file in the project root:
OPENAI_API_KEY = "your-openai-api-key-here"- Run the application
streamlit run app.pyThe app will open automatically in your browser at http://localhost:8501
Symptom-based inquiry:
User: "I have chest pain, which doctor should I see?"
Assistant: "Chest pain can be serious and should be evaluated promptly.
I recommend seeing our Cardiology specialist who focuses on heart and
cardiovascular conditions. However, if you're experiencing severe chest
pain, please seek emergency medical attention immediately..."
General information:
User: "What are your office hours?"
Assistant: "Our clinic is open Monday to Friday from 7am to 7pm, and
Saturdays from 8am to 12pm. We're closed on Sundays and major holidays..."
Specialty information:
User: "What does a dermatologist treat?"
Assistant: "Our Dermatology department treats various skin conditions
including acne, eczema, psoriasis, skin cancer screening, mole removal,
and also offers aesthetic treatments like anti-aging procedures..."
- Frontend: Streamlit
- AI Model: OpenAI GPT-3.5-turbo
- Language: Python 3.8+
- Session State Management: Maintains conversation history
- Streaming Responses: Real-time token-by-token display
- System Prompts: Carefully crafted instructions for medical context
- Error Handling: Graceful handling of API errors
- No data storage: Conversations are not persisted after session ends
- API key protection: Keys stored in secure secrets file
- No medical diagnosis: Assistant explicitly avoids making diagnoses
streamlit run app.pyThis chatbot is for informational purposes only and does not provide medical advice, diagnosis, or treatment. Always seek the advice of qualified health providers with any questions regarding medical conditions. In case of emergency, call your local emergency services immediately.