Skip to content

shaileshdev4/medcred

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MedCred

Medical AI content integrity monitor for the Google Cloud Rapid Agent Hackathon - Arize track.

Paste AI-generated health content and get a PASS / FAIL verdict with full evidence. MedCred combines OpenFDA checks, external API verification, Phoenix trace-informed judging, and calibration-gated self-improvement.

Calibration: 99% label agreement on a 100-case held-out set (40 PASS / 40 FAIL / 20 edge). Reproduce with POST /calibration/run?mode=fast.


Architecture

Two-layer defense

Two-layer defense

OpenFDA extraction feeds the Gemini judge; a deterministic safety gate enforces FAIL after the verdict for invented drugs, deprecated treatments, and high-risk patterns. Phoenix handles subtler fraud the gate cannot catch (fake PMIDs, inflated efficacy claims).

Analyze pipeline

Analyze pipeline

Grounding → External APIs → OpenFDA → Phoenix MCP → phoenix_context → Judge → Gate → Annotate → Correction

Self-improve loop

Self-improve loop

Every 5 evaluations: read FAIL spans → propose prompt update → A/B test on held-out calibration set → promote only if agreement meets or exceeds baseline.

Tech stack

Tech stack


Quick start

Prerequisites

  • Python 3.13+, uv
  • Node.js 18+ (frontend)
  • GCP project with Vertex AI + Agent Builder (optional grounding)
  • Arize Phoenix API key

Backend

git clone https://github.com/shaileshdev4/medcred
cd medcred/backend
cp .env.example .env
# Set: PHOENIX_API_KEY, PHOENIX_SPACE, GOOGLE_CLOUD_PROJECT, GOOGLE_GENAI_USE_VERTEXAI=1
uv pip install -r requirements.txt
uv run python main.py

Health check: curl http://localhost:8000/health

Frontend

cd medcred/frontend
cp .env.example .env.local
# Set NEXT_PUBLIC_API_URL=http://localhost:8000
npm install && npm run dev

Open http://localhost:3000


Demo presets (Analyze)

Preset What it proves
Fake drug (synaptol) OpenFDA + gate → FAIL
Citation fraud (lisinopril + fake PMID) Phoenix trace + judge → FAIL (gate does not trigger)
Dangerous dosing Deterministic gate → FAIL

Testing

cd medcred/backend
uv pip install -r requirements-dev.txt
uv run pytest tests/ -q

Preflight (DNS + Phoenix + Vertex):

uv run python agent.py --preflight-only

ADK batch smoke (1 article):

uv run python agent.py healthgpt --smoke

Phoenix OTLP smoke:

uv run python scripts/verify_phoenix_trace.py

Calibration (100 cases, ~25 min; batch if you hit Vertex 429):

uv run python scripts/run_calibration_report.py
# or: curl -X POST "http://localhost:8000/calibration/run?mode=fast"

Pre-seed Phoenix traces before demo (25 evals):

uv run python scripts/preseed_phoenix_traces.py

API

Endpoint Description
POST /analyze/stream SSE paste-audit pipeline
POST /evaluate/{publisher_id} ADK batch evaluation
GET /evaluate/{publisher_id}/live Theater SSE stream
POST /calibration/run?mode=fast Label agreement on calibration set
POST /improvements/run?force=true Trigger self-improve cycle
GET /health Service + Phoenix/Postgres status

Project structure

medcred/
├── backend/
│   ├── agent.py              # ADK SequentialAgent + CLI
│   ├── main.py               # FastAPI API
│   ├── core/                 # Phoenix tracing, evaluator base, self-improve
│   ├── single_eval.py        # Analyze pipeline
│   ├── sse_handler.py        # Theater SSE
│   ├── phoenix_mcp.py        # ADK McpToolset → @arizeai/phoenix-mcp
│   ├── phoenix_context.py    # Drug-aware trace injection
│   ├── calibration_runner.py # Label agreement + promotion gate
│   ├── evaluators/           # Gemini medical judge
│   ├── calibration_dataset.json
│   ├── scripts/              # Smoke, calibration, preseed
│   └── tests/                # 53 tests
├── frontend/                 # Next.js 14 dashboard
├── images/                   # Architecture diagrams
├── docs/
│   ├── SUBMISSION.md         # Deploy + Devpost checklist
│   └── AGENT_BUILDER_MEDCRED.md
├── medcred_devpost.md        # Devpost write-up
└── LICENSE

Deployment

See docs/SUBMISSION.md for Railway (backend), Vercel (frontend), and Neon (Postgres).

Docker:

docker build -t medcred-backend ./backend
docker build -t medcred-frontend ./frontend

Built with

Python, FastAPI, Next.js, Google ADK, Gemini 2.5 Flash, Vertex AI, Arize Phoenix, phoenix-mcp, OpenFDA, DailyMed, PubMed, ClinicalTrials.gov, MedlinePlus, PostgreSQL, Neon.

Full Devpost narrative: medcred_devpost.md


License

MIT - see LICENSE.

About

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors