HOSTOBOT is an advanced Agentic Microservices demonstration combining Large Language Models (LLMs) with a Graph Database (Neo4j) to deliver a powerful Hybrid RAG (Retrieval-Augmented Generation) system.
Traditional RAG systems often struggle with structured aggregation and relationship-heavy queries. HOSTOBOT addresses this limitation using a Router Agent that dynamically selects the best tool:
- βοΈ Python Tools β real-time simulations and computations
- π Vector Search β qualitative insights (patient sentiment)
- π§ Graph Cypher Generation β quantitative analytics
This platform empowers users to effortlessly request complex hospital-related data using natural language queries.
The code is written in Python π.
The intelligent core of this system is the π₯ Hospital RAG Agent, which dynamically routes queries using the following advanced tools:
- π οΈ Current Hospitals (
get_current_hospitals_tools) β Retrieves the active list of hospitals directly from the Neo4j database. - π οΈ Wait Times (
get_current_wait_times) β Generates a simulated current wait time for patient emergency visits. - π οΈ Most Available Hospital (
get_most_available_hospital) β Suggests the most optimal hospital with the highest available capacity. - ππ οΈ Experiences & Reviews (
get_reviews) β Leverages Vector Search capabilities on patient "Review" nodes via aNeo4jVectorSearchChain, seamlessly integrating qualitative semantic search into the populated graph database. - ππ οΈ Graph Querying (
get_graph) β Dynamically translates natural language questions into precise Cypher queries using aCypherChain, enabling direct quantitative question-answering against the complex graph structure.
To run the application, you need the following prerequisites:
- π NEO4J Credentials: URI, Username, and Password.
- π AI API Key: Choose between OpenAI, Gemini, or Mistral.
π Action: Provide these credentials in your
.envfile and ensure Docker Desktop π³ is running before proceeding.
LLM_RAG_ETL_Showcase-Hostobot/
βββ .env # Critical environment configurations
βββ docker-compose.yml # Orchestration for all 4 services
β
βββ img/ # Images to display in the Readme
β βββ dbscheme.png
β
βββ hospital_neo4j_etl/ # DATA LAYER
β βββ src/
β β βββ hospital_bulk_csv_write.py # Bulk loader & relationship mapper
β β βββ entrypoint.sh # Execution script
β βββ Dockerfile
β
βββ chatbot_api/ # LOGIC LAYER (FastAPI)
β βββ src/
β β βββ main.py # API entry point & routes
β β βββ agents/
β β β βββ hospital_rag_agent.py # Agent & Tool definitions
β β βββ chains/
β β β βββ hospital_cypher_chain.py # Cypher generation logic
β β β βββ hospital_review_chain.py # Vector search logic
β β βββ tools/
β β β βββ wait_times.py # Simulated real-time tool
β β βββ models/
β β β βββ hospital_rag_query.py # Pydantic schemas
β β βββ utils/
β β βββ async_utils.py # Retry decorators
β βββ Dockerfile
β
βββ chatbot_frontend/ # PRESENTATION LAYER
βββ src/
β βββ main.py # Streamlit UI logic
βββ Dockerfile
The Neo4j database is modeled to handle multi-hop questions.
- π₯ Hospital:
{id, name, state_name} - π° Payer:
{id, name} - π¨ββοΈ π©Ί Physician:
{id, name, dob, school, salary} - π§βπ€βπ§ π€ Patient:
{id, name, sex, blood_type} - π
Visit:
{id, room_number, admission_type, status, diagnosis} - π Review:
{id, text, patient_name, physician_name}
(Patient)-[:HAS]->(Visit)(Physician)-[:TREATS]->(Visit)(Visit)-[:AT]->(Hospital)(Visit)-[:COVERED_BY]->(Payer)(Visit)-[:WRITES]->(Review)(Hospital)-[:EMPLOYS]->(Physician)
Graph Ontology: Mapping relationships between Patients, Visits, and Providers.
Start the entire microservices stack with a single command:
docker compose up --buildOnce the Docker containers are built and healthy, you can access the localized services:
- π API Documentation (FastAPI): http://localhost:8000/docs
- π¬ Chatbot UI (Streamlit): http://localhost:8501/
Try testing the agent with some of these complex, natural language questions:
- Which hospitals are part of the hospital network?
- Whatβs the current wait time at Wallace-Hamilton Hospital?
- At which hospitals are patients reporting issues related to billing or insurance?
- Whatβs the average length in days for completed emergency visits?
- How are patients describing the nursing team at Castaneda-Hardy?
- What was the total amount billed to each payer during 2023?
- What is the average charge for visits covered by Medicaid?
- Which doctor has the shortest average visit duration?
- What is the total billed amount for patient 789's hospital stay?
- Which state saw the biggest percentage increase in Medicaid visits from 2022 to 2023?
- Whatβs the average daily billing amount for patients with Aetna coverage?
- How many patient reviews have been submitted from Florida?
- For visits that include a chief complaint, what percentage also have a review?
- What percentage of visits at each hospital include patient reviews?
- Which physician has received the highest number of reviews for their visits?
- What is the unique identifier for Dr. James Cooper?
- Show all reviews associated with visits handled by physician 270 β include every one.

