agentic-graphrag 0.0.1__tar.gz → 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. agentic_graphrag-0.0.2/PKG-INFO +393 -0
  2. agentic_graphrag-0.0.2/README.md +337 -0
  3. agentic_graphrag-0.0.2/agrag/agents/__init__.py +1 -0
  4. agentic_graphrag-0.0.2/agrag/agents/build.py +169 -0
  5. agentic_graphrag-0.0.2/agrag/agents/ledger.py +92 -0
  6. agentic_graphrag-0.0.2/agrag/agents/middleware.py +55 -0
  7. agentic_graphrag-0.0.2/agrag/agents/model.py +125 -0
  8. agentic_graphrag-0.0.2/agrag/agents/prompts.py +28 -0
  9. agentic_graphrag-0.0.2/agrag/agents/settings.py +97 -0
  10. agentic_graphrag-0.0.2/agrag/agents/subagents.py +36 -0
  11. agentic_graphrag-0.0.2/agrag/agents/tools.py +94 -0
  12. agentic_graphrag-0.0.2/agrag/chunking/__init__.py +24 -0
  13. agentic_graphrag-0.0.2/agrag/chunking/text.py +120 -0
  14. agentic_graphrag-0.0.2/agrag/common/data_models/chunk.py +114 -0
  15. agentic_graphrag-0.0.2/agrag/common/data_models/data_point.py +23 -0
  16. agentic_graphrag-0.0.2/agrag/common/data_models/document.py +209 -0
  17. agentic_graphrag-0.0.2/agrag/common/data_models/entity.py +88 -0
  18. agentic_graphrag-0.0.2/agrag/common/data_models/extraction.py +103 -0
  19. agentic_graphrag-0.0.2/agrag/common/data_models/graph_record.py +48 -0
  20. agentic_graphrag-0.0.2/agrag/common/data_models/graph_schema.py +94 -0
  21. agentic_graphrag-0.0.2/agrag/common/data_models/provenance.py +72 -0
  22. agentic_graphrag-0.0.2/agrag/common/data_models/relation.py +44 -0
  23. agentic_graphrag-0.0.2/agrag/common/data_models/search_result.py +42 -0
  24. agentic_graphrag-0.0.2/agrag/common/data_models/vector_record.py +59 -0
  25. agentic_graphrag-0.0.2/agrag/common/text.py +13 -0
  26. agentic_graphrag-0.0.2/agrag/common/validation.py +133 -0
  27. agentic_graphrag-0.0.2/agrag/cypher/__init__.py +5 -0
  28. agentic_graphrag-0.0.2/agrag/cypher/entities.py +467 -0
  29. agentic_graphrag-0.0.2/agrag/cypher/merge.py +167 -0
  30. agentic_graphrag-0.0.2/agrag/cypher/relations.py +170 -0
  31. agentic_graphrag-0.0.2/agrag/cypher/safety.py +141 -0
  32. agentic_graphrag-0.0.2/agrag/cypher/schema.py +200 -0
  33. agentic_graphrag-0.0.2/agrag/embedding/__init__.py +35 -0
  34. agentic_graphrag-0.0.2/agrag/embedding/base.py +96 -0
  35. agentic_graphrag-0.0.2/agrag/embedding/errors.py +35 -0
  36. agentic_graphrag-0.0.2/agrag/embedding/fastembed_bm25.py +140 -0
  37. agentic_graphrag-0.0.2/agrag/embedding/sentence_transformers.py +154 -0
  38. agentic_graphrag-0.0.2/agrag/embedding/settings.py +32 -0
  39. agentic_graphrag-0.0.2/agrag/embedding/sparse_base.py +53 -0
  40. agentic_graphrag-0.0.2/agrag/graphdb/__init__.py +45 -0
  41. agentic_graphrag-0.0.2/agrag/graphdb/base.py +260 -0
  42. agentic_graphrag-0.0.2/agrag/graphdb/errors.py +77 -0
  43. agentic_graphrag-0.0.2/agrag/graphdb/neo4j.py +618 -0
  44. agentic_graphrag-0.0.2/agrag/graphdb/serialize.py +58 -0
  45. agentic_graphrag-0.0.2/agrag/graphdb/settings.py +52 -0
  46. agentic_graphrag-0.0.2/agrag/ingestion/__init__.py +6 -0
  47. agentic_graphrag-0.0.2/agrag/ingestion/extract.py +776 -0
  48. agentic_graphrag-0.0.2/agrag/ingestion/graph.py +1722 -0
  49. agentic_graphrag-0.0.2/agrag/ingestion/merge.py +834 -0
  50. agentic_graphrag-0.0.2/agrag/ingestion/resolve.py +323 -0
  51. agentic_graphrag-0.0.2/agrag/ingestion/types.py +187 -0
  52. agentic_graphrag-0.0.2/agrag/llm/baml_client/__init__.py +60 -0
  53. agentic_graphrag-0.0.2/agrag/llm/baml_client/async_client.py +235 -0
  54. agentic_graphrag-0.0.2/agrag/llm/baml_client/config.py +102 -0
  55. agentic_graphrag-0.0.2/agrag/llm/baml_client/globals.py +35 -0
  56. agentic_graphrag-0.0.2/agrag/llm/baml_client/inlinedbaml.py +22 -0
  57. agentic_graphrag-0.0.2/agrag/llm/baml_client/parser.py +70 -0
  58. agentic_graphrag-0.0.2/agrag/llm/baml_client/runtime.py +361 -0
  59. agentic_graphrag-0.0.2/agrag/llm/baml_client/stream_types.py +59 -0
  60. agentic_graphrag-0.0.2/agrag/llm/baml_client/sync_client.py +244 -0
  61. agentic_graphrag-0.0.2/agrag/llm/baml_client/tracing.py +22 -0
  62. agentic_graphrag-0.0.2/agrag/llm/baml_client/type_builder.py +307 -0
  63. agentic_graphrag-0.0.2/agrag/llm/baml_client/type_map.py +33 -0
  64. agentic_graphrag-0.0.2/agrag/llm/baml_client/types.py +83 -0
  65. agentic_graphrag-0.0.2/agrag/llm/baml_client/watchers.py +44 -0
  66. agentic_graphrag-0.0.2/agrag/llm/baml_src/extraction.baml +64 -0
  67. agentic_graphrag-0.0.2/agrag/llm/baml_src/generators.baml +6 -0
  68. agentic_graphrag-0.0.2/agrag/llm/baml_src/resolution.baml +37 -0
  69. agentic_graphrag-0.0.2/agrag/llm/baml_src/retrieval.baml +14 -0
  70. agentic_graphrag-0.0.2/agrag/llm/client_config.py +57 -0
  71. agentic_graphrag-0.0.2/agrag/llm/client_registry.py +69 -0
  72. agentic_graphrag-0.0.2/agrag/llm/retry.py +73 -0
  73. agentic_graphrag-0.0.2/agrag/loaders/corpus/__init__.py +39 -0
  74. agentic_graphrag-0.0.2/agrag/loaders/corpus/_walk.py +259 -0
  75. agentic_graphrag-0.0.2/agrag/loaders/corpus/base.py +79 -0
  76. agentic_graphrag-0.0.2/agrag/loaders/corpus/decode.py +83 -0
  77. agentic_graphrag-0.0.2/agrag/loaders/corpus/errors.py +59 -0
  78. agentic_graphrag-0.0.2/agrag/loaders/corpus/readers/_common.py +278 -0
  79. agentic_graphrag-0.0.2/agrag/loaders/corpus/readers/html.py +64 -0
  80. agentic_graphrag-0.0.2/agrag/loaders/corpus/readers/prose.py +220 -0
  81. agentic_graphrag-0.0.2/agrag/loaders/corpus/readers/records.py +303 -0
  82. agentic_graphrag-0.0.2/agrag/loaders/corpus/registry.py +104 -0
  83. agentic_graphrag-0.0.2/agrag/loaders/corpus/types.py +189 -0
  84. agentic_graphrag-0.0.2/agrag/loaders/docling/__init__.py +34 -0
  85. agentic_graphrag-0.0.2/agrag/loaders/docling/chunking.py +124 -0
  86. agentic_graphrag-0.0.2/agrag/loaders/docling/loader.py +139 -0
  87. agentic_graphrag-0.0.2/agrag/observability.py +98 -0
  88. agentic_graphrag-0.0.2/agrag/retrieval/__init__.py +1 -0
  89. agentic_graphrag-0.0.2/agrag/retrieval/errors.py +53 -0
  90. agentic_graphrag-0.0.2/agrag/retrieval/filters.py +101 -0
  91. agentic_graphrag-0.0.2/agrag/retrieval/fusion.py +73 -0
  92. agentic_graphrag-0.0.2/agrag/retrieval/identity.py +81 -0
  93. agentic_graphrag-0.0.2/agrag/retrieval/methods/__init__.py +1 -0
  94. agentic_graphrag-0.0.2/agrag/retrieval/methods/vector.py +92 -0
  95. agentic_graphrag-0.0.2/agrag/retrieval/recipes.py +40 -0
  96. agentic_graphrag-0.0.2/agrag/retrieval/rerank/__init__.py +1 -0
  97. agentic_graphrag-0.0.2/agrag/retrieval/rerank/cross_encoder.py +74 -0
  98. agentic_graphrag-0.0.2/agrag/retrieval/rerank/node_distance.py +67 -0
  99. agentic_graphrag-0.0.2/agrag/retrieval/retrievers/__init__.py +1 -0
  100. agentic_graphrag-0.0.2/agrag/retrieval/retrievers/base.py +27 -0
  101. agentic_graphrag-0.0.2/agrag/retrieval/retrievers/bfs.py +115 -0
  102. agentic_graphrag-0.0.2/agrag/retrieval/retrievers/chunk.py +169 -0
  103. agentic_graphrag-0.0.2/agrag/retrieval/retrievers/entity.py +104 -0
  104. agentic_graphrag-0.0.2/agrag/retrieval/retrievers/text2cypher.py +451 -0
  105. agentic_graphrag-0.0.2/agrag/retrieval/search_engine.py +294 -0
  106. agentic_graphrag-0.0.2/agrag/retrieval/settings.py +65 -0
  107. agentic_graphrag-0.0.2/agrag/vectordb/__init__.py +69 -0
  108. agentic_graphrag-0.0.2/agrag/vectordb/base.py +252 -0
  109. agentic_graphrag-0.0.2/agrag/vectordb/errors.py +44 -0
  110. agentic_graphrag-0.0.2/agrag/vectordb/milvus.py +759 -0
  111. agentic_graphrag-0.0.2/agrag/vectordb/qdrant.py +747 -0
  112. agentic_graphrag-0.0.2/agrag/vectordb/settings.py +133 -0
  113. agentic_graphrag-0.0.2/agrag/vectordb/weaviate.py +550 -0
  114. {agentic_graphrag-0.0.1 → agentic_graphrag-0.0.2}/pyproject.toml +67 -3
  115. {agentic_graphrag-0.0.1 → agentic_graphrag-0.0.2}/pyproject.toml.orig +66 -4
  116. agentic_graphrag-0.0.1/PKG-INFO +0 -54
  117. agentic_graphrag-0.0.1/README.md +0 -35
  118. {agentic_graphrag-0.0.1 → agentic_graphrag-0.0.2}/LICENSE +0 -0
  119. {agentic_graphrag-0.0.1 → agentic_graphrag-0.0.2}/agrag/__init__.py +0 -0
  120. {agentic_graphrag-0.0.1 → agentic_graphrag-0.0.2}/agrag/py.typed +0 -0
@@ -0,0 +1,393 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentic-graphrag
3
+ Version: 0.0.2
4
+ Summary: Agentic GraphRAG: graph-based retrieval-augmented generation with agentic reasoning.
5
+ Keywords: graphrag,rag,knowledge-graph,agents,retrieval
6
+ Author: Ashwin Mathur, Varun Mathur
7
+ Author-email: Ashwin Mathur <ashwinm400@gmail.com>, Varun Mathur <varunm500@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
12
+ Requires-Dist: pydantic>=2.0
13
+ Requires-Dist: pydantic-settings>=2.0
14
+ Requires-Dist: python-dotenv>=1.0
15
+ Requires-Dist: chonkie>=1.7
16
+ Requires-Dist: opentelemetry-api>=1.20
17
+ Requires-Dist: charset-normalizer>=3.4
18
+ Requires-Dist: markdown-it-py>=3.0
19
+ Requires-Dist: selectolax>=0.3.21
20
+ Requires-Dist: rapidfuzz>=3.0
21
+ Requires-Dist: langgraph>=1.2 ; extra == 'agents'
22
+ Requires-Dist: deepagents>=0.7 ; extra == 'agents'
23
+ Requires-Dist: langchain-openai>=1.0 ; extra == 'agents'
24
+ Requires-Dist: docling>=2.0 ; extra == 'docling'
25
+ Requires-Dist: sentence-transformers>=5 ; extra == 'embed-local'
26
+ Requires-Dist: gliner2[local] ; extra == 'extract'
27
+ Requires-Dist: transformers<4.56 ; extra == 'extract'
28
+ Requires-Dist: protobuf ; extra == 'extract'
29
+ Requires-Dist: baml-py>=0.226.1,<0.227 ; extra == 'llm'
30
+ Requires-Dist: pymilvus>=2.5.3 ; extra == 'milvus'
31
+ Requires-Dist: neo4j>=5.0 ; extra == 'neo4j'
32
+ Requires-Dist: opentelemetry-sdk>=1.20 ; extra == 'observability'
33
+ Requires-Dist: opentelemetry-exporter-otlp>=1.20 ; extra == 'observability'
34
+ Requires-Dist: opentelemetry-instrumentation-asyncio ; extra == 'observability'
35
+ Requires-Dist: openinference-semantic-conventions ; extra == 'observability'
36
+ Requires-Dist: qdrant-client>=1.12 ; extra == 'qdrant'
37
+ Requires-Dist: fastembed>=0.4 ; extra == 'qdrant'
38
+ Requires-Dist: weaviate-client>=4.9 ; extra == 'weaviate'
39
+ Maintainer: Ashwin Mathur, Varun Mathur
40
+ Maintainer-email: Ashwin Mathur <ashwinm400@gmail.com>, Varun Mathur <varunm500@gmail.com>
41
+ Requires-Python: >=3.11
42
+ Project-URL: Documentation, https://ontogr.github.io/agentic-graphrag/
43
+ Project-URL: Issues, https://github.com/ontogr/agentic-graphrag/issues
44
+ Project-URL: Source, https://github.com/ontogr/agentic-graphrag
45
+ Provides-Extra: agents
46
+ Provides-Extra: docling
47
+ Provides-Extra: embed-local
48
+ Provides-Extra: extract
49
+ Provides-Extra: llm
50
+ Provides-Extra: milvus
51
+ Provides-Extra: neo4j
52
+ Provides-Extra: observability
53
+ Provides-Extra: qdrant
54
+ Provides-Extra: weaviate
55
+ Description-Content-Type: text/markdown
56
+
57
+ <h1 align="center"><a href="https://github.com/ontogr/agentic-graphrag">Agentic GraphRAG</a></h1>
58
+
59
+ <div align="center">
60
+
61
+ [![DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ontogr/agentic-graphrag)
62
+ [![CI](https://img.shields.io/github/actions/workflow/status/ontogr/agentic-graphrag/ci.yml?branch=main&label=CI&logo=githubactions)](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
63
+ [![Ruff](https://img.shields.io/github/actions/workflow/status/ontogr/agentic-graphrag/ci.yml?branch=main&label=Ruff&logo=ruff)](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
64
+ [![ty](https://img.shields.io/github/actions/workflow/status/ontogr/agentic-graphrag/ci.yml?branch=main&label=ty&logo=python)](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
65
+ [![Unit tests](https://img.shields.io/github/actions/workflow/status/ontogr/agentic-graphrag/ci.yml?branch=main&label=unit%20tests&logo=pytest)](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
66
+ [![Integration tests](https://img.shields.io/github/actions/workflow/status/ontogr/agentic-graphrag/integration.yml?branch=main&label=integration%20tests&logo=pytest)](https://github.com/ontogr/agentic-graphrag/actions/workflows/integration.yml)
67
+ [![Codecov](https://codecov.io/gh/ontogr/agentic-graphrag/branch/main/graph/badge.svg)](https://codecov.io/gh/ontogr/agentic-graphrag)
68
+ [![PyPI](https://img.shields.io/pypi/v/agentic-graphrag.svg)](https://pypi.org/project/agentic-graphrag/)
69
+ [![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue?logo=readthedocs)](https://ontogr.github.io/agentic-graphrag/)
70
+ [![License](https://img.shields.io/github/license/ontogr/agentic-graphrag?color=green)](LICENSE)
71
+
72
+ </div>
73
+
74
+ Agentic GraphRAG is a modular, schema-driven system for building knowledge graphs from unstructured and structured data, retrieving evidence across graph and vector indexes, and answering questions with agentic reasoning.
75
+
76
+ <p align="center">
77
+ <img src="img/agentic_graphrag_pipeline.png" alt="Agentic GraphRAG pipeline from data loading through graph construction, storage, retrieval, and agentic reasoning" width="1200">
78
+ </p>
79
+
80
+ - **One ingestion API** for raw text, files, directories, globs, and prebuilt documents.
81
+ - **Structure-aware loading and chunking** with core text readers, Docling for rich documents, and Chonkie for text chunking.
82
+ - **Schema-driven extraction** with runtime-defined entity types, relation types, and valid graph patterns.
83
+ - **Local-first extraction cascade** using GLiNER 2.5 with type-safe BAML/LLM fallback for weak or ambiguous chunks.
84
+ - **Tiered entity resolution** combining exact, fuzzy, embedding, and LLM-verified matching with fail-safe merge rules.
85
+ - **Auditable graph merges** with field-level conflict handling, relation repointing, provenance union, and soft tombstones.
86
+ - **Pluggable storage** with Neo4j for graph data and native vectors, plus Qdrant, Weaviate, and Milvus/Zilliz for dedicated vector search.
87
+ - **Layered retrieval** across entities, relations, chunks, graph neighborhoods, and community reports, with hybrid fusion and reranking.
88
+ - **Agentic plan–research–verify loop** that decomposes questions, gathers evidence in parallel, checks coverage, and produces cited answers.
89
+ - **OpenTelemetry-native observability** across loading, chunking, extraction, resolution, and storage.
90
+
91
+ The system is built using:
92
+
93
+ - [**Docling**](https://github.com/docling-project/docling) and [**Chonkie**](https://github.com/chonkie-inc/chonkie) for document parsing and chunking.
94
+ - [**GLiNER 2.5**](https://github.com/urchade/GLiNER) for local schema-guided entity and relation extraction.
95
+ - [**BAML**](https://boundaryml.com/) for typed LLM functions and provider-independent client routing.
96
+ - [**Neo4j**](https://neo4j.com/) for the property graph and optional native vector search.
97
+ - [**Qdrant**](https://qdrant.tech/), [**Weaviate**](https://weaviate.io/), and [**Milvus**](https://milvus.io/) for dense and hybrid retrieval.
98
+ - [**Sentence Transformers**](https://www.sbert.net/) and [**FastEmbed**](https://github.com/qdrant/fastembed) for dense and sparse embeddings.
99
+ - [**OpenTelemetry**](https://opentelemetry.io/) for vendor-neutral traces and metrics.
100
+
101
+ ## Knowledge Graph
102
+
103
+ Agentic GraphRAG stores source material, extracted knowledge, and graph summaries in one typed property graph:
104
+
105
+ ```text
106
+ (:Document)<-[:PART_OF]-(:Chunk)-[:MENTIONS]->(:Entity:<Type>)
107
+ (:Chunk)-[:NEXT_CHUNK]->(:Chunk)
108
+ (:Entity)-[:<RELATION_TYPE>]->(:Entity)
109
+ (:Entity)-[:IN_COMMUNITY]->(:Community)
110
+ (:Community)-[:PARENT_COMMUNITY]->(:Community)
111
+ (:Community)-[:HAS_REPORT]->(:CommunityReport)
112
+ ```
113
+
114
+ ### Documents and chunks
115
+
116
+ Documents keep their source URI, format, loader, content hash, and record identity. Text formats use content-based identities; binary Docling formats use raw-byte hashes. Chunks keep stable document links and source provenance:
117
+
118
+ - Text chunks record character and line spans plus their heading path.
119
+ - Layout-aware chunks record page numbers and bounding boxes.
120
+ - Record formats such as CSV, TSV, JSON, and JSON Lines preserve row identity.
121
+
122
+ ### Entities and relations
123
+
124
+ Extraction produces mentions first, not graph nodes. Each mention keeps its source chunk, label, text span, confidence, and extractor provenance. Resolution then assigns canonical identities and merges aliases before storage.
125
+
126
+ Relations are directed subject–predicate–object triples. The active schema constrains valid source type, relation type, and target type combinations, so invalid triples are removed before they reach the graph.
127
+
128
+ ### Communities
129
+
130
+ Hierarchical community detection groups related entities and relations into nested topics. Each community can receive an LLM-generated report with a title, summary, findings, and importance score. Community reports provide broad context without forcing retrieval to return every low-level edge.
131
+
132
+ ### Runtime schemas
133
+
134
+ `GraphSchema` is a first-class runtime value. It defines:
135
+
136
+ - entity types and their descriptions;
137
+ - relation types and their descriptions;
138
+ - valid `(source, relation, target)` patterns;
139
+ - the vocabulary injected into local and LLM extractors.
140
+
141
+ Use the generic preset for open-domain data or provide a schema for a specific domain. The same schema guides extraction, validation, resolution, storage, and query generation.
142
+
143
+ ## Architecture
144
+
145
+ Agentic GraphRAG has two main data flows:
146
+
147
+ ```text
148
+ Ingestion: source -> document -> chunk -> mentions -> resolved graph -> indexes
149
+ Query: question -> plan -> parallel retrieval -> verify -> cited answer
150
+ ```
151
+
152
+ ## Ingestion Pipeline
153
+
154
+ `Graph.add()` is the single entry point for adding content. The complete pipeline is organized into these stages:
155
+
156
+ 1. **Load:** Select a loader by format, decode or parse the source, preserve source metadata, and apply `RAISE`, `SKIP`, or `QUARANTINE` per-source error handling.
157
+ 2. **Chunk:** Use Docling's layout-aware chunking before flattening rich documents; use Chonkie for text and record documents.
158
+ 3. **Extract:** Run GLiNER locally against the active schema. Escalate weak results to a typed BAML extraction function when configured.
159
+ 4. **Validate:** Drop entities and triples that do not conform to the schema.
160
+ 5. **Resolve:** Apply exact, fuzzy, embedding, and LLM-verified comparison tiers. Ambiguous or failed comparisons do not merge.
161
+ 6. **Merge:** Resolve properties field by field, combine provenance, deduplicate repointed relations, and retain an audit trail.
162
+ 7. **Store:** Upsert canonical nodes and relations, then populate graph-native or dedicated vector indexes.
163
+
164
+ The extraction cascade replaces a weak local result with the LLM result instead of combining two conflicting outputs. Exact matches use global store-backed lookup; more expensive fuzzy and LLM comparisons are blocked to a smaller candidate set.
165
+
166
+ `Graph.consolidate()` provides a separate whole-graph reconciliation pass for duplicates found across ingestion runs. It is dry-run by default so applications can inspect proposed merges before applying them.
167
+
168
+ ## Embeddings and Storage
169
+
170
+ The async `Embedder`, `GraphStore`, and `VectorStore` interfaces keep model and database choices outside graph-construction logic.
171
+
172
+ ### Embeddings
173
+
174
+ - Dense embeddings through Sentence Transformers.
175
+ - Sparse BM25 embeddings through FastEmbed.
176
+ - Batch-first async APIs with optional content-addressed caching by text and model.
177
+ - Dimension checks before collections or indexes accept vectors.
178
+
179
+ ### Graph storage
180
+
181
+ The Neo4j backend supports local Neo4j and Aura over Bolt, managed read/write transactions, node and relation upserts, constraints, indexes, and native dense vector search. Dynamic labels and relation types are validated before Cypher interpolation.
182
+
183
+ ### Vector storage
184
+
185
+ | Backend | Dense search | Hybrid search | Deployment |
186
+ | --- | --- | --- | --- |
187
+ | Neo4j | Yes | No | Local or Aura |
188
+ | Qdrant | Yes | Dense + sparse fusion | Local or Cloud |
189
+ | Weaviate | Yes | Native BM25/vector weighting | Custom or Cloud |
190
+ | Milvus / Zilliz | Yes | Dense + BM25 fusion | Local or Cloud |
191
+
192
+ All dedicated vector stores share collection lifecycle, batch upsert, retrieval, scrolling, counting, deletion, filtering, dense search, and hybrid search. Filters use exact scalar matches, OR within a list value, and AND across keys.
193
+
194
+ ## Retrieval Pipeline
195
+
196
+ Retrieval composes small search methods into retrievers, runs them concurrently, and fuses their results through data-only recipes.
197
+
198
+ - **Entity retrieval** finds canonical entities by dense or hybrid search and can expand matched seeds with bounded graph traversal.
199
+ - **Relation retrieval** searches relation representations and hydrates full subject–predicate–object edges from the graph.
200
+ - **Chunk retrieval** returns source passages with document and span provenance.
201
+ - **Community retrieval** searches community reports for thematic and corpus-wide questions.
202
+ - **Text-to-Cypher retrieval** generates a schema-aware, read-only query with bounded retries.
203
+ - **Graph traversal** uses bounded, degree-aware breadth-first search to collect connected evidence.
204
+
205
+ | Recipe | Search methods | Fusion |
206
+ | --- | --- | --- |
207
+ | `entity`, `relation`, `chunk`, `community` | One focused retriever | Reciprocal Rank Fusion |
208
+ | `hybrid_rrf` | Entity + relation + chunk + community | Reciprocal Rank Fusion |
209
+ | `hybrid_cross_encoder` | All semantic retrievers + graph expansion | Cross-encoder |
210
+ | `bfs_expand` | Entity seeds + bounded graph traversal | Reciprocal Rank Fusion |
211
+ | `text2cypher` | Schema-aware Cypher | Reciprocal Rank Fusion |
212
+
213
+ Reciprocal Rank Fusion, cross-encoder, maximal marginal relevance, and graph-distance rerankers cover different query needs. A recipe can ignore an empty search branch and still return evidence from the remaining methods.
214
+
215
+ ## Agentic RAG Loop
216
+
217
+ The agent coordinates three roles around the retrieval layer:
218
+
219
+ - **Planner:** decomposes a question into focused sub-questions and selects a retrieval recipe for each.
220
+ - **Researcher:** runs sub-questions in parallel across entity, relation, chunk, community, graph, and Cypher tools; every evidence item keeps its citation.
221
+ - **Verifier:** scores coverage and evidence depth, lists unsupported claims, and proposes targeted follow-up searches.
222
+
223
+ If the evidence gate fails, the missing items seed another research round. When the gate passes, or the iteration limit is reached, the orchestrator produces a structured answer with citations, confidence, caveats, and an answerability flag.
224
+
225
+ ## Structured LLM Output
226
+
227
+ BAML defines typed extraction, entity-comparison, community-summary, planning, verification, and answer contracts. Runtime client registries support a single provider, fallback chains, or round-robin routing across OpenAI, Anthropic, AWS Bedrock, Google AI, Vertex AI, Azure OpenAI, and OpenAI-compatible endpoints.
228
+
229
+ ## Observability and Failure Handling
230
+
231
+ OpenTelemetry API support is part of the core package; exporters and the SDK are optional. Applications can send traces to any OTLP-compatible backend.
232
+
233
+ Long-running graph builds report bounded, structured stage statistics for ingestion, extraction, resolution, merging, and storage. Failures include the affected item, error type, message, and trace/span IDs. Full detail remains in the trace backend so result objects stay bounded on large corpora.
234
+
235
+ ## Installation
236
+
237
+ Agentic GraphRAG requires Python 3.11 or newer.
238
+
239
+ ```bash
240
+ uv pip install agentic-graphrag
241
+ ```
242
+
243
+ Install only the integrations you use:
244
+
245
+ ```bash
246
+ # Rich documents and local extraction
247
+ uv pip install "agentic-graphrag[docling,extract]"
248
+
249
+ # LLM extraction and local dense embeddings
250
+ uv pip install "agentic-graphrag[llm,embed-local]"
251
+
252
+ # Neo4j with a dedicated Qdrant vector store and OTLP tracing
253
+ uv pip install "agentic-graphrag[neo4j,qdrant,observability]"
254
+ ```
255
+
256
+ | Extra | Adds |
257
+ | --- | --- |
258
+ | `docling` | PDF, DOCX, PPTX, image, XML, and layout-aware parsing |
259
+ | `extract` | Local GLiNER 2.5 extraction |
260
+ | `llm` | BAML-powered extraction and verification |
261
+ | `embed-local` | Sentence Transformers dense embeddings |
262
+ | `neo4j` | Neo4j graph storage and native vector search |
263
+ | `qdrant` | Qdrant dense and hybrid search |
264
+ | `weaviate` | Weaviate dense and hybrid search |
265
+ | `milvus` | Milvus/Zilliz dense and hybrid search |
266
+ | `observability` | OpenTelemetry SDK and OTLP export |
267
+
268
+ ## Usage
269
+
270
+ ### Ingest files and text
271
+
272
+ ```python
273
+ import asyncio
274
+
275
+ from agrag.ingestion import Graph
276
+
277
+
278
+ async def main() -> None:
279
+ graph = await Graph.open()
280
+
281
+ files = await graph.add(source="./corpus/**/*.md")
282
+ text = await graph.add(text="Agentic GraphRAG turns evidence into a graph.")
283
+
284
+ print(files.documents, len(files.chunks))
285
+ print(text.documents, len(text.chunks))
286
+
287
+
288
+ asyncio.run(main())
289
+ ```
290
+
291
+ `Graph.add()` accepts exactly one of:
292
+
293
+ - `source=` — a file, directory, glob, or list of paths;
294
+ - `text=` — raw text as one document;
295
+ - `documents=` — prebuilt `Document` objects.
296
+
297
+ ### Handle source failures
298
+
299
+ ```python
300
+ from agrag.loaders.corpus.types import ErrorPolicy
301
+
302
+ result = await graph.add(
303
+ source="./corpus",
304
+ error_policy=ErrorPolicy.QUARANTINE,
305
+ )
306
+
307
+ for uri, reason in result.quarantined_items:
308
+ print(uri, reason)
309
+ ```
310
+
311
+ See the [documentation](https://ontogr.github.io/agentic-graphrag/) for guides and the generated API reference.
312
+
313
+ ## Supported Formats
314
+
315
+ | Format | Extension(s) | Loader |
316
+ | --- | --- | --- |
317
+ | Plain text and logs | `.txt`, `.log` | Core |
318
+ | Markdown | `.md`, `.markdown` | Core |
319
+ | AsciiDoc | `.adoc`, `.asciidoc` | Docling, with core fallback |
320
+ | HTML | `.html`, `.htm` | Core |
321
+ | CSV / TSV | `.csv`, `.tsv` | Core, one document per row |
322
+ | JSON | `.json` | Core, record-aware |
323
+ | JSON Lines | `.jsonl`, `.ndjson` | Core, one document per row |
324
+ | PDF | `.pdf` | Docling |
325
+ | Word | `.docx` | Docling |
326
+ | PowerPoint | `.pptx` | Docling |
327
+ | Images | `.png`, `.jpg`, `.jpeg`, `.tif`, `.tiff`, `.bmp` | Docling |
328
+ | XML | `.xml` | Docling or the core XML reader |
329
+
330
+ Core loaders remain the default for Markdown, HTML, CSV, TSV, and JSON records. Docling takes precedence for layout-rich documents and AsciiDoc when installed.
331
+
332
+ ## Project Structure
333
+
334
+ ```text
335
+ agrag/
336
+ ├── common/data_models/ # documents, chunks, schemas, extraction and storage records
337
+ ├── chunking/ # Chonkie and Docling chunk adapters
338
+ ├── loaders/ # core corpus readers and optional Docling loader
339
+ ├── ingestion/ # Graph API, extraction, resolution, merge and pipeline stages
340
+ ├── embedding/ # dense and sparse embedding interfaces
341
+ ├── graphdb/ # graph-store interface and Neo4j backend
342
+ ├── vectordb/ # vector-store interface and Qdrant/Weaviate/Milvus backends
343
+ ├── cypher/ # validated Cypher builders
344
+ ├── retrieval/ # search methods, retrievers, recipes and rerankers
345
+ ├── agents/ # planner, researcher, verifier and answer synthesis
346
+ ├── communities/ # hierarchical detection and report generation
347
+ ├── llm/ # BAML sources, generated client and provider routing
348
+ └── observability.py # OpenTelemetry helpers
349
+
350
+ tests/
351
+ ├── unit/ # isolated tests with external services mocked
352
+ └── integration/ # live backend tests against Docker services
353
+ ```
354
+
355
+ ## Development
356
+
357
+ ```bash
358
+ git clone https://github.com/ontogr/agentic-graphrag.git
359
+ cd agentic-graphrag
360
+ make sync
361
+ make lint-check
362
+ make lint-typing
363
+ make test
364
+ ```
365
+
366
+ Integration tests run against local Neo4j, Qdrant, Weaviate, and Milvus services:
367
+
368
+ ```bash
369
+ make dev-services-up
370
+ make test-integration
371
+ make dev-services-down
372
+ ```
373
+
374
+ ## Contributing
375
+
376
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow, test conventions, and pull request guidelines.
377
+
378
+ ## References
379
+
380
+ - [Microsoft GraphRAG](https://arxiv.org/abs/2404.16130) — hierarchical communities and community reports
381
+ - [Graphiti](https://github.com/getzep/graphiti) — layered graph search and entity-aware retrieval
382
+ - [Cognee](https://github.com/topoteretes/cognee) — data pipelines, graph memory, and consolidation
383
+ - [KG-Gen](https://github.com/stair-lab/kg-gen) — knowledge-graph extraction and alias deduplication
384
+ - [FalkorDB GraphRAG SDK](https://github.com/FalkorDB/GraphRAG-SDK) — graph-native retrieval and entity resolution
385
+ - [Neo4j GraphRAG](https://github.com/neo4j/neo4j-graphrag-python) — Neo4j retrieval and vector integration
386
+ - [LightRAG](https://github.com/HKUDS/LightRAG) — graph and vector retrieval
387
+ - [PathRAG](https://github.com/BUPT-GAMMA/PathRAG) — relational-path retrieval
388
+ - [GLiNER](https://arxiv.org/abs/2311.08526) — generalist zero-shot information extraction
389
+ - [BAML](https://boundaryml.com/), [Docling](https://github.com/docling-project/docling), and [Chonkie](https://github.com/chonkie-inc/chonkie)
390
+
391
+ ## License
392
+
393
+ This project is licensed under the [Apache License 2.0](LICENSE).