Skip to content

adithyanms-debug/DocAssist

Repository files navigation

Doctor Assist - AI Medical Interview System

An intelligent medical assistant that acts as a Senior Doctor conducting dynamic interviews with ASHA workers. The system uses Agentic AI and RAG (Retrieval Augmented Generation) to ask targeted follow-up questions and provide diagnoses with actionable medical advice.

Features

  • 🤖 Agentic AI: Conducts dynamic interviews, asking targeted follow-up questions
  • 📚 RAG System: Retrieves relevant medical information from a knowledge base
  • 🗄️ Pinecone Vector Database: Stores and searches medical knowledge efficiently
  • 💬 Streamlit GUI: Beautiful, interactive web interface
  • 🔍 Context-Aware: Maintains conversation context throughout the interview

Architecture

  1. PDF Processing: Extracts and chunks medical information from health.pdf
  2. Vector Database: Stores embeddings in Pinecone for semantic search
  3. RAG System: Retrieves relevant context based on symptoms
  4. Doctor Agent: Uses Gemini AI to conduct interviews and provide diagnoses
  5. Streamlit Interface: User-friendly chat interface for ASHA workers

Setup Instructions

1. Install Dependencies

pip install -r requirements.txt

### 2. Set Up Environment Variables

Create a `.env` file in the project root with the following:

```env
# Gemini API Key
GEMINI_API_KEY=your_gemini_api_key_here

# Pinecone API Key
PINECONE_API_KEY=your_pinecone_api_key_here

# Pinecone Environment (e.g., us-east-1, us-west-2)
PINECONE_ENVIRONMENT=us-east-1

# Pinecone Index Name
PINECONE_INDEX_NAME=doctor-assist

3. Get API Keys

4. Set Up Vector Database

Run the setup script to process the PDF and upload it to Pinecone:

python setup_vector_db.py

This will:

  • Extract text from health.pdf
  • Chunk the text into manageable pieces
  • Generate embeddings
  • Upload to Pinecone vector database

Note: This only needs to be run once, or when you update the PDF.

5. Run the Application

streamlit run app.py

The app will open in your browser at http://localhost:8501

Usage

  1. Enter Initial Symptoms: Type the patient's initial symptoms (e.g., "45-year-old male, high fever for 3 days, headache")

  2. Answer Follow-up Questions: The AI doctor will ask targeted questions to gather more information

  3. Receive Assessment: Once enough information is gathered, you'll receive:

    • Diagnosis with confidence level
    • Actionable medical advice
    • Medication warnings
    • Referral recommendations

Example Workflow

ASHA Worker: "45-year-old male, high fever for 3 days, headache"

Doctor: "Please check the patient's eyes. Is there any yellowing (Jaundice)? 
        Also, ask if they have joint pain."

ASHA Worker: "No yellowing. Severe joint pain behind the eyes."

Doctor: ASSESSMENT:
        Suspected Dengue Fever (85% Confidence)
        
        Actionable Advice:
        - Do NOT give Aspirin (bleeding risk)
        - Prescribe Paracetamol
        - Refer to District Hospital for Platelet count
        
        Explanation:
        High fever combined with retro-orbital pain (pain behind eyes) 
        is a classic sign of Dengue.

Project Structure

DoctorAssit/
├── app.py                 # Streamlit main application
├── doctor_agent.py        # Core AI agent logic
├── rag_utils.py           # RAG utilities for vector search
├── setup_vector_db.py     # Script to set up Pinecone database
├── requirements.txt       # Python dependencies
├── .env                   # Environment variables (create this)
├── health.pdf             # Medical knowledge base PDF
└── README.md             # This file

Technologies Used

  • Streamlit: Web interface
  • Google Gemini: LLM for medical reasoning
  • Pinecone: Vector database for semantic search
  • Sentence Transformers: Text embeddings
  • PyPDF2: PDF text extraction

Important Notes

⚠️ Medical Disclaimer: This is an AI assistant for medical guidance. Always consult with qualified healthcare professionals for critical medical decisions. This tool is designed to assist ASHA workers, not replace professional medical judgment.

Troubleshooting

Issue: "Index not found"

  • Make sure you've run setup_vector_db.py first
  • Check that your Pinecone index name matches in .env

Issue: "API key error"

  • Verify your API keys are correct in .env
  • Make sure the .env file is in the project root

Issue: "No relevant context found"

  • The RAG system might not have found relevant information
  • Try rephrasing your query or check if the PDF was uploaded correctly

License

This project is for educational and healthcare assistance purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages