Skip to content

An LLM graph RAG agent chatbot built with LangChain, Neo4j, FastAPI, Streamlit, and synthetic hospital data

Notifications You must be signed in to change notification settings

asanmateu/healthcare-rag-chatbot

Repository files navigation

Healthcare RAG Agent 🤖

I decided to build this chatbot, with the help of Real Python's LLM RAG Chatbot tutorial, to have an LLM project to build upon as I learn new topics and experiment with new ideas.

Along the way, I learned about LangChain, how and when to use knowledge graphs, and how to quickly deploy LLM RAG apps with FastAPI and Streamlit.

Why don't you check it out?

Start by cloning this repo and adding a .env file with the following environment variables:

OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>

NEO4J_URI=<YOUR_NEO4J_URI>
NEO4J_USERNAME=<YOUR_NEO4J_USERNAME>
NEO4J_PASSWORD=<YOUR_NEO4J_PASSWORD>

HOSPITALS_CSV_PATH=https://raw.githubusercontent.com/hfhoffman1144/langchain_neo4j_rag_app/main/data/hospitals.csv
PAYERS_CSV_PATH=https://raw.githubusercontent.com/hfhoffman1144/langchain_neo4j_rag_app/main/data/payers.csv
PHYSICIANS_CSV_PATH=https://raw.githubusercontent.com/hfhoffman1144/langchain_neo4j_rag_app/main/data/physicians.csv
PATIENTS_CSV_PATH=https://raw.githubusercontent.com/hfhoffman1144/langchain_neo4j_rag_app/main/data/patients.csv
VISITS_CSV_PATH=https://raw.githubusercontent.com/hfhoffman1144/langchain_neo4j_rag_app/main/data/visits.csv
REVIEWS_CSV_PATH=https://raw.githubusercontent.com/hfhoffman1144/langchain_neo4j_rag_app/main/data/reviews.csv

HOSPITAL_AGENT_MODEL=gpt-3.5-turbo-1106
HOSPITAL_CYPHER_MODEL=gpt-3.5-turbo-1106
HOSPITAL_QA_MODEL=gpt-3.5-turbo-0125

CHATBOT_URL=http://host.docker.internal:8000/hospital-rag-agent

Next, navigate to the project root, start Docker, make sure your AuraDB instance is up and running, and then run:

make build

The build will start the servers, however, you can also start the server with the command:

make start

and stop all containers by running:

make stop

You can interact with the chatbot API docs on localhost:8000/docs, and the UI on localhost:8501:

Screenshot 2024-03-27 at 19 44 54

Database design

It would be useful to look at the way the database has been structured to come up with some potential questions you want to make to the chatbot:

Screenshot 2024-04-07 at 23 45 47

Node properties

Screenshot 2024-04-07 at 23 44 17

Relationship properties

Screenshot 2024-04-07 at 23 44 57

About

An LLM graph RAG agent chatbot built with LangChain, Neo4j, FastAPI, Streamlit, and synthetic hospital data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published