Skip to content

ShamyaHaria/clinagent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClinAgent

A production-grade clinical AI agent for natural language querying over CDISC-compliant trial data.

ClinAgent takes plain English questions about a Phase III oncology trial and routes them through a multi-tool agent — returning clinically meaningful answers backed by survival curves, AE tables, and data listings. Built to demonstrate what AI-assisted analysis looks like in regulated clinical environments.

Built by Shamya Haria


What you can ask it

"What are the most common adverse events in the DRUG-X arm?"
"Show me PFS and OS survival curves by treatment arm"
"How many grade 3 or higher SAEs were reported?"
"Baseline characteristics table by arm"
"List subjects who discontinued due to adverse events"

Architecture

flowchart TD
    A[User Query via Streamlit] --> B[ClinAgent Orchestrator\nGroq LLaMA-3.1 + Pydantic AI]
    B --> C[RAG Tool\npgvector semantic search]
    B --> D[Stats Tool\nKaplan-Meier, AE frequency]
    B --> E[Table Tool\nADaM listings]
    C & D & E --> F[PostgreSQL + pgvector\nSDTM + ADaM domains]
    F --> G[Langfuse\nself-hosted observability]
Loading

Clinical data

Synthetic CDISC-compliant dataset for study CLINX-2024-001 across three treatment arms (DRUG-X 100mg, DRUG-X 200mg, and PLACEBO, 100 subjects each). Nine SDTM and ADaM domains covering demographics, adverse events, dosing, vitals, and labs — ~34,000 records total, with 3,120 pgvector embeddings generated locally via all-MiniLM-L6-v2.


Stack

Layer Technology
LLM Groq llama-3.1-8b-instant
Embeddings sentence-transformers/all-MiniLM-L6-v2 (local)
Vector DB PostgreSQL 14 + pgvector
Agent Pydantic AI + custom tool router
Observability Langfuse (self-hosted via Docker)
UI Streamlit + Plotly
Survival analysis lifelines (Kaplan-Meier with 95% CI)
Tests Pytest — 39 tests, 100% passing

Clinical features

  • Treatment-emergent AE flagging (TRTEMFL), CTCAE grading, seriousness and relatedness classification
  • Kaplan-Meier PFS and OS with median survival and 95% confidence intervals per arm
  • Table 1 equivalent baseline characteristics for continuous and categorical variables
  • Cohort subsetting by arm, sex, age, tumor type, and ECOG PS
  • ADaM analysis variables (CHG, PCHG, BASE, NRIND) computed for lab and vital signs

About

A clinical AI agent that answers natural language queries over a CDISC-compliant Phase III oncology trial dataset, routing questions through semantic RAG, survival analysis, and ADaM table tools with full LLM observability.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages