Agentic RAG backend for CloudNerd (Stack Overflow) and DietNerd (PubMed).
Same pipeline for both — switch with AGENT_DOMAIN.
This repo is the agent layer only. It reuses retrieval / relevance / synthesis from a sibling CustomNerd linear backend (customnerd-backend/).
your-workspace/
├── agentic-customnerd/ # this repo (or rename to cloudnerd-agent-backend)
└── customnerd-backend/ # linear CustomNerd backend (clone separately)
└── saved_states/
├── CloudNerd/
└── DietNerd/
config.py resolves the legacy root as ../customnerd-backend next to this folder.
- Clone / place the linear backend as a sibling folder named
customnerd-backend. - Ensure domain packs exist under
customnerd-backend/saved_states/CloudNerdandDietNerd(prompts + search APIs). - Put API keys in
customnerd-backend/variables.env(or copyvariables.env.template→variables.envhere for agent overrides). - Prefer reusing the linear backend venv (it already has BioPython, OpenAI, etc.).
| Domain | Retrieval | Notes |
|---|---|---|
CloudNerd |
SO cascade (RETRIEVAL_MODE=cascade) |
Needs STACK_API_KEY |
DietNerd |
PubMed Entrez (RETRIEVAL_MODE=legacy) |
Needs ENTREZ_EMAIL (+ NCBI_API_KEY) |
On boot (and via POST /agent/load_domain), the agent copies
customnerd-backend/saved_states/<DOMAIN>/ into the live backend and reloads prompts / search.
# DietNerd
AGENT_DOMAIN=DietNerd
RETRIEVAL_MODE=legacy
# CloudNerd
AGENT_DOMAIN=CloudNerd
RETRIEVAL_MODE=cascadeHot-switch: POST /agent/load_domain with form field domain=DietNerd.
| Mode | Behavior |
|---|---|
hybrid (default) |
Enhanced pipeline + optional rescue pass |
parity |
Enhanced pipeline, no rescue |
adaptive |
ReAct or LangGraph (USE_LANGGRAPH=true) |
search → organize → classify → assess
→ (optional re-search)
→ pre-verify faith → synthesize → claim filter → post-verify
→ (optional hybrid rescue) → answer + citations
# From parent workspace that also contains customnerd-backend/
cd agentic-customnerd
copy variables.env.template variables.env
# edit AGENT_DOMAIN / keys as needed
..\customnerd-backend\venv\Scripts\python.exe -m uvicorn main:app --host 127.0.0.1 --port 8001Health: GET http://127.0.0.1:8001/health
cd ..\customnerd-backend
.\venv\Scripts\python.exe eval_rag.py --csv path\to\input.csv `
--api-url http://127.0.0.1:8001 --output ..\result\agent_eval --agent-trace| Variable | Default | Description |
|---|---|---|
AGENT_DOMAIN |
CloudNerd / DietNerd |
Domain pack to activate |
AGENT_MODE |
hybrid |
hybrid, parity, or adaptive |
AGENT_FAST_ORGANIZE |
true |
Fast article map (0 LLM per paper for Diet/SO) |
AGENT_PREFER_COMBINED_SYNTHESIS |
true |
Grounded combined_lite answers |
AGENT_FAITH_FIRST |
true |
Faithfulness-oriented verify / regen |
HYBRID_RESCUE_ENABLED |
true |
Rescue pass in hybrid mode |
RETRIEVAL_MODE |
legacy / cascade |
Diet vs Cloud retrieval |
Do not commit variables.env (secrets). Use variables.env.template only.