An intelligent healthcare assistant with memory capabilities using Mem0, built using FastAPI, Chainlit, and mem0. This bot can remember patient information across conversations, providing personalized healthcare support.
mem0_demo.mp4
- 🧠 Memory System: Remembers patient information and conversation history using mem0
- 🔄 Streaming Responses: Real-time streaming of AI responses for a better user experience
- 🏥 Healthcare Focus: Specialized in healthcare-related conversations and information
- 🌐 Dual Interface: API backend with FastAPI and interactive UI with Chainlit
- 🔒 Secure: Designed with healthcare data privacy considerations
- 📱 Responsive UI: Modern, user-friendly interface for patient interactions
git clone https://github.com/extrawest/ai_healthcare_bot_with_memory.git
cd ai_healthcare_bot_with_memory
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Copy the example environment file and configure your settings:
cp .env.example .env
Edit the .env
file with your own settings:
- Set your OpenAI API key
- Configure Qdrant settings for vector storage
- Adjust host/port settings if needed
First, start the FastAPI backend server:
python -m src.main
The API will be available at http://0.0.0.0:8000 by default.
In a new terminal window (with the virtual environment activated), start the Chainlit UI:
python run_chainlit.py
The UI will be available at http://0.0.0.0:8001 by default.
Open your browser and navigate to http://0.0.0.0:8001 to start interacting with the healthcare bot. The bot will remember your conversation history and provide personalized healthcare support.
POST /chat/completions
Request body:
{
"user_message": "I have a headache and would like to schedule an appointment",
"user_id": "user_12345"
}
Response: A streaming response with AI-generated content.
The bot uses mem0 to store and retrieve relevant information from previous conversations. This allows it to:
- Remember patient symptoms and conditions
- Recall previous appointments and discussions
- Provide personalized healthcare advice based on patient history
- Python 3.9+
- OpenAI API key
- Qdrant instance (for vector storage)
- FastAPI
- Chainlit
- mem0
- langchain
The system uses mem0 for memory storage with the following configuration:
- OpenAI embeddings (text-embedding-3-large)
- Qdrant vector store for efficient retrieval
- Custom prompt for healthcare entity extraction
The application implements streaming responses using:
- FastAPI's StreamingResponse
- Custom streaming service that converts regular responses to streams
- Chainlit's streaming capabilities for real-time UI updates
The AIHealthcareSupport agent:
- Retrieves relevant memories for each query
- Builds context from previous conversations
- Uses OpenAI's GPT-4o model for generating responses
- Stores new conversation data in memory
Developed by extrawest. Software development company