Using LangGraph, LangChain, and OpenAI’s GPT models, the system processes patient queries, updates their medical records, and provides intelligent responses based on their history.
- AI-powered Appointment Scheduling
- Patient Profile Management (tracks medical history, allergies, past treatments)
- Emergency Detection & Alert System
- Multi-turn Conversations with Memory
- Graph-based Conversational Flow with Decision Routing
🔹 check_condition()
Routes the conversation:
- If the message contains
"emergency"
, routes tohandle_emergency()
- Otherwise, routes to
call_model()
🔹 call_model()
Retrieves patient history and generates AI responses using OpenAI's GPT model.
🔹 handle_emergency()
Provides immediate emergency instructions.
🔹 write_memory()
Updates and stores patient medical records.
- Clone the Repository
git clone https://github.com/taherfattahi/langgraph-medical-ai-assistant
cd langgraph-medical-ai-assistant
- Install Dependencies Ensure you have Python 3.8+ and install the required dependencies:
pip install -r requirements.txt
- Set Up Environment Variables Create a .env file with your OpenAI API key:
OPENAI_API_KEY=your-api-key-here
Run the chatbot assistant:
python main.py
Example Conversation:
Hello Taher! Thank you for reaching out. I can help you schedule an appointment for your routine check-up. May I know your availability for the appointment?
For emergencies:
User: This is an emergency! I'm experiencing severe chest pain.
Assistant: We’ve detected an emergency. Please contact emergency services immediately or call our 24/7 urgent line: +43 00 00 00.
- LangGraph - Graph-based conversation routing
- LangChain - Memory and LLM integration
- OpenAI GPT - AI-powered responses
- Python - Core language
- InMemoryStore - Persistent patient data storage
👨💻 Taher Fattahi 📧 Contact: taherfattahi11@gmail.com
Contributions are welcome! Feel free to fork the repo and submit pull requests. 🚀
This project is licensed under the MIT License.