Spaces:
Sleeping
Sleeping
Commit History
-
fix: enforce patient's phase preference in API call, not LLM guidance
KevinIsInCoding +1: Claude Sonnet 4.6Previously the research LLM was expected to forward profile.phases to the search tool — an unreliable pattern. Now the code sets phases directly from profile.phases for INTERVENTIONAL searches, ignoring whatever the LLM passed. EAP and OBSERVATIONAL searches are unaffected (phase filters don't apply there). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>276f805 -
fix: show all nearby sites and explicit NCT ID per trial
KevinIsInCoding +1: Claude Sonnet 4.6RESEARCH_SYSTEM output format now: - Lists every nearest_sites entry under "Nearby sites:" instead of showing only the closest facility in a single 📍 header line - Adds an explicit **NCT:** line so the trial number appears as readable text, not just embedded in the URL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>092de1d
-
fix: update intake prompt default radius from 100 to 20 miles
KevinIsInCoding +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>13ab5fc -
chore: force Space rebuild
KevinIsInCoding863db8b -
perf: rank trials by phase, cap at 15, strip bloat, tighten defaults (#25)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureTrial ranking (Phase 4 > Phase 3 > ... > EAP > Observational) replaces pure distance sorting so the highest-value trials surface first. Token reduction (~60-80% of tool-result payload): - _rank_and_slim: cap at 15 trials before LLM, strip summary/conditions/ keywords/age fields/std_ages/eligibility, reduce nearest_sites 5→3, drop intervention descriptions - max_tokens: research 8096→3000, bulk-parse eligibility 8192→4096 Default search radius: 100 miles → 20 miles Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>a009989 -
perf: trim intake system prompt from ~905 to ~290 tokens (#23)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signature* perf: add prompt caching to intake and research agents Wraps system prompts and tool lists with cache_control: ephemeral at all five API call sites. Cached tokens are billed at 10% of normal input rate, saving ~90% on repeated turns within a session. Adds cached_system() and cached_tools() helpers to llm.py so the pattern stays consistent and easy to update. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * perf: trim intake system prompt from ~905 to ~290 tokens Cuts verbose multi-sentence phase descriptions, long EAP/observational paragraphs, and tool-schema-redundant instructions down to compact one-liners. All behavioral rules (YYYY-MM dates, never skip ZIP, submit_profile gate) are preserved. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>80162d5 -
perf: add prompt caching to intake and research agents (#22)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureWraps system prompts and tool lists with cache_control: ephemeral at all five API call sites. Cached tokens are billed at 10% of normal input rate, saving ~90% on repeated turns within a session. Adds cached_system() and cached_tools() helpers to llm.py so the pattern stays consistent and easy to update. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>5b5c80a -
perf: switch research agent from Opus to Haiku (#21)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureRESEARCH_MODEL was claude-opus-4-7 (~$15/MTok input). Switching to claude-haiku-4-5-20251001 (~$0.80/MTok input) cuts the per-session research cost by ~19x. The research task (call search tool, synthesize trial results) does not require Opus-level reasoning. Estimated saving: ~$0.22/session (~70% of total session cost). Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>a3080f5 -
test(critic-fixes): address brittleness, over-mocking, and missing edge cases (#20)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureFindings from post-wave-4 critic review: Missing edge cases (high): - test_models.py: add TestGeocodeZip covering valid Nominatim response and empty-results → ValueError (pytest-httpx) - test_eligibility.py: document that _resolve_patient_value("sex") returns found=False because PatientProfile has no sex field Missing edge cases (medium): - test_trials_api.py: add test_location_at_zero_lat_is_silently_dropped documenting that lat=0.0 is falsy and causes the site to be skipped - test_intake.py: add test_future_date_returns_negative documenting that _months_from_date does not clamp future dates to zero Brittleness fixes (medium): - test_eligibility.py: test_empty_eligibility_text_returns_pass now uses assert_not_called() instead of an unconsumed side_effect list - test_research.py: test_two_search_calls_before_end_turn now asserts the return value instead of only call_count - test_trials_api.py: test_geo_filter_formatted now asserts structure instead of exact float-to-st…3d5e588 -
test(wave-4): LLM orchestration tests for eligibility, intake, and research (#19)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signaturetests/agents/test_eligibility.py extended (54 tests total): - _parse_criteria: empty text skips API, criterion+constraint parsed, no-constraint→None, missing tool call→empty, exactly 1 API call - _assess_llm: empty→no call, pass/fail verdict mapping, unknown key skipped, missing tool call→all UNKNOWN - run_eligibility_check: deterministic criterion resolved without LLM assess, fail when criterion fails, empty eligibility→PASS, call counts - bulk_parse_and_strip: fields stripped, parsed_criteria/deterministic_verdicts added, verdict computed for known key, trials beyond top_n untouched, empty eligibility skipped, API failure returns empty verdicts tests/agents/test_intake.py (20 tests): - _months_from_date: same-month, 1-month, 12-month, year-boundary, multi-year, invalid string, empty string (freezegun) - _resolve_months: prefers date key, fallback to int, missing both→0, None→0 - stream_intake_turn: token events, text event+updated messages, identify_disease→reset_strea…a6f4696 -
test(wave-3): deterministic eligibility and trials_api tests (#18)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signaturetests/agents/test_eligibility.py (37 tests): - _evaluate_deterministic: every operator (<=, >=, ==, !=, in, not_in, between) × pass/fail; output shape (confidence=high, patient_value stringified, reason format, unit inclusion, TypeError→FAIL) - _resolve_patient_value: patient.* fields, platform.* with/without data, unknown key - _compute_overall: precedence rule FAIL>UNKNOWN>PASS, empty list→PASS tests/test_trials_api.py (30 tests): - _flatten_and_rank: sort order, None-distance sorts last, nearest_sites capped at 5, central-contact phone fallback, required key presence - search_trials_api aggFilters: all 8 case-matrix branches from the inline comment in trials_api.py - search_trials_api pagination: nextPageToken forwarded, multi-page accumulation, empty response - search_trials_api retry: succeeds after 1 failure, raises after 3 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>9e87f14 -
test(wave-2): add pure-function tests for models and prompts (#17)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureCovers haversine_miles (5 cases: zero, known distance, symmetry, short, return type) and PatientProfile.summary (14 cases: all fields, phases, study types, edge cases). Covers lookup_disease_profile (15 cases: exact match, case-insensitive, synonyms, multi-disease registry, partial containment, unknown, structure validation). All 35 tests pass with no mocks — confirms pytest wiring and that the data/diseases/ JSON registry is structurally intact. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>9c9268b -
test(wave-1): add test infrastructure and conftest.py (#16)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureSet up pytest with pytest-mock, pytest-httpx, freezegun, and pytest-cov. Adds tests/conftest.py with shared fixtures (als_patient, mock_client) and factory functions (make_text_block, make_tool_use_block, make_message, FakeStream) that all subsequent test waves will depend on. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>01a873b -
docs: add unit test design document
KevinIsInCoding +1: Claude Sonnet 4.6Defines testing strategy, module coverage targets, and 7-stage implementation order for Beacon's test suite. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>b720671
-
feat: structured eligibility assessment with per-criterion verdicts (#15)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signature- Add agents/eligibility.py: two-step pipeline — bulk LLM parse of eligibility text into structured constraints, then deterministic code evaluation (Path A) for known patient fields; research LLM handles unclear criteria inline (Path B, no extra call) - Add data/criterion_keys.json: canonical key → patient/platform field mapping; extend without touching agent code - Add data/tools/{parse_criteria,parse_criteria_bulk,assess_eligibility}.json - Extend models.py: CriterionVerdict, ParsedConstraint, EligibilityCriterion, CriterionAssessment, TrialEligibilityReport - trials_api.py: extract full fields (sex, healthy_volunteers, std_ages, study_type, enrollment, conditions, keywords, interventions); remove 1000/500-char truncations; pageSize 200 → 1000 (fewer round trips) - agents/intake.py: accept onset_date/diagnosis_date (YYYY-MM) and compute months in Python — fixes LLM arithmetic drift on current date - agents/research.py: bulk parse + strip after each search; yield ("s…b4e34e7
-
feat: structured eligibility assessment with per-criterion verdicts (#14)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signature- Add agents/eligibility.py: two-step pipeline — bulk LLM parse of eligibility text into structured constraints, then deterministic code evaluation (Path A) for known patient fields; research LLM handles unclear criteria inline (Path B, no extra call) - Add data/criterion_keys.json: canonical key → patient/platform field mapping; extend without touching agent code - Add data/tools/{parse_criteria,parse_criteria_bulk,assess_eligibility}.json - Extend models.py: CriterionVerdict, ParsedConstraint, EligibilityCriterion, CriterionAssessment, TrialEligibilityReport - trials_api.py: extract full fields (sex, healthy_volunteers, std_ages, study_type, enrollment, conditions, keywords, interventions); remove 1000/500-char truncations; pageSize 200 → 1000 (fewer round trips) - agents/intake.py: accept onset_date/diagnosis_date (YYYY-MM) and compute months in Python — fixes LLM arithmetic drift on current date - agents/research.py: bulk parse + strip after each search; yield ("s…e15864e -
feat: SRP refactor, streaming UX fix, and semantic disease detection (#12)
KevinIsInCoding +3: Claude Sonnet 4.6, claude[bot], KevinIsInCodingUnverified signature* feat: SRP refactor, streaming UX fix, and semantic disease detection - Split 652-line clinical_trials_guru.py monolith into focused modules: config, models, tools, prompts, trials_api, _console, agents/intake, agents/research. clinical_trials_guru.py now ~60 lines of re-exports. - Move tool schemas and disease benchmark profiles to JSON files under data/; adding a new disease requires only a new JSON file, no code change. - Fix Gradio 6.x input-locking bug by switching all intake/research turns to Anthropic streaming API — inputs unblock after milliseconds, not 30s. - Replace brittle substring match_disease() with identify_disease tool: the intake agent calls identify_disease(standardized_name=...) when it semantically identifies the disease; system does reliable registry lookup via lookup_disease_profile(). Handles all languages, synonyms, and symptom descriptions that keyword matching could not. - Pin Gradio to >=6.14.0,<7.0.0 to prevent unexpected major-version br…22195c1 -
fix: handle EAP+phase combinations in aggFilters search logic (#11)
KevinIsInCoding +2: claude[bot], KevinIsInCodingUnverified signatureImplements all 5 search cases from issue #10: 1. Specific stages only → phase:X Y 2. All stages incl. NA → studyType:int 3. EAP only → studyType:exp 4. EAP + specific stages → studyType:exp,phase:X Y (combined filter) 5. EAP + all stages → studyType:exp Previously, EAP searches always ignored any phase preference. The fix adds phase-aware branching inside the is_eap block, combining studyType:exp with the numbered phase list when specific phases are requested. Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: KevinIsInCoding <KevinIsInCoding@users.noreply.github.com>4c8ffca -
feat: add Hugging Face-compatible logging infrastructure (#9)
KevinIsInCoding +2: claude[bot], KevinIsInCodingUnverified signature- New `beacon_logging.py` module with rotating JSON file handler and a console handler using HF's `%(levelname)s:%(name)s:%(message)s` format. Controlled via `BEACON_LOG_LEVEL` / `BEACON_LOG_DIR` env vars. - `clinical_trials_guru.py`: logs patient intake profile JSON (INFO) and full ClinicalTrials.gov request payload + per-page response metadata (DEBUG/INFO). - `app.py`: logs patient intake profile JSON (INFO) after web-UI intake. Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: KevinIsInCoding <KevinIsInCoding@users.noreply.github.com>083d098 -
feat: add Observational study type support (#7)
KevinIsInCoding +2: claude[bot], KevinIsInCodingUnverified signatureAdd support for filtering observational studies from ClinicalTrials.gov alongside existing Interventional and Expanded Access searches. - Extend SEARCH_TRIALS_TOOL enum with OBSERVATIONAL study_type - Add studyType:obs aggFilter handling in search_trials_api - Add include_observational field to PatientProfile and SUBMIT_PROFILE_TOOL - Update INTAKE_SYSTEM prompt to present observational studies as an option - Update RESEARCH_SYSTEM prompt to guide separate observational searches - Propagate include_observational from intake tool result in both CLI and web app Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: KevinIsInCoding <KevinIsInCoding@users.noreply.github.com>7389f19
-
Add Claude Code GitHub Workflow (#6)
KevinIsInCodingUnverified signature* "Claude PR Assistant workflow" * "Claude Code Review workflow"f27b72f
-
FIX: Translate report field labels (Trial, Sponsor, PI, etc.) in i18n mode (#4)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureAdd REPORT_LABELS dict with translated field names for ZH/ES/HI and inject them as explicit mappings in the language directive so the research agent uses the correct labels in every trial entry. Proper nouns (hospital names, drug names, etc.) remain untouched per the existing preserve rule. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>54a8876 -
FIX: Prevent translation of hospital names and proper nouns in i18n mode (#3)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signatureLanguage directives now explicitly instruct Claude to translate only its own explanatory text and never modify hospital/facility names, drug names, sponsor names, investigator names, trial titles, NCT IDs, or any proper nouns from trial data. Unsure cases default to keeping the original English. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>7d5835c -
FEAT: Add multi-language support (EN / ZH / ES / HI) (#2)
KevinIsInCoding +1: Claude Sonnet 4.6Unverified signature- New translations.py with UI string dicts and language directives for all 4 languages - Language dropdown in UI header — switching resets the session in the chosen language - Intake and research agents prepend a language directive to their system prompts so Claude responds entirely in the selected language (Chinese, Spanish, Hindi, English) - PatientProfile.lang field carries language through to the research agent - All hardcoded English UI strings replaced with UI[lang] lookups Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>eb6d0dc
-
Merge pull request #1 from KevinIsInCoding/feat/na-phase-and-full-pagination
KevinIsInCodingUnverified signatureFEAT: Support NA-phase trials and full result paginationb3c8b62 -
FEAT: Support NA-phase trials and fetch all results via pagination
KevinIsInCoding +1: Claude Sonnet 4.6- Add "na" (Not Applicable) as a valid phase option in intake and search tool schemas - Explain Not Applicable phase to patients during intake (device/unphased studies) - Instruct research agent never to enumerate all phases explicitly — pass phases=[] so NA-phase trials (which have no phase bucket on ClinicalTrials.gov) are included - Replace fixed pageSize cap with full pagination (pageSize=200 + nextPageToken loop) so all matching trials are fetched and ranked by the LLM, eliminating truncation - Raise report limit from top 5 to top 10 results per section Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>ee146e1 -
Merge feat/als-intake-and-api-fixes: ALS intake improvements and API fixes
KevinIsInCoding +1: Claude Sonnet 4.6- Add FVC % predicted, ALS subtype, and gene mutation fields to intake - Add PI name and contact info (phone/email) to trial results - Fix ClinicalTrials.gov API filter (aggFilters can't combine studyType + phase) - Require ZIP code to always be confirmed by patient (never inferred) - Restrict results to tool output only — no hallucinated hospitals - Resolve all lingering merge conflict markers in pyproject.toml and uv.lock - Consolidate README with HF Space YAML frontmatter and updated setup guide Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>95c1c84 -
FIX: Resolve merge conflict markers in pyproject.toml and regenerate uv.lock
KevinIsInCoding +1: Claude Sonnet 4.6Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>49cbd8a
-
FEAT: Add more information about Patient intake agent
KevinIsInCoding56d41c3 -
Update README with phase explanations, EAP section, and hot-reload command
KevinIsInCoding +1: Claude Sonnet 4.6Documents the diagnosis/onset distinction, trial phase meanings, EAP compassionate use pathway, and the `gradio app.py` hot-reload workflow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>e7279ce -
Add plain-language explanation of EAP in intake prompt
KevinIsInCoding +1: Claude Sonnet 4.6Patients unfamiliar with compassionate use now receive a clear description: what EAP is, how it differs from a trial, the physician-sponsor-FDA pathway, and the caveat that it does not guarantee efficacy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>73de926 -
Elaborate clinical trial phase descriptions in intake prompt
KevinIsInCoding +1: Claude Sonnet 4.6Patients often don't know what trial phases mean. The intake agent now briefly explains each phase (Early Phase 1 through Phase 4) so patients can make an informed choice about which phases they're open to. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>077fd95 -
Add Expanded Access Program (EAP) as a search option alongside clinical trials
KevinIsInCoding +1: Claude Sonnet 4.6Doctors noted patients may be interested in compassionate use / EAP when they don't qualify for a trial. The intake agent now asks whether the patient wants clinical trials, EAP, or both. The research agent can call search_clinical_trials with study_type=EXPANDED_ACCESS, which queries ClinicalTrials.gov with the correct AVAILABLE status and EXPANDED_ACCESS study type filter. Results appear in a dedicated EAP section of the report. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>57735b3 -
Add diagnosis_months to patient intake alongside onset_months
KevinIsInCoding +1: Claude Sonnet 4.6Doctors noted that formal diagnosis date and symptom onset date often differ and both are clinically relevant for trial eligibility. The intake agent now asks for and collects both fields, and the patient profile summary surfaces both to the research agent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>d2a29fe
-
Initial release: Beacon rare disease clinical trial finder
KevinIsInCoding +1: Claude Sonnet 4.6Conversational AI assistant that interviews patients, geocodes their location, and searches ClinicalTrials.gov in real time to surface nearby recruiting trials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>bfda151
-
initial commit
774f1fa -
initial commit
de5e581
-
Initial release: Beacon rare disease clinical trial finder
KevinIsInCoding +1: Claude Sonnet 4.6Conversational AI assistant that interviews patients, geocodes their location, and searches ClinicalTrials.gov in real time to surface nearby recruiting trials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>2aa1bda
-
Improve ALS intake fields, result format, and fix ClinicalTrials.gov API
KevinIsInCoding +1: Claude Sonnet 4.6- Add FVC % predicted and ALS subtype (sporadic/familial + gene mutation) to intake for ALS patients, both stored in benchmarks - Fix ZIP code skipping: narrow "infer what you can" so the model always asks the patient explicitly for their postal code - Fix 400 Bad Request on every API call: replace invalid filter.studyType with aggFilters=studyType:int/exp; phase and studyType filters are now applied correctly for interventional trials and EAPs - Extract PI name and contact phone/email from ClinicalTrials.gov API response (centralContacts, overallOfficials, per-site contacts) - Update result format: add Principal Investigator and Contact fields, expand Eligibility notes → Qualification criteria with explicit numbers - Prohibit hallucinated fallback center lists when no API results are found Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>450de16 -
Update README with phase explanations, EAP section, and hot-reload command
KevinIsInCoding +1: Claude Sonnet 4.6Documents the diagnosis/onset distinction, trial phase meanings, EAP compassionate use pathway, and the `gradio app.py` hot-reload workflow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>2361439 -
Add plain-language explanation of EAP in intake prompt
KevinIsInCoding +1: Claude Sonnet 4.6Patients unfamiliar with compassionate use now receive a clear description: what EAP is, how it differs from a trial, the physician-sponsor-FDA pathway, and the caveat that it does not guarantee efficacy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1424b71 -
Elaborate clinical trial phase descriptions in intake prompt
KevinIsInCoding +1: Claude Sonnet 4.6Patients often don't know what trial phases mean. The intake agent now briefly explains each phase (Early Phase 1 through Phase 4) so patients can make an informed choice about which phases they're open to. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1f9a208 -
Add Expanded Access Program (EAP) as a search option alongside clinical trials
KevinIsInCoding +1: Claude Sonnet 4.6Doctors noted patients may be interested in compassionate use / EAP when they don't qualify for a trial. The intake agent now asks whether the patient wants clinical trials, EAP, or both. The research agent can call search_clinical_trials with study_type=EXPANDED_ACCESS, which queries ClinicalTrials.gov with the correct AVAILABLE status and EXPANDED_ACCESS study type filter. Results appear in a dedicated EAP section of the report. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1aaa065 -
Add diagnosis_months to patient intake alongside onset_months
KevinIsInCoding +1: Claude Sonnet 4.6Doctors noted that formal diagnosis date and symptom onset date often differ and both are clinically relevant for trial eligibility. The intake agent now asks for and collects both fields, and the patient profile summary surfaces both to the research agent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>c85f3d6
-
To support Gradio Visualization and HuggingFace host
KevinIsInCodingb15c385
-
Initial release: Beacon rare disease clinical trial finder
KevinIsInCoding +1: Claude Sonnet 4.6Conversational AI assistant that interviews patients, geocodes their location, and searches ClinicalTrials.gov in real time to surface nearby recruiting trials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>f8d77e4
-
To support Gradio Visualization and HuggingFace host
KevinIsInCoding2fd08bb -
initial commit
Verified signature2a6ee87
-
Initial release: Beacon rare disease clinical trial finder
KevinIsInCoding +1: Claude Sonnet 4.6Conversational AI assistant that interviews patients, geocodes their location, and searches ClinicalTrials.gov in real time to surface nearby recruiting trials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>6977736