Overview
This project implements a Django-based Patient Chat Application where patients can interact with an AI bot to manage health-related conversations, request changes to appointments, medications, and access important medical information. It uses a knowledge graph and an LLM-agnostic design to enhance functionality and scalability.
Key Features
- Health-Related Conversations: The bot assists with medical condition inquiries, medications, diets, and appointments.
- Appointment Requests: Patients can reschedule appointments, which are updated for the doctor in real time.
- Entity Extraction: Extracts key entities (e.g., medications, symptoms, appointments) and stores them in a Neo4j knowledge graph for future interactions.
- Memory Optimization: Manages long conversations by storing data in PostgreSQL and Neo4j, ensuring real-time processing.
- LLM-Agnostic Design: Built with Langchain for compatibility with various LLMs, such as Google Gemini, GPT-3, or LLaMA.
Details About Machine Learning
- Classifier for Query Filtering: Binary classifier trained on MedQuAD and Natural Questions datasets, along with a topic model from HuggingFace to filter out irrelevant queries.
- Entity Extraction for Knowledge Graph: Key entities like medications and appointment preferences are extracted using Bio_ClinicalBERT and regex matching.
Project Structure
├── datasets ├── patient_chat_app │ ├── chatbot │ ├── ml_models │ ├── static │ └── templates └── venv
Setup Instructions
Follow these steps to set up the application:
- Clone the repository and set up a virtual environment.
- Install dependencies with
pip install -r requirements.txt
. - Configure PostgreSQL and Neo4j databases and update settings in
settings.py
andknowledge_graph.py
. - Run migrations with
python manage.py migrate
. - Start the server using
python manage.py runserver
.
Future Improvements
- Implement multi-agent systems to separate task-based models more effectively.
- Add conversation summarization for easier documentation and review.
- Optimize memory storage by reducing redundancy between PostgreSQL and Neo4j.
Conclusion
This project demonstrates advanced chatbot functionality with health-related entity extraction, flexible LLM integration, and real-time appointment management. The architecture ensures scalability and adaptability for various use cases.