Biomedical Agent - a variation of a deep researched with openFDA, DailyMed, ClinicalTrialsGov access
Python
0
94 commits
updated Mar 22, 2026
Biomedical research agent that integrates OpenFDA, DailyMed, ClinicalTrials.gov, ChEMBL, BindingDB, DrugCentral, Orange Book and related sources into a unified PostgreSQL database, with LLM-friendly search tools and a chat interface.
Prerequisites: PostgreSQL 14+, Python 3.12+, ~50 GB disk, 8+ GB RAM for full ingestion.
sudo apt-get install postgresql postgresql-contribbrew install postgresqlcp .env.example .env
pip install -e .
biomedagent-db verify-deps
biomedagent-db setup_postgres
biomedagent-db ingest
Data available. The database unifies clinical trials (ClinicalTrials.gov), molecular structures and biotherapeutics (ChEMBL, DrugCentral, BindingDB), biological targets, drug labels (OpenFDA, DailyMed), and regulatory data (Orange Book), with mappings from trials and products to molecules. Full schema: docs/DATABASE_SCHEMA.md.
Tools available. Retrieval tools cover clinical trial search, drug labels, molecule–trial connectivity, adverse events, outcomes, Orange Book, cross-database lookup, biotherapeutic sequence search, and target/drug pharmacology; agent tools wrap these with LLM-friendly formatting. Full reference: docs/tools.md.
For pipeline order and script roles, see docs/INGESTION.md.
This is the fastest reproducible path on a single local Postgres instance/port (5432).
cp .env.example .env
pip install -e .
.env for your local Postgres user:DATA_POSTGRES_URI=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_data
APP_DATABASE_URL=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_app
DATABASE_URL=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_app
POSTGRES_URI=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_app
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=replace_with_long_random_secret
BIOAGENT_BACKEND_URL=http://localhost:8000
make verify-deps
make setup-postgres
make ingest-quick
make users-setup
make users-list
make gui-stack-up
http://localhost:3000/logincredentials.txtmake chat-stack
For a lightweight prototype dataset (fastest path), run:
biomedagent-db ingest --quick-prototype
This profile ingests OpenFDA + Orange Book only, skips heavy sources (CT.gov, DailyMed, BindingDB, ChEMBL, DrugCentral, dm_target, dm_molecule), and applies defaults:
--openfda-files 2--n-max 2000You can still override these limits explicitly.
Common commands:
make install
make verify-deps
make setup-postgres
make ingest
make ingest-quick
make aegra-dev
make aegra-serve
make chat
make chat-stack
make gui-stack
make web-install
make web-dev
make web-check
make users-setup
make users-list
Run make help to list all targets.
Two-DB layout:
coscientist_data (5432): scientific source tables used by tools/ingestioncoscientist_app (5432): app_users + Aegra checkpoint/store dataUse your existing local PostgreSQL service (same instance/port, separate databases). Ensure Postgres is running before setup:
sudo systemctl start postgresqlbrew services start postgresqlInitialize and seed users:
make users-setup
make users-list
Additional user commands:
make users-db
make users-add [email protected] NAME="Dr. New" ROLE=user
make users-reset-pw [email protected]
make users-deactivate [email protected]
make users-activate [email protected]
make users-remove [email protected]
Generated credentials are written to credentials.txt (gitignored). Share securely and delete after use.
This project uses two databases on the same Postgres instance/port (for example 5432), configured via env vars:
Example:
APP_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
POSTGRES_URI=postgresql://postgres:postgres@localhost:5432/coscientist_app
Full guide: docs/CHAT_INTERFACE.md
You can run the Aegra server and CLI chat together with one script:
./scripts/run_aegra_and_chat.sh
This script:
./scripts/run_aegra.sh in the project root/v1/ok (or /ok) readinessbiomedagent-db chatServer logs are written to .aegra/server.log by default.
export BIOAGENT_API_TOKEN=dev-token
export BIOAGENT_API_USER_ID=1
export BIOAGENT_AUTH_REQUIRED=true
./scripts/run_aegra_and_chat.sh --api-token "$BIOAGENT_API_TOKEN"
./scripts/run_aegra_and_chat.sh --help
./scripts/run_aegra_and_chat.sh --assistant-id co_scientist
./scripts/run_aegra_and_chat.sh --server-url http://localhost:8000
./scripts/run_aegra_and_chat.sh --api-token dev-token -- --stream-tool-args
Terminal 1:
./scripts/run_aegra.sh
Terminal 2:
biomedagent-db chat --server-url http://localhost:8000 --assistant-id co_scientist --api-token dev-token
Full web details: web/README.md
make gui-stack
This starts Aegra, waits for backend health, then runs the Next.js app.
Terminal 1:
make aegra-dev
Terminal 2:
cd web
npm install
npm run dev
Then open:
http://localhost:3000/loginRequired env for GUI auth/backend wiring (in .env):
APP_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
POSTGRES_URI=postgresql://postgres:postgres@localhost:5432/coscientist_app
AEGRA_POSTGRES_URI=postgresql://postgres:postgres@localhost:5432/coscientist_app
AEGRA_REDIS_URL=redis://localhost:6379/0
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=replace_with_long_random_secret
BIOAGENT_BACKEND_URL=http://localhost:8000
Reports are persisted in PostgreSQL (bioagent_reports table), scoped by user/thread.
Aegra uses Postgres-backed runtime persistence for /threads when AEGRA_POSTGRES_URI is configured.
Seed login users first:
make users-setup
make users-list
Backend deployment now targets Aegra. Configure Railway service env vars:
AEGRA_POSTGRES_URI=postgresql://[email protected]:5432/...
AEGRA_REDIS_URL=redis://[email protected]:6379
AEGRA_CONFIG_PATH=/app/langgraph.json
Detailed guide: docs/AEGRA_RAILWAY.md
Missing DATABASE_URL (or APP_DATABASE_URL) for NextAuth:
Set DATABASE_URL in shell or web/.env.local when running cd web && npm run dev.
SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string:
DATABASE_URL is malformed or missing password. Use postgresql://user:password@host:port/dbname.
password authentication failed for user ...:
APP_DATABASE_URL/DATABASE_URL credentials do not match your Postgres server.
permission denied to create database during make users-setup:
The current DB role lacks CREATEDB; either set APP_DATABASE_ADMIN_URL or use sudo/admin once.
permission denied for schema public during make users-setup:
Grant schema privileges once using admin user; manage_users.py can auto-fix via APP_DATABASE_ADMIN_URL or sudo fallback.
Biomedical Agent - a variation of a deep researched with openFDA, DailyMed, ClinicalTrialsGov access
Python
0
94 commits
updated Mar 22, 2026
Biomedical research agent that integrates OpenFDA, DailyMed, ClinicalTrials.gov, ChEMBL, BindingDB, DrugCentral, Orange Book and related sources into a unified PostgreSQL database, with LLM-friendly search tools and a chat interface.
Prerequisites: PostgreSQL 14+, Python 3.12+, ~50 GB disk, 8+ GB RAM for full ingestion.
sudo apt-get install postgresql postgresql-contribbrew install postgresqlcp .env.example .env
pip install -e .
biomedagent-db verify-deps
biomedagent-db setup_postgres
biomedagent-db ingest
Data available. The database unifies clinical trials (ClinicalTrials.gov), molecular structures and biotherapeutics (ChEMBL, DrugCentral, BindingDB), biological targets, drug labels (OpenFDA, DailyMed), and regulatory data (Orange Book), with mappings from trials and products to molecules. Full schema: docs/DATABASE_SCHEMA.md.
Tools available. Retrieval tools cover clinical trial search, drug labels, molecule–trial connectivity, adverse events, outcomes, Orange Book, cross-database lookup, biotherapeutic sequence search, and target/drug pharmacology; agent tools wrap these with LLM-friendly formatting. Full reference: docs/tools.md.
For pipeline order and script roles, see docs/INGESTION.md.
This is the fastest reproducible path on a single local Postgres instance/port (5432).
cp .env.example .env
pip install -e .
.env for your local Postgres user:DATA_POSTGRES_URI=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_data
APP_DATABASE_URL=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_app
DATABASE_URL=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_app
POSTGRES_URI=postgresql://<your_db_user>:<your_db_password>@localhost:5432/coscientist_app
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=replace_with_long_random_secret
BIOAGENT_BACKEND_URL=http://localhost:8000
make verify-deps
make setup-postgres
make ingest-quick
make users-setup
make users-list
make gui-stack-up
http://localhost:3000/logincredentials.txtmake chat-stack
For a lightweight prototype dataset (fastest path), run:
biomedagent-db ingest --quick-prototype
This profile ingests OpenFDA + Orange Book only, skips heavy sources (CT.gov, DailyMed, BindingDB, ChEMBL, DrugCentral, dm_target, dm_molecule), and applies defaults:
--openfda-files 2--n-max 2000You can still override these limits explicitly.
Common commands:
make install
make verify-deps
make setup-postgres
make ingest
make ingest-quick
make aegra-dev
make aegra-serve
make chat
make chat-stack
make gui-stack
make web-install
make web-dev
make web-check
make users-setup
make users-list
Run make help to list all targets.
Two-DB layout:
coscientist_data (5432): scientific source tables used by tools/ingestioncoscientist_app (5432): app_users + Aegra checkpoint/store dataUse your existing local PostgreSQL service (same instance/port, separate databases). Ensure Postgres is running before setup:
sudo systemctl start postgresqlbrew services start postgresqlInitialize and seed users:
make users-setup
make users-list
Additional user commands:
make users-db
make users-add [email protected] NAME="Dr. New" ROLE=user
make users-reset-pw [email protected]
make users-deactivate [email protected]
make users-activate [email protected]
make users-remove [email protected]
Generated credentials are written to credentials.txt (gitignored). Share securely and delete after use.
This project uses two databases on the same Postgres instance/port (for example 5432), configured via env vars:
Example:
APP_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
POSTGRES_URI=postgresql://postgres:postgres@localhost:5432/coscientist_app
Full guide: docs/CHAT_INTERFACE.md
You can run the Aegra server and CLI chat together with one script:
./scripts/run_aegra_and_chat.sh
This script:
./scripts/run_aegra.sh in the project root/v1/ok (or /ok) readinessbiomedagent-db chatServer logs are written to .aegra/server.log by default.
export BIOAGENT_API_TOKEN=dev-token
export BIOAGENT_API_USER_ID=1
export BIOAGENT_AUTH_REQUIRED=true
./scripts/run_aegra_and_chat.sh --api-token "$BIOAGENT_API_TOKEN"
./scripts/run_aegra_and_chat.sh --help
./scripts/run_aegra_and_chat.sh --assistant-id co_scientist
./scripts/run_aegra_and_chat.sh --server-url http://localhost:8000
./scripts/run_aegra_and_chat.sh --api-token dev-token -- --stream-tool-args
Terminal 1:
./scripts/run_aegra.sh
Terminal 2:
biomedagent-db chat --server-url http://localhost:8000 --assistant-id co_scientist --api-token dev-token
Full web details: web/README.md
make gui-stack
This starts Aegra, waits for backend health, then runs the Next.js app.
Terminal 1:
make aegra-dev
Terminal 2:
cd web
npm install
npm run dev
Then open:
http://localhost:3000/loginRequired env for GUI auth/backend wiring (in .env):
APP_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coscientist_app
POSTGRES_URI=postgresql://postgres:postgres@localhost:5432/coscientist_app
AEGRA_POSTGRES_URI=postgresql://postgres:postgres@localhost:5432/coscientist_app
AEGRA_REDIS_URL=redis://localhost:6379/0
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=replace_with_long_random_secret
BIOAGENT_BACKEND_URL=http://localhost:8000
Reports are persisted in PostgreSQL (bioagent_reports table), scoped by user/thread.
Aegra uses Postgres-backed runtime persistence for /threads when AEGRA_POSTGRES_URI is configured.
Seed login users first:
make users-setup
make users-list
Backend deployment now targets Aegra. Configure Railway service env vars:
AEGRA_POSTGRES_URI=postgresql://[email protected]:5432/...
AEGRA_REDIS_URL=redis://[email protected]:6379
AEGRA_CONFIG_PATH=/app/langgraph.json
Detailed guide: docs/AEGRA_RAILWAY.md
Missing DATABASE_URL (or APP_DATABASE_URL) for NextAuth:
Set DATABASE_URL in shell or web/.env.local when running cd web && npm run dev.
SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string:
DATABASE_URL is malformed or missing password. Use postgresql://user:password@host:port/dbname.
password authentication failed for user ...:
APP_DATABASE_URL/DATABASE_URL credentials do not match your Postgres server.
permission denied to create database during make users-setup:
The current DB role lacks CREATEDB; either set APP_DATABASE_ADMIN_URL or use sudo/admin once.
permission denied for schema public during make users-setup:
Grant schema privileges once using admin user; manage_users.py can auto-fix via APP_DATABASE_ADMIN_URL or sudo fallback.