AI Health Counselor

πŸ₯ AI Health Counselor β€” RAG-Powered Medical Guidance

Framework Database Safety Memory

Responsible AI for health counseling β€” a retrieval-augmented generation (RAG) system providing structured, safety-first medical guidance over curated datasets with context-aware dialogue.


πŸ“Œ Overview

Healthcare AI requires more than just high accuracy; it requires rigorous safety guardrails, context-aware memory, and the ability to strictly adhere to topic boundaries. This project implements a RAG-powered Health Counselor designed to provide informative, responsible medical guidance while minimizing hallucinations and ensuring mandatory disclaimers are always present.

The system utilizes ChromaDB for efficient retrieval over thousands of curated medical Q&A entries and Pydantic for strictly structured outputs to ensure consistency in medical advice formatting.


βš™οΈ Project Details

PropertyValue
DomainHealthcare / Medical Q&A
Data SourceCurated Medical Q&A Datasets
Retrieval EngineChromaDB (Vector Search)
Memory StrategySliding-Window Conversation Memory
RoutingFunction Calling for Symptom Follow-up
SafetyHallucination Detection & Topic Filtering

πŸ›‘οΈ Safety & Responsibility Layer

  • Topic Boundary Filtering: Automatically rejects queries outside the medical/health domain to prevent misuse.
  • Hallucination Detection: Cross-references generated responses against retrieved context to flag potential factual errors.
  • Mandatory Disclaimers: Automatically appends medical disclaimers to every response, emphasizing that the AI is not a substitute for professional medical advice.

🧠 Approach

Dialogue & Reasoning Pipeline

User Query
      β”‚
      β–Ό
 Safety Filter (Input Guardrails)
      β”‚
      β–Ό
 Retrieval Step (ChromaDB)
      β”‚
      β”œβ”€β”€β–Ί Search curated medical Q&A
      β”‚
      β–Ό
 Context-Aware Dialogue Engine (LangChain)
      β”‚
      β”œβ”€β”€β–Ί Sliding-window Memory (History)
      └──► Function Calling (Symptom Routing)
      β”‚
      β–Ό
 Hallucination Detection (Verification)
      β”‚
      β–Ό
 Structured Response (Pydantic + Disclaimer)

Key Techniques

  • Context-Aware Multi-turn Dialogue: Implemented stateful conversation management using sliding-window memory, significantly improving response coherence across long user sessions.
  • Symptom Follow-up Routing: Leveraged LLM function calling to identify when a user mentions specific symptoms, triggering prioritized routing to specialized follow-up diagnostic questions.
  • RAG over Curated Data: Eschewed broad web-searches for retrieval over high-quality, verified medical Q&A pairs to ensure grounding in expert knowledge.
  • Structured Output (Pydantic): Every response follows a rigid schema: advice, supporting_evidence, suggested_next_steps, and disclaimer.

πŸ“ Repository Structure

health-counselor-ai/
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ curated_qa/             # Verified medical datasets
β”‚   └── vectordb/               # ChromaDB index persistence
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ engine/                 # Core LangChain RAG logic
β”‚   β”‚   β”œβ”€β”€ chains.py           # Dialogue and retrieval chains
β”‚   β”‚   └── memory.py           # Sliding-window implementation
β”‚   β”œβ”€β”€ safety/                 # Guardrails and filters
β”‚   β”‚   β”œβ”€β”€ hallucination.py    # Fact-checking against context
β”‚   β”‚   └── topic_filter.py     # Domain boundary enforcement
β”‚   β”œβ”€β”€ routing/                # Function calling for symptom routing
β”‚   └── schemas/                # Pydantic models for responses
β”œβ”€β”€ notebooks/
β”‚   └── EDA_and_Indexing.ipynb  # Data processing and embedding
β”œβ”€β”€ requirements.txt
└── README.md

πŸ“Š Performance & Coherence

  • Response Coherence: High stability maintained across 10+ turn conversations due to the sliding-window memory strategy.
  • Safety Compliance: 100% adherence to topic filtering for non-medical queries during testing.
  • Retrieval Precision: High overlap between generated advice and retrieved reference documents.

The system was built with a β€œSafety First” philosophy, prioritizing response grounding and disclaimer inclusion over conversational creativity.


πŸ› οΈ Tech Stack

ComponentTool
OrchestrationLangChain
Vector StoreChromaDB
ValidationPydantic
LogicPython
LLMsOpenAI GPT-4o / Claude 3 Sonnet
MetricsRAGAS (for retrieval/generation evaluation)

πŸ“š References


Focusing on responsible, grounded AI solutions for healthcare guidance.