Spaces:
Runtime error

File size: 2,624 Bytes
8f7e3b6
4adf7aa
 
 
dfe0fb4
8f7e3b6
4f9cf3b
8f7e3b6
 
4adf7aa
 
 
 
 
 
 
 
 
8f7e3b6
 
4adf7aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
title: MediBot - AI Medical Symptom Checker
emoji: πŸ₯
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: "6.11.0"
app_file: app.py
pinned: false
license: mit
tags:
  - medical
  - nlp
  - langchain
  - faiss
  - rag
  - openai
  - symptom-checker
---

# πŸ₯ MediBot β€” AI Medical Symptom Checker

An intelligent medical chatbot that uses **Retrieval-Augmented Generation (RAG)**, **FAISS vector search**, and **LangChain ReAct agents** to help users understand their symptoms and identify possible conditions.

## ⚠️ Disclaimer

MediBot is for **informational purposes only** and does NOT replace professional medical advice. Always consult a licensed healthcare provider.

## Architecture

```
User Input β†’ LangChain ReAct Agent β†’ FAISS VectorStore (41 diseases)
                    ↓                        ↓
              Tool Selection         Semantic Symptom Search
                    ↓                        ↓
         Disease Details Lookup    Severity Score Calculation
                    ↓
            Gradio Chat Response
```

## Tech Stack

| Component | Technology |
|---|---|
| LLM | OpenAI GPT-4o-mini |
| Embeddings | OpenAI text-embedding-3-small |
| Vector Store | FAISS (Facebook AI Similarity Search) |
| Agent Framework | LangChain ReAct |
| Memory | LangGraph MemorySaver (per thread_id) |
| UI | Gradio |
| Deployment | HuggingFace Spaces |

## Key Features

- **Semantic symptom search**: Finds diseases even when you don't use exact medical terms
- **Multi-agent ReAct reasoning**: Dynamically selects the right tools for each query
- **Conversation memory**: Remembers symptoms mentioned in previous messages
- **Severity scoring**: Weighs each symptom by clinical importance (scale 1–6)
- **Structured output**: Disease descriptions, precautions, and severity levels
- **Edge case handling**: Graceful responses to unknown symptoms, empty input, or ambiguous queries

## Data Sources

- `dataset.csv` β€” 4,920 rows mapping 41 diseases to 17 symptoms each
- `symptom_Description.csv` β€” Medical descriptions for 41 diseases
- `Symptom-severity.csv` β€” Clinical severity weights for 133 symptoms
- `symptom_precaution.csv` β€” Up to 4 precautions per disease

## Setup (Local)

```bash
# Clone and install
pip install -r requirements.txt

# Set your OpenAI API key
cp .env.example .env
# Edit .env and add your key

# Run
python app.py
```

## HuggingFace Spaces Deployment

Set `OPENAI_API_KEY` as a **Secret** in your Space settings. The FAISS index is built on first launch (takes ~30 seconds, then cached).

---

*MediBot Capstone Β· Interview Kickstart*