Installation
RAG Doctor is available on npm as rag-doctor. You can install it globally, use it with npx, or add it as a development dependency in your project.
Requirements
- Node.js 18 or higher
- npm, pnpm, or yarn
Global install
Install RAG Doctor globally to use the rag-doctor command anywhere on your system:
bash
# npmnpm install -g rag-doctor # pnpmpnpm add -g rag-doctor # yarnyarn global add rag-doctorProject dependency
Add RAG Doctor as a dev dependency to use it in CI pipelines or project scripts:
bash
# npmnpm install --save-dev rag-doctor # pnpmpnpm add -D rag-doctor # yarnyarn add -D rag-doctorNo install (npx)
Run RAG Doctor without installing using npx:
bash
npx rag-doctor analyze ./traces/session.jsonnpx caching
npx will cache the downloaded package after the first run. Subsequent runs will be fast. To force the latest version, use
npx rag-doctor@latest.Quick start
Once installed, verify the installation and run your first analysis:
bash
# Verify installationrag-doctor --version # Show helprag-doctor --help # Analyze a trace filerag-doctor analyze ./traces/session.json # Get structured JSON outputrag-doctor analyze ./traces/session.json --jsonTrace file format
RAG Doctor expects a JSON trace file describing a RAG execution. At minimum, it must contain a query and an array of retrieved chunks:
trace.json
1{2 "query": "What are the side effects of ibuprofen?",3 "chunks": [4 {5 "id": "chunk-001",6 "content": "Ibuprofen is a nonsteroidal anti-inflammatory drug (NSAID)...",7 "score": 0.91,8 "tokens": 312,9 "source": "medical-db/ibuprofen-overview.txt"10 },11 {12 "id": "chunk-002",13 "content": "Common side effects include stomach upset, heartburn...",14 "score": 0.87,15 "tokens": 198,16 "source": "medical-db/ibuprofen-side-effects.txt"17 }18 ],19 "model": "gpt-4o",20 "totalTokens": 51021}Adapters
RAG Doctor can accept trace data from LangChain callbacks, LlamaIndex event hooks, and custom instrumentation. See the architecture docs for details on the ingestion layer.