File size: 3,571 Bytes
774f1fa
 
 
 
 
 
 
 
 
 
 
 
 
 
bfda151
 
 
 
 
 
e7279ce
 
bfda151
 
e7279ce
 
 
 
 
 
 
 
 
 
 
 
 
 
bfda151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e7279ce
 
 
 
 
 
 
 
 
 
bfda151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: Beacon Trial Finder
emoji: πŸ“š
colorFrom: gray
colorTo: yellow
sdk: gradio
sdk_version: 6.14.0
python_version: '3.13'
app_file: app.py
pinned: false
license: mit
short_description: help patients with rare disease to find clinical trials
---

# Beacon β€” Rare Disease Clinical Trial Finder

Beacon is a conversational AI assistant that helps patients with rare diseases find relevant recruiting clinical trials near them. It conducts a warm intake interview, geocodes the patient's location, queries [ClinicalTrials.gov](https://clinicaltrials.gov) in real time, and produces a ranked report of the closest matching trials.

## How it works

1. **Intake agent** (Claude Sonnet) β€” interviews the patient conversationally to collect disease, age, symptom onset date, formal diagnosis date, location, preferred trial phases, and whether they are interested in Expanded Access Programs (EAP / compassionate use).
2. **Research agent** (Claude Opus) β€” searches ClinicalTrials.gov via the official v2 API for clinical trials and/or EAP listings, retrying with synonyms or wider radii if results are sparse, then outputs a ranked report with eligibility notes and next steps.
3. **LangGraph** orchestrates the two-node pipeline (intake β†’ research).

### Clinical trial phases explained

| Phase | Focus | Typical size |
|---|---|---|
| **Early Phase 1** | First-in-human safety; tiny doses | ~10–15 people |
| **Phase 1** | Safe dosage range and side effects | 20–80 people |
| **Phase 2** | Does it work? Continued safety | 100–300 people |
| **Phase 3** | vs. standard of care; required for FDA approval | 1,000–3,000 people |
| **Phase 4** | Post-approval long-term surveillance | Varies |

### Expanded Access Programs (EAP)

EAP (also called compassionate use) allows patients who do not qualify for or cannot access a clinical trial to receive an investigational drug or device outside of a formal trial. The treatment is not yet FDA-approved; a physician must submit the EAP request to the drug sponsor and obtain FDA authorization. Beacon can search for available EAP listings alongside clinical trials.

## Project setup

### Prerequisites

- Python 3.11+
- [`uv`](https://docs.astral.sh/uv/) (recommended) or `pip`

### 1. Clone the repo

```bash
git clone <repo-url>
cd beacon
```

### 2. Install dependencies

```bash
uv sync
```

Or with pip:

```bash
pip install -e .
```

### 3. Configure API keys

Copy the example env file and fill in your keys:

```bash
cp .env.example .env
```

Open `.env` and replace the placeholder values:

```env
ANTHROPIC_API_KEY=your_anthropic_api_key_here
```

### 4. Run

```bash
uv run python app.py
```

#### Hot-reload during development

Use the `gradio` CLI to automatically reload the app whenever you save a file β€” no manual restart needed:

```bash
uv run gradio app.py
```

> **Note:** Active user sessions are reset on each reload.

## Configuration

| Environment variable | Default     | Description       |
|----------------------|-------------|-------------------|
| `ANTHROPIC_API_KEY`  | *(required)*| Anthropic API key |

## Project structure

```
beacon/
β”œβ”€β”€ app.py                   # Gradio web UI entry point
β”œβ”€β”€ main.py                  # Terminal entry point
β”œβ”€β”€ clinical_trials_guru.py  # Intake + research agents, LangGraph pipeline
β”œβ”€β”€ llm.py                   # LLM provider abstraction
β”œβ”€β”€ requirements.txt         # HuggingFace Spaces dependencies
β”œβ”€β”€ pyproject.toml
└── .env                     # Local secrets β€” not committed
```