{"id":50831361,"url":"https://github.com/langchain-samples/document-rag-multi-agent","last_synced_at":"2026-06-13T23:30:33.459Z","repository":{"id":357655727,"uuid":"1223930750","full_name":"langchain-samples/document-rag-multi-agent","owner":"langchain-samples","description":"Sample document rag and summarizer agent","archived":false,"fork":false,"pushed_at":"2026-05-13T17:35:59.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-13T19:27:09.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/langchain-samples.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-28T19:48:52.000Z","updated_at":"2026-05-13T14:24:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/langchain-samples/document-rag-multi-agent","commit_stats":null,"previous_names":["langchain-samples/document-rag-multi-agent"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/langchain-samples/document-rag-multi-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fdocument-rag-multi-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fdocument-rag-multi-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fdocument-rag-multi-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fdocument-rag-multi-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/langchain-samples","download_url":"https://codeload.github.com/langchain-samples/document-rag-multi-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-samples%2Fdocument-rag-multi-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34304627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-13T23:30:31.583Z","updated_at":"2026-06-13T23:30:33.453Z","avatar_url":"https://github.com/langchain-samples.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Document RAG Analysis\n\nA multi-agent RAG system that extracts information from documents, generates summaries, and fact-checks the output against the source material. Built with the Deep Agents framework.\n\n## Architecture\n\n```text\ndocument-rag-analysis/\n├── agents/\n│   ├── extractor.py      — analyze_document tool (index, retrieve, deduplicate, summarize)\n│   ├── fact_checker.py   — verify_claims tool (cross-checks summary against source chunks)\n│   └── orchestrator.py   — Deep Agent wiring\n├── main.py               — CLI entry point\n├── requirements.txt\n└── .env.example\n```\n\n| Agent | Role | Model |\n| --- | --- | --- |\n| Orchestrator | Calls `analyze_document` directly, then delegates to `fact-checker` subagent | `claude-sonnet-4-6` |\n| `fact-checker` subagent | Verifies each claim in the summary against retrieved source passages | `claude-haiku-4-5-20251001` |\n\n### Pipeline\n\n```text\nDocument path\n    │\n    ▼\nanalyze_document (extractor.py)\n    ├── Index once → Chroma (cached across runs)\n    ├── 2 broad similarity searches\n    ├── Deduplicate chunks (Jaccard)\n    └── Summarize in one LLM call\n    │\n    ▼\nverify_claims (fact_checker.py)\n    ├── Re-retrieve same chunks from Chroma\n    └── Per-claim verdict: ✅ Supported / ⚠️ Partially / ❌ Not Found\n    │\n    ▼\nSummary + Fact-check report\n```\n\nOpenAI is used only for embeddings (`text-embedding-3-small`). All agent reasoning uses Claude. Vectorstore operations are excluded from LangSmith traces to stay under the 20 MB payload limit; LLM calls are fully traced.\n\n## Setup\n\n```bash\npip install -r requirements.txt\ncp .env.example .env   # fill in ANTHROPIC_API_KEY + OPENAI_API_KEY\n```\n\n## Usage\n\n```bash\n# Executive summary + fact-check (default)\npython main.py ./docs/report.pdf\n\n# Bullet summary with a custom extraction query\npython main.py ./docs/ --query \"What are the risk factors?\" --summary-type bullet\n\n# Detailed summary of a specific file\npython main.py ./docs/paper.pdf --summary-type detailed\n```\n\n### Options\n\n| Flag | Default | Description |\n| --- | --- | --- |\n| `document_path` | required | Path to a PDF, `.txt` file, or directory of documents |\n| `--query` | `\"Extract all key information...\"` | What to extract from the documents |\n| `--summary-type` | `executive` | `executive`, `detailed`, or `bullet` |\n| `--thread-id` | auto-generated | Session ID for conversation continuity |\n\n## Test Documents\n\nA download script is included to fetch a few public arXiv papers into `./docs/`:\n\n```bash\npython download_test_docs.py\n```\n\n| File | Paper |\n| --- | --- |\n| `attention_is_all_you_need.pdf` | Attention Is All You Need (Transformer) |\n| `bert.pdf` | BERT: Pre-training of Deep Bidirectional Transformers |\n| `gpt3.pdf` | Language Models are Few-Shot Learners (GPT-3) |\n| `llama.pdf` | LLaMA: Open and Efficient Foundation Language Models |\n\n```bash\n# Summarize a single paper\npython main.py ./docs/attention_is_all_you_need.pdf --summary-type detailed\n\n# Query across all four papers at once\npython main.py ./docs/ --query \"What architecture or training techniques are proposed?\" --summary-type bullet\n```\n\n## Environment Variables\n\nCopy `.env.example` to `.env` and fill in your keys. The `.env` file is gitignored and will never be committed.\n\n```bash\nANTHROPIC_API_KEY=your-anthropic-key\nOPENAI_API_KEY=your-openai-key\n\n# LangSmith tracing (optional)\nLANGSMITH_TRACING=true\nLANGSMITH_API_KEY=your-langsmith-key\nLANGSMITH_PROJECT=document-rag-analysis\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-samples%2Fdocument-rag-multi-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flangchain-samples%2Fdocument-rag-multi-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-samples%2Fdocument-rag-multi-agent/lists"}