๐Ÿฉบ HIA (Health Insights Agent)

March 6, 2026 ยท View on GitHub

AI Agent to analyze blood reports and provide detailed health insights.

Features | Tech Stack | Installation | Project Structure | Contributing | Author

Usage Demo

๐ŸŒŸ Features

  • Agent-based architecture
    • Analysis Agent: Report analysis with in-context learning from previous analyses and a built-in knowledge base
    • Chat Agent: RAG-powered follow-up Q&A over your report (FAISS + HuggingFace embeddings)
  • Multi-model cascade via Groq with automatic fallback (primary โ†’ secondary โ†’ tertiary โ†’ fallback)
  • Chat sessions: Create multiple analysis sessions; each session stores report, analysis, and follow-up messages in Supabase
  • Report sources: Upload your own PDF or use the built-in sample report for quick testing
  • PDF handling: Upload up to 20MB, max 50 pages; validation for file type and medical-report content
  • Daily analysis limit: Configurable cap (default 15/day) with countdown in the sidebar
  • Secure auth: Supabase Auth (sign up / sign in), session validation, and configurable session timeout
  • Session history: View, switch, and delete past sessions; report text persisted for follow-up chat across reloads
  • Modern UI: Responsive Streamlit app with sidebar session list, user greeting, and real-time feedback

๐Ÿ› ๏ธ Tech Stack

  • Frontend: Streamlit (1.42+)
  • AI / LLM
    • Report analysis: Groq with multi-model fallback via ModelManager
      • Primary: meta-llama/llama-4-maverick-17b-128e-instruct
      • Secondary: llama-3.3-70b-versatile
      • Tertiary: llama-3.1-8b-instant
      • Fallback: llama3-70b-8192
    • Follow-up chat: RAG with LangChain, HuggingFace embeddings (all-MiniLM-L6-v2), FAISS vector store, and Groq (llama-3.3-70b-versatile)
  • Database: Supabase (PostgreSQL)
    • Tables: users, chat_sessions, chat_messages
  • Auth: Supabase Auth, Gotrue
  • PDF: PDFPlumber (text extraction), filetype (file validation)
  • Libraries: LangChain, LangChain Community, LangChain HuggingFace, LangChain Text Splitters, sentence-transformers, FAISS (CPU)

๐Ÿš€ Installation

Requirements ๐Ÿ“‹

  • Python 3.8+
  • Streamlit 1.42+
  • Supabase account
  • Groq API key
  • PDFPlumber, filetype

Getting Started ๐Ÿ“

  1. Clone the repository:
git clone https://github.com/harshhh28/hia.git
cd hia
  1. Install dependencies:
pip install -r requirements.txt
  1. Required environment variables (in .streamlit/secrets.toml):
SUPABASE_URL = "your-supabase-url"
SUPABASE_KEY = "your-supabase-key"
GROQ_API_KEY = "your-groq-api-key"
  1. Set up Supabase database schema:

The application uses three tables: users, chat_sessions, and chat_messages. Use the SQL script at public/db/script.sql to create them.

database schema

(You can turn off email confirmation on signup in Supabase: Authentication โ†’ Providers โ†’ Email โ†’ Confirm email.)

  1. Run the application:
streamlit run src\main.py

๐Ÿ“ Project Structure

hia/
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.py                 # Application entry point; chat UI and session flow
โ”‚   โ”œโ”€โ”€ auth/
โ”‚   โ”‚   โ”œโ”€โ”€ auth_service.py     # Supabase auth, sessions, chat message persistence
โ”‚   โ”‚   โ””โ”€โ”€ session_manager.py # Session init, timeout, create/delete chat sessions
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ analysis_form.py    # Report source (upload/sample), patient form, analysis trigger
โ”‚   โ”‚   โ”œโ”€โ”€ auth_pages.py       # Login / signup pages
โ”‚   โ”‚   โ”œโ”€โ”€ footer.py           # Footer component
โ”‚   โ”‚   โ”œโ”€โ”€ header.py           # User greeting
โ”‚   โ”‚   โ””โ”€โ”€ sidebar.py          # Session list, new session, daily limit, logout
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ”œโ”€โ”€ app_config.py       # App name, limits (upload, pages, analysis, timeout)
โ”‚   โ”‚   โ”œโ”€โ”€ prompts.py          # Specialist prompts for report analysis
โ”‚   โ”‚   โ””โ”€โ”€ sample_data.py      # Sample blood report for "Use Sample PDF"
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ””โ”€โ”€ ai_service.py       # Analysis + chat entry points; vector store caching
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ analysis_agent.py   # Report analysis, rate limits, knowledge base, in-context learning
โ”‚   โ”‚   โ”œโ”€โ”€ chat_agent.py       # RAG pipeline (embeddings, FAISS, query contextualization)
โ”‚   โ”‚   โ””โ”€โ”€ model_manager.py   # Groq multi-model cascade and fallback
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ validators.py       # Email, password, PDF file and content validation
โ”‚       โ””โ”€โ”€ pdf_extractor.py   # PDF text extraction and validation
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ db/
โ”‚       โ”œโ”€โ”€ script.sql          # Supabase schema (users, chat_sessions, chat_messages)
โ”‚       โ””โ”€โ”€ schema.png          # Schema diagram

๐Ÿ‘ฅ Contributing

Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests, the development workflow, coding standards, and more.

We appreciate all contributions, from reporting bugs and improving documentation to implementing new features.

๐Ÿ‘จโ€๐Ÿ’ป Contributors

Thanks to all the amazing contributors who have helped improve this project!

AvatarNameGitHubRoleContributionsPR(s)Notes
harshhh28 avatarHarsh Gajjarharshhh28Project Creator & MaintainerCore implementation, DocumentationN/ALead Developer
gaurav98095 avatarGauravgaurav98095ContributorDB Schema, bugs#1, #5, #6, #7Database Design, bugs

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™‹โ€โ™‚๏ธ Author

Created by Harsh Gajjar