agentic-graphrag 0.0.4__tar.gz → 0.0.5__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.
- agentic_graphrag-0.0.5/PKG-INFO +650 -0
- agentic_graphrag-0.0.5/README.md +578 -0
- agentic_graphrag-0.0.5/agrag/agents/__init__.py +36 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/build.py +8 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/ledger.py +2 -14
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/model.py +8 -6
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/prompts.py +5 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/settings.py +6 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/tools/__init__.py +10 -2
- agentic_graphrag-0.0.5/agrag/agents/tools/candidates.py +77 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/tools/search.py +13 -3
- agentic_graphrag-0.0.5/agrag/candidates/__init__.py +36 -0
- agentic_graphrag-0.0.5/agrag/candidates/errors.py +12 -0
- agentic_graphrag-0.0.5/agrag/candidates/patch.py +281 -0
- agentic_graphrag-0.0.5/agrag/candidates/review.py +445 -0
- agentic_graphrag-0.0.5/agrag/candidates/search.py +41 -0
- agentic_graphrag-0.0.5/agrag/chunking/__init__.py +22 -0
- agentic_graphrag-0.0.5/agrag/chunking/_edge_orders.py +31 -0
- agentic_graphrag-0.0.5/agrag/chunking/_tables.py +42 -0
- agentic_graphrag-0.0.5/agrag/chunking/chunker.py +467 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/__init__.py +21 -3
- agentic_graphrag-0.0.5/agrag/common/data_models/candidate.py +171 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/candidate_review.py +214 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/chunk.py +171 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/community.py +6 -6
- agentic_graphrag-0.0.5/agrag/common/data_models/cutover_job.py +18 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/default_schema.py +123 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/document.py +473 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/dropped.py +69 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/entity.py +36 -24
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/extraction.py +24 -8
- agentic_graphrag-0.0.5/agrag/common/data_models/graph_record.py +182 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/graph_schema.py +630 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/presets.py +100 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/provenance.py +27 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/resolved_entity.py +3 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/search_result.py +1 -5
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/stage_failure.py +3 -3
- agentic_graphrag-0.0.5/agrag/common/data_models/structure.py +201 -0
- agentic_graphrag-0.0.5/agrag/common/data_models/update_decision.py +19 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/vector_record.py +0 -15
- agentic_graphrag-0.0.5/agrag/common/fingerprint.py +19 -0
- agentic_graphrag-0.0.5/agrag/common/graph_rows.py +43 -0
- agentic_graphrag-0.0.5/agrag/common/schema_fingerprint.py +228 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/validation.py +22 -22
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/_pending_filter.py +23 -0
- agentic_graphrag-0.0.5/agrag/cypher/candidate_conversion.py +185 -0
- agentic_graphrag-0.0.5/agrag/cypher/candidate_review.py +145 -0
- agentic_graphrag-0.0.5/agrag/cypher/candidate_search.py +42 -0
- agentic_graphrag-0.0.5/agrag/cypher/candidates.py +163 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/community_read.py +14 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/cutover_job_read.py +12 -9
- agentic_graphrag-0.0.5/agrag/cypher/cutover_job_write.py +461 -0
- agentic_graphrag-0.0.5/agrag/cypher/documents.py +73 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/entities.py +193 -140
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/relations.py +240 -119
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/resolution_read.py +53 -34
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/resolution_write.py +32 -34
- agentic_graphrag-0.0.5/agrag/cypher/safety.py +576 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/schema.py +95 -23
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/embedding/__init__.py +8 -6
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/embedding/base.py +7 -7
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/embedding/fastembed_bm25.py +7 -19
- agentic_graphrag-0.0.5/agrag/embedding/fastembed_dense.py +208 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/embedding/sentence_transformers.py +38 -32
- agentic_graphrag-0.0.5/agrag/embedding/settings.py +38 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/embedding/sparse_base.py +4 -4
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/extraction.py +2 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/resolution.py +2 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/settings.py +6 -8
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/graphdb/base.py +103 -25
- agentic_graphrag-0.0.5/agrag/graphdb/entities.py +61 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/graphdb/errors.py +10 -12
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/graphdb/neo4j.py +308 -70
- agentic_graphrag-0.0.5/agrag/graphdb/serialize.py +189 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/__init__.py +8 -2
- agentic_graphrag-0.0.5/agrag/ingestion/_candidate_conversion.py +550 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_candidate_stage.py +232 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_cutover.py +717 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_deferred.py +127 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_document_lifecycle.py +176 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_escalation.py +363 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_gliner_decode.py +341 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_ingest.py +1052 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_ingest_pipeline.py +1312 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_job_cleanup.py +230 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/_lexical_backbone.py +20 -49
- agentic_graphrag-0.0.5/agrag/ingestion/_mentions.py +88 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_merge_stage.py +566 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_pending_rows.py +114 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_resolution_maintenance.py +546 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_resolve_stage.py +92 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/_resume.py +71 -30
- agentic_graphrag-0.0.5/agrag/ingestion/_stage_context.py +35 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_storage.py +509 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_structure.py +320 -0
- agentic_graphrag-0.0.5/agrag/ingestion/_walk.py +135 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/community.py +290 -70
- agentic_graphrag-0.0.5/agrag/ingestion/extract.py +1048 -0
- agentic_graphrag-0.0.5/agrag/ingestion/graph.py +1007 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/merge.py +111 -290
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/reports/__init__.py +4 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/reports/add_result.py +7 -27
- agentic_graphrag-0.0.5/agrag/ingestion/reports/consolidation_report.py +38 -0
- agentic_graphrag-0.0.5/agrag/ingestion/reports/conversion_report.py +25 -0
- agentic_graphrag-0.0.5/agrag/ingestion/reports/escalation_report.py +87 -0
- agentic_graphrag-0.0.5/agrag/ingestion/reports/reevaluation_report.py +41 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/reports/update_result.py +5 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolve/__init__.py +16 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolve/batch_validation.py +9 -6
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolve/candidate_source.py +100 -54
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolve/exact_groups.py +1 -1
- agentic_graphrag-0.0.5/agrag/ingestion/resolve/resolution.py +643 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolve/resolver.py +148 -84
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolve/zone_classifier.py +11 -35
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolved_embeddings.py +54 -33
- agentic_graphrag-0.0.4/agrag/ingestion/materialize.py → agentic_graphrag-0.0.5/agrag/ingestion/resolved_entities.py +268 -123
- agentic_graphrag-0.0.5/agrag/ingestion/settings.py +126 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/stats/__init__.py +3 -2
- agentic_graphrag-0.0.5/agrag/ingestion/stats/chunking.py +53 -0
- agentic_graphrag-0.0.5/agrag/ingestion/stats/dropped.py +18 -0
- agentic_graphrag-0.0.5/agrag/ingestion/stats/extraction.py +39 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/stats/merge.py +9 -6
- agentic_graphrag-0.0.5/agrag/ingestion/stats/resolution.py +32 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/async_client.py +9 -9
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/inlinedbaml.py +2 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/stream_types.py +9 -6
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/sync_client.py +9 -9
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/type_builder.py +99 -34
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/type_map.py +3 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/types.py +9 -6
- agentic_graphrag-0.0.5/agrag/llm/baml_src/extraction.baml +78 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_src/retrieval.baml +6 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/client_config.py +10 -5
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/client_registry.py +9 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/retry.py +49 -10
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/loaders/__init__.py +14 -18
- {agentic_graphrag-0.0.4/agrag/loaders/corpus → agentic_graphrag-0.0.5/agrag/loaders}/base.py +24 -6
- {agentic_graphrag-0.0.4/agrag/loaders/corpus/readers → agentic_graphrag-0.0.5/agrag/loaders}/chat.py +26 -23
- agentic_graphrag-0.0.4/agrag/loaders/corpus/readers/_common.py → agentic_graphrag-0.0.5/agrag/loaders/common.py +111 -31
- {agentic_graphrag-0.0.4/agrag/loaders/corpus → agentic_graphrag-0.0.5/agrag/loaders}/decode.py +3 -4
- agentic_graphrag-0.0.5/agrag/loaders/defaults.py +37 -0
- agentic_graphrag-0.0.5/agrag/loaders/docling/__init__.py +10 -0
- agentic_graphrag-0.0.5/agrag/loaders/docling/_converters.py +96 -0
- agentic_graphrag-0.0.5/agrag/loaders/docling/_sections.py +292 -0
- agentic_graphrag-0.0.5/agrag/loaders/docling/loader.py +187 -0
- {agentic_graphrag-0.0.4/agrag/loaders/corpus → agentic_graphrag-0.0.5/agrag/loaders}/errors.py +3 -5
- agentic_graphrag-0.0.5/agrag/loaders/loader_registry.py +64 -0
- agentic_graphrag-0.0.5/agrag/loaders/prose.py +108 -0
- {agentic_graphrag-0.0.4/agrag/loaders/corpus/readers → agentic_graphrag-0.0.5/agrag/loaders}/records.py +28 -17
- {agentic_graphrag-0.0.4/agrag/loaders/corpus → agentic_graphrag-0.0.5/agrag/loaders}/types.py +23 -16
- agentic_graphrag-0.0.4/agrag/loaders/corpus/_walk.py → agentic_graphrag-0.0.5/agrag/loaders/walk.py +40 -22
- agentic_graphrag-0.0.5/agrag/retrieval/chunking.py +69 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/community_context.py +10 -22
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/filters.py +1 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/fusion.py +10 -13
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/methods/traversal.py +7 -7
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/methods/vector.py +2 -3
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/rerank/cross_encoder.py +0 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/rerank/node_distance.py +2 -8
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/resolved_entities.py +13 -25
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/retrievers/base.py +1 -1
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/retrievers/bfs.py +5 -21
- agentic_graphrag-0.0.5/agrag/retrieval/retrievers/chunk.py +140 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/retrievers/community.py +22 -20
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/retrievers/entity.py +91 -137
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/retrievers/text2cypher.py +71 -149
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/search_engine.py +47 -20
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/settings.py +5 -5
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/tracing.py +0 -30
- agentic_graphrag-0.0.5/agrag/schema/__init__.py +14 -0
- agentic_graphrag-0.0.5/agrag/schema/canonical.py +64 -0
- agentic_graphrag-0.0.5/agrag/schema/errors.py +67 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/__init__.py +26 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/_iri.py +90 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/dispatch.py +56 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/errors.py +18 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/json_schema.py +207 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/jsonld.py +149 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/owl.py +812 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/pydantic_models.py +297 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/result.py +38 -0
- agentic_graphrag-0.0.5/agrag/schema/formats/shacl.py +223 -0
- agentic_graphrag-0.0.5/agrag/schema/loader.py +780 -0
- agentic_graphrag-0.0.5/agrag/schema/shorthand.py +608 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/vectordb/base.py +112 -2
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/vectordb/milvus.py +33 -24
- agentic_graphrag-0.0.5/agrag/vectordb/pending.py +87 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/vectordb/qdrant.py +43 -22
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/vectordb/settings.py +7 -7
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/vectordb/weaviate.py +50 -33
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/pyproject.toml +45 -17
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/pyproject.toml.orig +55 -14
- agentic_graphrag-0.0.4/PKG-INFO +0 -418
- agentic_graphrag-0.0.4/README.md +0 -344
- agentic_graphrag-0.0.4/agrag/agents/__init__.py +0 -19
- agentic_graphrag-0.0.4/agrag/chunking/__init__.py +0 -38
- agentic_graphrag-0.0.4/agrag/chunking/_docling_adapters.py +0 -69
- agentic_graphrag-0.0.4/agrag/chunking/_text.py +0 -159
- agentic_graphrag-0.0.4/agrag/chunking/base.py +0 -239
- agentic_graphrag-0.0.4/agrag/chunking/docling.py +0 -200
- agentic_graphrag-0.0.4/agrag/chunking/extras.py +0 -182
- agentic_graphrag-0.0.4/agrag/chunking/heading.py +0 -137
- agentic_graphrag-0.0.4/agrag/chunking/parent_child.py +0 -105
- agentic_graphrag-0.0.4/agrag/chunking/recursive.py +0 -72
- agentic_graphrag-0.0.4/agrag/chunking/rules.py +0 -119
- agentic_graphrag-0.0.4/agrag/chunking/sentence.py +0 -51
- agentic_graphrag-0.0.4/agrag/chunking/token.py +0 -49
- agentic_graphrag-0.0.4/agrag/chunking/turns.py +0 -115
- agentic_graphrag-0.0.4/agrag/common/data_models/chunk.py +0 -189
- agentic_graphrag-0.0.4/agrag/common/data_models/cutover_job.py +0 -63
- agentic_graphrag-0.0.4/agrag/common/data_models/document.py +0 -317
- agentic_graphrag-0.0.4/agrag/common/data_models/graph_record.py +0 -148
- agentic_graphrag-0.0.4/agrag/common/data_models/graph_schema.py +0 -183
- agentic_graphrag-0.0.4/agrag/cypher/cutover_job_write.py +0 -319
- agentic_graphrag-0.0.4/agrag/cypher/safety.py +0 -141
- agentic_graphrag-0.0.4/agrag/embedding/settings.py +0 -35
- agentic_graphrag-0.0.4/agrag/graphdb/serialize.py +0 -227
- agentic_graphrag-0.0.4/agrag/ingestion/_cutover.py +0 -482
- agentic_graphrag-0.0.4/agrag/ingestion/_document_lifecycle.py +0 -115
- agentic_graphrag-0.0.4/agrag/ingestion/_ingest_pipeline.py +0 -1690
- agentic_graphrag-0.0.4/agrag/ingestion/extract.py +0 -834
- agentic_graphrag-0.0.4/agrag/ingestion/graph.py +0 -2079
- agentic_graphrag-0.0.4/agrag/ingestion/reports/consolidation_report.py +0 -26
- agentic_graphrag-0.0.4/agrag/ingestion/reports/reevaluation_report.py +0 -28
- agentic_graphrag-0.0.4/agrag/ingestion/settings.py +0 -24
- agentic_graphrag-0.0.4/agrag/ingestion/stats/chunking.py +0 -77
- agentic_graphrag-0.0.4/agrag/ingestion/stats/extraction.py +0 -27
- agentic_graphrag-0.0.4/agrag/ingestion/stats/resolution.py +0 -22
- agentic_graphrag-0.0.4/agrag/llm/baml_src/extraction.baml +0 -74
- agentic_graphrag-0.0.4/agrag/loaders/corpus/__init__.py +0 -41
- agentic_graphrag-0.0.4/agrag/loaders/corpus/readers/html.py +0 -64
- agentic_graphrag-0.0.4/agrag/loaders/corpus/readers/prose.py +0 -220
- agentic_graphrag-0.0.4/agrag/loaders/corpus/registry.py +0 -104
- agentic_graphrag-0.0.4/agrag/loaders/docling/__init__.py +0 -34
- agentic_graphrag-0.0.4/agrag/loaders/docling/loader.py +0 -139
- agentic_graphrag-0.0.4/agrag/retrieval/identity.py +0 -98
- agentic_graphrag-0.0.4/agrag/retrieval/retrievers/chunk.py +0 -252
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/LICENSE +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/errors.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/harness.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/middleware.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/result.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/subagents.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/tools/aggregate.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/tools/traversal.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/tracing.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/agents/verification.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/data_point.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/normalization.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/query_value.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/data_models/relation.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/common/text.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/cypher/community_write.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/embedding/errors.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/adapter.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/answer.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/judge.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/trajectory.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/eval/verifier.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/graphdb/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/graphdb/settings.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/_clustering.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/reports/community_detection_report.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/resolve/comparators.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/stats/ingest.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/ingestion/stats/storage.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/config.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/globals.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/parser.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/runtime.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/tracing.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_client/watchers.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_src/community.baml +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_src/generators.baml +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_src/merge.baml +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/baml_src/resolution.baml +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/llm/tracing.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/observability.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/py.typed +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/errors.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/methods/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/recipes.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/rerank/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/retrieval/retrievers/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/vectordb/__init__.py +0 -0
- {agentic_graphrag-0.0.4 → agentic_graphrag-0.0.5}/agrag/vectordb/errors.py +0 -0
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentic-graphrag
|
|
3
|
+
Version: 0.0.5
|
|
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: openinference-semantic-conventions
|
|
18
|
+
Requires-Dist: charset-normalizer>=3.4
|
|
19
|
+
Requires-Dist: selectolax>=0.3.21,<1
|
|
20
|
+
Requires-Dist: docling-slim[convert-core,format-markdown,format-html,format-docx,format-pptx,format-xlsx]>=2.135
|
|
21
|
+
Requires-Dist: rapidfuzz>=3.0
|
|
22
|
+
Requires-Dist: scipy>=1.14
|
|
23
|
+
Requires-Dist: fastembed>=0.8.0
|
|
24
|
+
Requires-Dist: jsonschema>=4.0
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: langgraph>=1.2 ; extra == 'agents'
|
|
27
|
+
Requires-Dist: deepagents>=0.7.15 ; extra == 'agents'
|
|
28
|
+
Requires-Dist: langchain-openai>=1.0 ; extra == 'agents'
|
|
29
|
+
Requires-Dist: graspologic-native>=1.2.5 ; extra == 'community'
|
|
30
|
+
Requires-Dist: docling>=2.135 ; extra == 'docling'
|
|
31
|
+
Requires-Dist: sentence-transformers>=5 ; extra == 'embed-local'
|
|
32
|
+
Requires-Dist: deepeval>=4.2.6 ; extra == 'eval'
|
|
33
|
+
Requires-Dist: agentevals>=0.0.9 ; extra == 'eval'
|
|
34
|
+
Requires-Dist: er-evaluation>=2.3.0 ; extra == 'eval'
|
|
35
|
+
Requires-Dist: scikit-learn>=1.5 ; extra == 'eval'
|
|
36
|
+
Requires-Dist: langchain-openai>=1.0 ; extra == 'eval'
|
|
37
|
+
Requires-Dist: opentelemetry-sdk>=1.20 ; extra == 'eval'
|
|
38
|
+
Requires-Dist: openinference-instrumentation-langchain>=0.1.76,<0.2 ; extra == 'eval'
|
|
39
|
+
Requires-Dist: gliner2[local] ; extra == 'extract'
|
|
40
|
+
Requires-Dist: transformers<4.56 ; extra == 'extract'
|
|
41
|
+
Requires-Dist: protobuf ; extra == 'extract'
|
|
42
|
+
Requires-Dist: baml-py>=0.226.1,<0.227 ; extra == 'llm'
|
|
43
|
+
Requires-Dist: pymilvus>=3.0.0,<4 ; extra == 'milvus'
|
|
44
|
+
Requires-Dist: neo4j>=5.22 ; extra == 'neo4j'
|
|
45
|
+
Requires-Dist: opentelemetry-sdk>=1.20 ; extra == 'observability'
|
|
46
|
+
Requires-Dist: opentelemetry-exporter-otlp>=1.20 ; extra == 'observability'
|
|
47
|
+
Requires-Dist: opentelemetry-instrumentation-asyncio ; extra == 'observability'
|
|
48
|
+
Requires-Dist: openinference-instrumentation-langchain>=0.1.76,<0.2 ; extra == 'observability'
|
|
49
|
+
Requires-Dist: qdrant-client>=1.12 ; extra == 'qdrant'
|
|
50
|
+
Requires-Dist: rdflib>=7.1 ; extra == 'schema-formats'
|
|
51
|
+
Requires-Dist: weaviate-client>=4.9 ; extra == 'weaviate'
|
|
52
|
+
Maintainer: Ashwin Mathur, Varun Mathur
|
|
53
|
+
Maintainer-email: Ashwin Mathur <ashwinm400@gmail.com>, Varun Mathur <varunm500@gmail.com>
|
|
54
|
+
Requires-Python: >=3.11
|
|
55
|
+
Project-URL: Documentation, https://ontogr.github.io/agentic-graphrag/
|
|
56
|
+
Project-URL: Issues, https://github.com/ontogr/agentic-graphrag/issues
|
|
57
|
+
Project-URL: Source, https://github.com/ontogr/agentic-graphrag
|
|
58
|
+
Provides-Extra: agents
|
|
59
|
+
Provides-Extra: community
|
|
60
|
+
Provides-Extra: docling
|
|
61
|
+
Provides-Extra: embed-local
|
|
62
|
+
Provides-Extra: eval
|
|
63
|
+
Provides-Extra: extract
|
|
64
|
+
Provides-Extra: llm
|
|
65
|
+
Provides-Extra: milvus
|
|
66
|
+
Provides-Extra: neo4j
|
|
67
|
+
Provides-Extra: observability
|
|
68
|
+
Provides-Extra: qdrant
|
|
69
|
+
Provides-Extra: schema-formats
|
|
70
|
+
Provides-Extra: weaviate
|
|
71
|
+
Description-Content-Type: text/markdown
|
|
72
|
+
|
|
73
|
+
<h1 align="center"><a href="https://github.com/ontogr/agentic-graphrag">Agentic GraphRAG</a></h1>
|
|
74
|
+
|
|
75
|
+
<div align="center">
|
|
76
|
+
|
|
77
|
+
[](https://deepwiki.com/ontogr/agentic-graphrag)
|
|
78
|
+
[](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
|
|
79
|
+
[](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
|
|
80
|
+
[](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
|
|
81
|
+
[](https://github.com/ontogr/agentic-graphrag/actions/workflows/ci.yml)
|
|
82
|
+
[](https://github.com/ontogr/agentic-graphrag/actions/workflows/integration.yml)
|
|
83
|
+
[](https://codecov.io/gh/ontogr/agentic-graphrag)
|
|
84
|
+
[](https://pypi.org/project/agentic-graphrag/)
|
|
85
|
+
[](https://pypi.org/project/agentic-graphrag/)
|
|
86
|
+
[](https://pepy.tech/project/agentic-graphrag)
|
|
87
|
+
[](https://ontogr.github.io/agentic-graphrag/)
|
|
88
|
+
[](LICENSE)
|
|
89
|
+
|
|
90
|
+
[Documentation](https://ontogr.github.io/agentic-graphrag/) · [Quickstart](#quickstart) · [Concepts](https://ontogr.github.io/agentic-graphrag/stable/concepts/architecture) · [Guides](https://ontogr.github.io/agentic-graphrag/stable/guides/ingest-documents) · [API reference](https://ontogr.github.io/agentic-graphrag/stable/api)
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
Agentic GraphRAG builds schema-defined knowledge graphs from documents and structured data. It stores source text alongside entities and relations, retrieves evidence from the graph and vector indexes, and can answer questions with citations to that evidence.
|
|
95
|
+
|
|
96
|
+
A plain vector search finds passages that look like your question. It cannot join a fact in one document to a fact in another. "Who founded the company that Satya Nadella works at?" needs two facts from two places. A graph joins them.
|
|
97
|
+
|
|
98
|
+
<p align="center">
|
|
99
|
+
<img src="https://raw.githubusercontent.com/ontogr/agentic-graphrag/main/docs/static/img/readme/pipeline.png" alt="Agentic GraphRAG pipeline. Sources are loaded, chunked, extracted, and resolved into a Neo4j graph and optional vector stores. Retrieval feeds a planner, researcher, and verifier agent that returns a cited answer. OpenTelemetry traces every layer." width="900">
|
|
100
|
+
</p>
|
|
101
|
+
|
|
102
|
+
- One ingestion API for raw text, files, directories, globs, and prebuilt documents.
|
|
103
|
+
- Structure-aware loading with Docling for rich documents and core readers for text, XML, and records. Sections, tables, and figures go into the graph, and one section-aware chunker packs every format.
|
|
104
|
+
- Schema-driven extraction with runtime-defined entity types, relation types, and valid graph patterns.
|
|
105
|
+
- Local extraction with GLiNER 2.5. In `hybrid` mode, pass an LLM extractor to `Graph` to review selected chunks up to a budget. The local model still runs on every chunk. A graph can be built without an extraction LLM, but GLiNER runs locally and needs its model dependencies.
|
|
106
|
+
- Tiered entity resolution combining exact, fuzzy, embedding, and LLM-verified matching. An unsure comparison never matches.
|
|
107
|
+
- Non-destructive matching. Fuzzy, embedding, and LLM matches write `MATCHES` edges and a derived `ResolvedEntity`. The original entities and their provenance stay in the graph.
|
|
108
|
+
- Pluggable storage with Neo4j for graph data and native vectors, plus Qdrant, Weaviate, and Milvus/Zilliz for dedicated vector search.
|
|
109
|
+
- Layered retrieval across entities, chunks, community reports, graph neighborhoods, and generated Cypher, with hybrid fusion and reranking.
|
|
110
|
+
- Agentic plan-research-verify loop that decomposes questions, gathers evidence, checks it, and produces cited answers.
|
|
111
|
+
- OpenTelemetry-native observability across loading, chunking, extraction, resolution, storage, retrieval, and agent turns.
|
|
112
|
+
|
|
113
|
+
The system uses:
|
|
114
|
+
|
|
115
|
+
- [Docling](https://github.com/docling-project/docling) for document parsing and [Chonkie](https://github.com/chonkie-inc/chonkie) to split long paragraphs.
|
|
116
|
+
- [GLiNER 2.5](https://github.com/urchade/GLiNER) for local schema-guided entity and relation extraction.
|
|
117
|
+
- [BAML](https://boundaryml.com/) for typed LLM functions and provider-independent client routing.
|
|
118
|
+
- [Neo4j](https://neo4j.com/) for the property graph and optional native vector search.
|
|
119
|
+
- [Qdrant](https://qdrant.tech/), [Weaviate](https://weaviate.io/), and [Milvus](https://milvus.io/) for dense and hybrid retrieval.
|
|
120
|
+
- [FastEmbed](https://github.com/qdrant/fastembed) for dense and sparse embeddings, and [Sentence Transformers](https://www.sbert.net/) as an optional dense embedder.
|
|
121
|
+
- [OpenTelemetry](https://opentelemetry.io/) for vendor-neutral traces and metrics.
|
|
122
|
+
|
|
123
|
+
## Knowledge Graph
|
|
124
|
+
|
|
125
|
+
Agentic GraphRAG stores source material, extracted knowledge, and graph summaries in one typed property graph:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
(:Document)-[:HAS_CHILD]->(:Section)
|
|
129
|
+
(:Section)-[:HAS_CHILD]->(:Section|:Chunk|:Table|:Figure)
|
|
130
|
+
(:Table)-[:HAS_CHILD]->(:Chunk)
|
|
131
|
+
(:Document)-[:HAS_PART]->(:Section|:Chunk|:Table|:Figure)
|
|
132
|
+
(:Source)-[:HAS_DOCUMENT]->(:Document)
|
|
133
|
+
(:Chunk)-[:NEXT_CHUNK]->(:Chunk)
|
|
134
|
+
(:Chunk)-[:MENTIONED_IN]->(entity)
|
|
135
|
+
(entity)-[:<RELATION_TYPE>]->(entity)
|
|
136
|
+
(entity)-[:MATCHES]->(entity)
|
|
137
|
+
(entity)-[:RESOLVED_AS]->(:ResolvedEntity)
|
|
138
|
+
(entity)-[:MEMBER_OF]->(:Community)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
An entity node carries its schema type as a label, for example `:Person`. You can walk from any answer back to its source document.
|
|
142
|
+
|
|
143
|
+
### Documents, sections, and chunks
|
|
144
|
+
|
|
145
|
+
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. A document holds a tree of sections, tables, and figures. Chunks keep stable links into that tree and source provenance:
|
|
146
|
+
|
|
147
|
+
A section keeps its heading, depth, and a stable `section_key`, and it holds no text. Text chunks record character spans plus their heading path, and they are exact slices of the document text. Chunks from PDF and slides record page numbers and bounding boxes. Record formats such as CSV, TSV, JSON, and JSON Lines preserve row identity. A new document version writes a new tree, and the old tree stays as history.
|
|
148
|
+
|
|
149
|
+
### Entities and relations
|
|
150
|
+
|
|
151
|
+
Extraction produces mentions first, not graph nodes. Each mention keeps its source chunk, label, text span, confidence, and extractor provenance. Resolution then decides which mentions name the same thing. Mentions with the same label and the same normalized text share one entity node.
|
|
152
|
+
|
|
153
|
+
Relations are directed subject-predicate-object triples. The active schema constrains valid source type, relation type, and target type combinations. Validation removes invalid triples before they reach the graph.
|
|
154
|
+
|
|
155
|
+
### Matches and resolved entities
|
|
156
|
+
|
|
157
|
+
A fuzzy, embedding, or LLM match does not rewrite or delete anything. It writes a `MATCHES` edge with its tier, score, and reason. Agentic GraphRAG then derives one `ResolvedEntity` for each group of linked entities and links each member to it with `RESOLVED_AS`. A later run can undo a decision, because the original entities are still there. Retrieval can search resolved entities.
|
|
158
|
+
|
|
159
|
+
### Communities
|
|
160
|
+
|
|
161
|
+
Leiden clustering groups related entities into communities. `Graph.detect_communities` keeps the broadest groups of two or more entities. A group with enough supporting relations gets an LLM-written report with a title, summary, findings, and a rating from 0 to 10. A smaller group gets a simple report with no LLM call. Community reports provide broad context without forcing retrieval to return every low-level edge.
|
|
162
|
+
|
|
163
|
+
### Runtime schemas
|
|
164
|
+
|
|
165
|
+
`GraphSchema` is a first-class runtime value. It defines:
|
|
166
|
+
|
|
167
|
+
- entity types and their descriptions.
|
|
168
|
+
- relation types and their descriptions.
|
|
169
|
+
- valid `(source, relation, target)` patterns.
|
|
170
|
+
- the vocabulary injected into local and LLM extractors.
|
|
171
|
+
|
|
172
|
+
Load OWL and RDFS Turtle ontologies with `load_schema("ontology.ttl")` after installing the `schema-formats` extra. See the [OWL and RDFS Turtle import reference](https://ontogr.github.io/agentic-graphrag/stable/reference/owl-import).
|
|
173
|
+
|
|
174
|
+
Use `DEFAULT_SCHEMA` for general text, or provide a schema for a specific domain. The schema guides extraction and validation, and supplies type information to retrieval and query generation.
|
|
175
|
+
|
|
176
|
+
Write a schema as a short dict, a list of labels or a YAML file. `extends` builds on the default schema:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from agrag.schema import load_schema
|
|
180
|
+
|
|
181
|
+
schema = load_schema(
|
|
182
|
+
{
|
|
183
|
+
"extends": "default",
|
|
184
|
+
"entities": [
|
|
185
|
+
{
|
|
186
|
+
"label": "Vendor",
|
|
187
|
+
"description": "An organization that sells to others.",
|
|
188
|
+
"parents": ["Organization"],
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"relations": ["Vendor-SELLS_TO->Organization"],
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Default schema and presets
|
|
197
|
+
|
|
198
|
+
`DEFAULT_SCHEMA` has nine entity types: Person, Organization, Location, Event, Product, Software, Publication, Dataset, and Project. It has eight relation types: WORKS_FOR, PART_OF, LOCATED_IN, OWNS, AUTHORED, PARTICIPATED_IN, DEPENDS_ON, and SUPPLIES. Each relation allows only the source and target types that it names.
|
|
199
|
+
|
|
200
|
+
Presets add entity types to a base schema. `OPERATIONS` adds Facility, Service, and Occupation. `LEGAL` adds Contract and Regulation. A preset adds types only. The default relations do not accept preset types, so define a relation in your own schema to connect them.
|
|
201
|
+
|
|
202
|
+
Use `extends` to build a schema on a base, such as `DEFAULT_SCHEMA` or a preset. A child type that redeclares a base type must use `override`. Use `exclude` to remove base types or relations.
|
|
203
|
+
|
|
204
|
+
### Extraction modes
|
|
205
|
+
|
|
206
|
+
Set `EXTRACTION_MODE` to choose how the graph reads text. The default is `hybrid`.
|
|
207
|
+
|
|
208
|
+
| Mode | What runs on each chunk | Use it when |
|
|
209
|
+
|---|---|---|
|
|
210
|
+
| `gliner` | The local GLiNER model. No extraction LLM runs. | You want no extraction LLM cost. |
|
|
211
|
+
| `hybrid` | GLiNER on every chunk, then an LLM on the weakest eligible chunks within the budget. | You have an LLM and want it to review GLiNER's result. |
|
|
212
|
+
| `llm` | An LLM on every chunk that meets `min_escalation_words` (8 by default). GLiNER does not run. | You want LLM extraction without GLiNER. The LLM may use a hosted or local endpoint. |
|
|
213
|
+
|
|
214
|
+
For the default extractors, install `extract` for `gliner`, both `extract` and `llm` for `hybrid`, or `llm` for `llm` mode. Custom extractors use their own dependencies.
|
|
215
|
+
|
|
216
|
+
When `hybrid` has no extraction LLM available, `Graph` selects GLiNER mode and logs a warning. `Graph` can build a BAML extractor from environment settings in either `hybrid` or `llm` mode, so a configured LLM may be used even when you do not pass `llm_extractor`. Set `EXTRACTION_MODE=gliner` to disable LLM extraction explicitly. Check `graph.effective_mode` to see the selected mode. See [Choose an extraction mode](https://ontogr.github.io/agentic-graphrag/latest/guides/choose-an-extraction-mode) for the tradeoffs.
|
|
217
|
+
|
|
218
|
+
## Architecture
|
|
219
|
+
|
|
220
|
+
Agentic GraphRAG has two main data flows:
|
|
221
|
+
|
|
222
|
+
Ingestion turns a source into a document, then into chunks, mentions, a matched graph, and indexes. A query turns a question into a plan, research, verification, and a cited answer.
|
|
223
|
+
|
|
224
|
+
## Ingestion Pipeline
|
|
225
|
+
|
|
226
|
+
`Graph.add()` is the single entry point for adding content. The pipeline has six stages:
|
|
227
|
+
|
|
228
|
+
1. Load: Select a loader by format. Decode or parse the source. Preserve source metadata. Apply `RAISE`, `SKIP`, or `QUARANTINE` as the error policy for each source.
|
|
229
|
+
2. Chunk: Pack the sections of every document into chunks with one section-aware chunker, using 600 tokens as the packing budget. Tokenizer context around the joined units can add a few tokens past it. A table becomes its own chunks, and a small chunk carries on into the next section.
|
|
230
|
+
3. Extract: Use the selected extraction mode. `gliner` runs GLiNER locally on every chunk; `hybrid` also sends the weakest eligible chunks to an LLM within the budget; `llm` sends eligible chunks to an LLM without running GLiNER. Validation drops entities and triples that do not conform to the schema.
|
|
231
|
+
4. Resolve: Apply exact, fuzzy, embedding, and LLM-verified comparison tiers. Ambiguous or failed comparisons do not match.
|
|
232
|
+
5. Merge: Combine the mentions of exact matches into one entity. Decide each property value and join the chunk ids that mention it. Fuzzy, embedding, and LLM matches are stored as `MATCHES` edges, not merged.
|
|
233
|
+
6. Store: Upsert nodes and relations, then populate graph-native or dedicated vector indexes.
|
|
234
|
+
|
|
235
|
+
`Graph` combines the LLM result with the local result as a union. An LLM entity with the name of a local entity keeps the local span and score. A chunk is eligible when one entity scores below 0.75, when the local model finds no entities in a chunk of at least eight words, or when an entity has a type with properties. The LLM reads the weakest eligible chunks first, up to 20% of the chunks in a batch by default, and each run reports what it left to the local model. Exact matches use global store-backed lookup. More expensive fuzzy and LLM comparisons run on a smaller candidate set.
|
|
236
|
+
|
|
237
|
+
<p align="center">
|
|
238
|
+
<img src="https://raw.githubusercontent.com/ontogr/agentic-graphrag/main/docs/static/img/readme/resolution.png" alt="Entity resolution tiers. A pair of mentions with the same label passes an exact tier, a fuzzy tier, an embedding tier, and an LLM tier. An unsure pair is never matched. A match writes MATCHES edges and a derived ResolvedEntity, and the original entities stay." width="900">
|
|
239
|
+
</p>
|
|
240
|
+
|
|
241
|
+
The pipeline compares only mentions with the same label, so a city and a company with the same name stay apart. A wrong match mixes the facts of two things, and a missed match can be fixed later. Uncertain comparisons stay undecided rather than becoming matches or rejections.
|
|
242
|
+
|
|
243
|
+
`Graph.consolidate()` provides a separate whole-graph reconciliation pass for duplicates found across ingestion runs. It runs as a dry run by default, so applications can inspect proposed matches before they apply them.
|
|
244
|
+
|
|
245
|
+
`Graph.update()` replaces a document that changed, and an unchanged document is a no-op. `Graph.delete_document()` removes a document from search and prunes entities that lose their last evidence. Both work on a document key, and each runs as one job, so a crash leaves the document whole.
|
|
246
|
+
|
|
247
|
+
## Embeddings and Storage
|
|
248
|
+
|
|
249
|
+
The async `Embedder`, `GraphStore`, and `VectorStore` interfaces keep model and database choices outside graph-construction logic.
|
|
250
|
+
|
|
251
|
+
### Embeddings
|
|
252
|
+
|
|
253
|
+
- Dense embeddings through FastEmbed, with Sentence Transformers as an option.
|
|
254
|
+
- Sparse BM25 embeddings through FastEmbed.
|
|
255
|
+
- Batch-first async APIs with optional content-addressed caching by text and model.
|
|
256
|
+
- Dimension checks before collections or indexes accept vectors. `Graph.open` raises an error when the embedder does not match the stored vector dimensions.
|
|
257
|
+
|
|
258
|
+
### Graph storage
|
|
259
|
+
|
|
260
|
+
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. The query builders validate dynamic labels and relation types before they interpolate them into Cypher.
|
|
261
|
+
|
|
262
|
+
### Vector storage
|
|
263
|
+
|
|
264
|
+
| Backend | Dense search | Hybrid search | Deployment |
|
|
265
|
+
| --- | --- | --- | --- |
|
|
266
|
+
| Neo4j | Native vector index | No | Local or Aura |
|
|
267
|
+
| Qdrant | Yes | Dense + sparse fusion | Local or Cloud |
|
|
268
|
+
| Weaviate | Yes | Native BM25/vector weighting | Custom or Cloud |
|
|
269
|
+
| Milvus / Zilliz | Yes | Dense + BM25 fusion | Local or Cloud |
|
|
270
|
+
|
|
271
|
+
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.
|
|
272
|
+
|
|
273
|
+
## Retrieval Pipeline
|
|
274
|
+
|
|
275
|
+
Retrieval composes small search methods into retrievers, runs them concurrently, and fuses their results through data-only recipes.
|
|
276
|
+
|
|
277
|
+
- Entity retrieval finds entities and resolved entities by dense or hybrid search and can expand matched seeds with bounded graph traversal.
|
|
278
|
+
- Chunk retrieval returns source passages with document and span provenance.
|
|
279
|
+
- Community retrieval searches community reports for thematic and corpus-wide questions.
|
|
280
|
+
- Text-to-Cypher retrieval generates a schema-aware, read-only query with bounded retries.
|
|
281
|
+
- Graph traversal uses bounded breadth-first search to collect connected evidence.
|
|
282
|
+
|
|
283
|
+
| Recipe | Search methods | Extra steps |
|
|
284
|
+
| --- | --- | --- |
|
|
285
|
+
| `ENTITY` | Entity | none |
|
|
286
|
+
| `CHUNK` | Chunk | none |
|
|
287
|
+
| `HYBRID` | Entity + chunk | none |
|
|
288
|
+
| `HYBRID_RERANKED` | Entity + chunk | Community reports, cross-encoder rerank |
|
|
289
|
+
| `GRAPH_EXPAND` | Entity | Graph walk, community reports |
|
|
290
|
+
| `THEMATIC` | Community | none |
|
|
291
|
+
| `TEXT2CYPHER` | Text-to-Cypher | none |
|
|
292
|
+
|
|
293
|
+
Reciprocal Rank Fusion merges the ranked lists, so no method's score scale takes over. A cross-encoder or graph-distance reranker can then set a new order. A recipe can ignore a failed or empty search branch and still return evidence from the remaining methods.
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from agrag.retrieval import HYBRID, SearchEngine
|
|
297
|
+
|
|
298
|
+
engine = SearchEngine(graph_store=graph_store, embedder=embedder, graph_schema=schema)
|
|
299
|
+
results = await engine.search("What treats headaches?", HYBRID)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Agentic RAG Loop
|
|
303
|
+
|
|
304
|
+
<p align="center">
|
|
305
|
+
<img src="https://raw.githubusercontent.com/ontogr/agentic-graphrag/main/docs/static/img/readme/agent-loop.png" alt="Agent loop. A planner splits the question into sub-questions. A researcher searches the graph. A verifier returns PASS, INSUFFICIENT, or CONTRADICTORY. INSUFFICIENT sends the gaps back to the researcher. The answer carries citation keys." width="900">
|
|
306
|
+
</p>
|
|
307
|
+
|
|
308
|
+
The agent coordinates three roles around the retrieval layer:
|
|
309
|
+
|
|
310
|
+
- Planner: splits a question into two to four focused sub-questions and writes the final answer.
|
|
311
|
+
- Researcher: searches the graph with entity, chunk, community, graph, and Cypher tools. Every evidence item keeps its citation key.
|
|
312
|
+
- Verifier: has no tools. It checks each sub-question against the cited evidence and returns one verdict.
|
|
313
|
+
|
|
314
|
+
| Verdict | Meaning | Next step |
|
|
315
|
+
| --- | --- | --- |
|
|
316
|
+
| `PASS` | Every sub-question has supporting evidence. Nothing conflicts. | The planner writes the answer. |
|
|
317
|
+
| `INSUFFICIENT` | A sub-question lacks evidence, or a claim does not match its evidence. | The planner sends the gaps back to the researcher, up to three times. |
|
|
318
|
+
| `CONTRADICTORY` | Two cited pieces of evidence conflict. | The planner states the conflict in the answer. |
|
|
319
|
+
|
|
320
|
+
When the retry limit is reached, the planner answers from the evidence it has and names the sub-questions it did not answer. Each run keeps a ledger. The ledger maps every citation key to stored evidence. `E` means an entity, `R` means a relation, `C` means a chunk, `G` means a community report, and `V` means a query value. You can limit every search to one document or tenant.
|
|
321
|
+
|
|
322
|
+
## Structured LLM Output
|
|
323
|
+
|
|
324
|
+
BAML defines typed contracts for entity and relation extraction, entity-match verification, community reports, description summaries, and Cypher generation. Runtime client registries support a single provider, fallback chains, or round-robin routing. They route across OpenAI, Anthropic, AWS Bedrock, Google AI, Vertex AI, Azure OpenAI, and OpenAI-compatible endpoints. The agent uses an OpenAI-compatible endpoint that you set with `LLM_BASE_URL`, `LLM_API_KEY`, and `LLM_MODEL_ID`.
|
|
325
|
+
|
|
326
|
+
## Observability and Failure Handling
|
|
327
|
+
|
|
328
|
+
OpenTelemetry API support is part of the core package. Exporters and the SDK are optional. You pass the tracer, and Agentic GraphRAG never installs a global one. Applications can send traces to any OTLP-compatible backend. Spans cover loading, chunking, extraction, model calls, resolution, storage writes, searches, and agent turns.
|
|
329
|
+
|
|
330
|
+
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.
|
|
331
|
+
|
|
332
|
+
`agrag.eval` (the `eval` extra) holds metrics that score answers, retrieval, extraction, resolution, and agent runs on your own documents and questions. See [Score Agentic GraphRAG on your questions](https://ontogr.github.io/agentic-graphrag/stable/guides/score-agrag-on-your-questions).
|
|
333
|
+
|
|
334
|
+
## Installation
|
|
335
|
+
|
|
336
|
+
Agentic GraphRAG requires Python 3.11 or newer.
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
uv pip install agentic-graphrag
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Install only the integrations you use:
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Rich documents and local extraction
|
|
346
|
+
uv pip install "agentic-graphrag[docling,extract]"
|
|
347
|
+
|
|
348
|
+
# LLM extraction
|
|
349
|
+
uv pip install "agentic-graphrag[llm]"
|
|
350
|
+
|
|
351
|
+
# Neo4j with a dedicated Qdrant vector store and OTLP tracing
|
|
352
|
+
uv pip install "agentic-graphrag[neo4j,qdrant,observability]"
|
|
353
|
+
|
|
354
|
+
# The question-answering agent
|
|
355
|
+
uv pip install "agentic-graphrag[agents]"
|
|
356
|
+
|
|
357
|
+
# Hierarchical community detection
|
|
358
|
+
uv pip install "agentic-graphrag[community]"
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
| Extra | Adds |
|
|
362
|
+
| --- | --- |
|
|
363
|
+
| `docling` | The layout and table models for PDF and image files |
|
|
364
|
+
| `extract` | Local GLiNER 2.5 extraction |
|
|
365
|
+
| `llm` | BAML-powered extraction and match verification |
|
|
366
|
+
| `agents` | The LangGraph runtime for the question-answering agent |
|
|
367
|
+
| `embed-local` | Sentence Transformers, to embed with models that the default embedder does not support |
|
|
368
|
+
| `neo4j` | Neo4j graph storage and native vector search |
|
|
369
|
+
| `qdrant` | Qdrant dense and hybrid search |
|
|
370
|
+
| `weaviate` | Weaviate dense and hybrid search |
|
|
371
|
+
| `milvus` | Milvus/Zilliz dense and hybrid search |
|
|
372
|
+
| `observability` | OpenTelemetry SDK and OTLP export |
|
|
373
|
+
| `community` | Leiden community detection |
|
|
374
|
+
| `eval` | The DeepEval and AgentEvals metrics in `agrag.eval` |
|
|
375
|
+
|
|
376
|
+
## Quickstart
|
|
377
|
+
|
|
378
|
+
You need a Neo4j database, version 5.23 or newer. The free [Neo4j Aura](https://ontogr.github.io/agentic-graphrag/stable/get-started/quickstart) tier works, and the full [Quickstart](https://ontogr.github.io/agentic-graphrag/stable/get-started/quickstart) shows the setup. Install the extras for this page with uv 0.6.9 or newer. Create and activate a virtual environment, then install the package. Save your credentials as `.env` in the working directory. The file sets `NEO4J_URI`, `NEO4J_USERNAME`, and `NEO4J_PASSWORD`.
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
uv venv
|
|
382
|
+
source .venv/bin/activate
|
|
383
|
+
uv pip install "agentic-graphrag[neo4j,extract,agents]" --torch-backend=auto
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Build a graph
|
|
387
|
+
|
|
388
|
+
Save this script as `build_graph.py`. It needs no LLM key.
|
|
389
|
+
|
|
390
|
+
The example passes `GlinerExtractor` directly, so GLiNER always runs. If an extraction LLM is configured in the environment, the default `hybrid` mode can also use it to review selected chunks. To make the mode explicit and prevent extraction LLM use, set `EXTRACTION_MODE=gliner` in `.env` or the shell.
|
|
391
|
+
|
|
392
|
+
```python
|
|
393
|
+
import asyncio
|
|
394
|
+
|
|
395
|
+
from agrag.common.data_models import EntityType, GraphSchema, RelationType
|
|
396
|
+
from agrag.embedding import build_embedder
|
|
397
|
+
from agrag.graphdb import build_graph_store
|
|
398
|
+
from agrag.ingestion import GlinerExtractor, Graph
|
|
399
|
+
|
|
400
|
+
schema = GraphSchema(
|
|
401
|
+
name="company-facts",
|
|
402
|
+
version="1",
|
|
403
|
+
entities=[
|
|
404
|
+
EntityType(label="Person", description="A named individual."),
|
|
405
|
+
EntityType(label="Organization", description="A company or institution."),
|
|
406
|
+
EntityType(label="Location", description="A city or country."),
|
|
407
|
+
],
|
|
408
|
+
relations=[
|
|
409
|
+
RelationType(
|
|
410
|
+
label="FOUNDED",
|
|
411
|
+
description="A person founded an organization.",
|
|
412
|
+
patterns=[("Person", "Organization")],
|
|
413
|
+
),
|
|
414
|
+
RelationType(
|
|
415
|
+
label="WORKS_AT",
|
|
416
|
+
description="A person works at an organization.",
|
|
417
|
+
patterns=[("Person", "Organization")],
|
|
418
|
+
),
|
|
419
|
+
RelationType(
|
|
420
|
+
label="HEADQUARTERED_IN",
|
|
421
|
+
description="An organization has its headquarters in a location.",
|
|
422
|
+
patterns=[("Organization", "Location")],
|
|
423
|
+
),
|
|
424
|
+
],
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
TEXT = (
|
|
428
|
+
"Satya Nadella works at Microsoft. Bill Gates founded Microsoft. "
|
|
429
|
+
"Microsoft is headquartered in Redmond."
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
async def main() -> None:
|
|
433
|
+
graph_store = build_graph_store("neo4j")
|
|
434
|
+
graph = await Graph.open(
|
|
435
|
+
schema=schema,
|
|
436
|
+
graph_store=graph_store,
|
|
437
|
+
embedder=build_embedder("ibm-granite/granite-embedding-small-english-r2"),
|
|
438
|
+
extractor=GlinerExtractor(),
|
|
439
|
+
)
|
|
440
|
+
try:
|
|
441
|
+
result = await graph.add(text=TEXT, return_chunks=True)
|
|
442
|
+
print("documents:", result.ingestion.documents)
|
|
443
|
+
print("chunks:", len(result.chunks))
|
|
444
|
+
print("entities extracted:", result.extraction.entities_extracted)
|
|
445
|
+
print("relations extracted:", result.extraction.relations_extracted)
|
|
446
|
+
finally:
|
|
447
|
+
await graph_store.close()
|
|
448
|
+
|
|
449
|
+
if __name__ == "__main__":
|
|
450
|
+
asyncio.run(main())
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
The script prints the counts below. The first run downloads two models, about 850 MB in total.
|
|
454
|
+
|
|
455
|
+
```text
|
|
456
|
+
documents: 1
|
|
457
|
+
chunks: 1
|
|
458
|
+
entities extracted: 6
|
|
459
|
+
relations extracted: 3
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
Run the script from the directory that contains `build_graph.py` and `.env`:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
python build_graph.py
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Ask a question
|
|
469
|
+
|
|
470
|
+
This step needs an OpenAI-compatible LLM endpoint. Add `LLM_BASE_URL`, `LLM_API_KEY`, and `LLM_MODEL_ID` to `.env`. Then save this script as `ask.py`:
|
|
471
|
+
|
|
472
|
+
```python
|
|
473
|
+
import asyncio
|
|
474
|
+
|
|
475
|
+
from agrag.agents import AgentLLMSettings, build_agent
|
|
476
|
+
from agrag.embedding import build_embedder
|
|
477
|
+
from agrag.graphdb import build_graph_store
|
|
478
|
+
from agrag.retrieval import SearchEngine
|
|
479
|
+
|
|
480
|
+
from build_graph import schema
|
|
481
|
+
|
|
482
|
+
QUESTION = "Who founded the company that Satya Nadella works at?"
|
|
483
|
+
|
|
484
|
+
async def main() -> None:
|
|
485
|
+
graph_store = build_graph_store("neo4j")
|
|
486
|
+
await graph_store.connect()
|
|
487
|
+
try:
|
|
488
|
+
engine = SearchEngine(
|
|
489
|
+
graph_store=graph_store,
|
|
490
|
+
embedder=build_embedder("ibm-granite/granite-embedding-small-english-r2"),
|
|
491
|
+
graph_schema=schema,
|
|
492
|
+
)
|
|
493
|
+
agent = build_agent(
|
|
494
|
+
engine=engine,
|
|
495
|
+
llm_settings=AgentLLMSettings.from_openai_compatible_env(),
|
|
496
|
+
graph_schema=schema,
|
|
497
|
+
)
|
|
498
|
+
result = await agent.ainvoke(
|
|
499
|
+
{"messages": [{"role": "user", "content": QUESTION}]}
|
|
500
|
+
)
|
|
501
|
+
answer = result["messages"][-1]
|
|
502
|
+
print(answer["content"] if isinstance(answer, dict) else answer.content)
|
|
503
|
+
print("evidence keys:", ", ".join(result["ledger"].keys))
|
|
504
|
+
finally:
|
|
505
|
+
await graph_store.close()
|
|
506
|
+
|
|
507
|
+
asyncio.run(main())
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
```bash
|
|
511
|
+
BAML_LOG=off uv run python ask.py
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
The answer varies with your model. This is an example:
|
|
515
|
+
|
|
516
|
+
```text
|
|
517
|
+
Satya Nadella works at Microsoft (E1, E3), which was founded by Bill Gates (E2, E3, C1).
|
|
518
|
+
evidence keys: E1, E2, E3, E4, C1, V1
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
The agent needed two facts from two sentences. It joined them through the `Microsoft` node. Each key points to stored evidence.
|
|
522
|
+
|
|
523
|
+
### Add more content
|
|
524
|
+
|
|
525
|
+
`Graph.add()` accepts exactly one of:
|
|
526
|
+
|
|
527
|
+
- `source=`: a file, directory, glob, or list of paths.
|
|
528
|
+
- `text=`: raw text as one document.
|
|
529
|
+
- `documents=`: prebuilt `Document` objects.
|
|
530
|
+
|
|
531
|
+
```python
|
|
532
|
+
files = await graph.add(source="./corpus/**/*.md", return_chunks=True)
|
|
533
|
+
print(files.ingestion.documents, len(files.chunks))
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### Handle source failures
|
|
537
|
+
|
|
538
|
+
```python
|
|
539
|
+
from agrag.loaders import ErrorPolicy
|
|
540
|
+
|
|
541
|
+
result = await graph.add(
|
|
542
|
+
source="./corpus",
|
|
543
|
+
error_policy=ErrorPolicy.QUARANTINE,
|
|
544
|
+
)
|
|
545
|
+
|
|
546
|
+
for item in result.ingestion.quarantined_items:
|
|
547
|
+
print(item.item_id, item.error_message)
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
`RAISE` stops the run, `SKIP` drops the source and counts it, and `QUARANTINE` sets it aside with the reason.
|
|
551
|
+
|
|
552
|
+
### Update and delete documents
|
|
553
|
+
|
|
554
|
+
```python
|
|
555
|
+
await graph.update("notes/q3.md", text=new_text)
|
|
556
|
+
await graph.delete_document("notes/q3.md")
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
See the [documentation](https://ontogr.github.io/agentic-graphrag/) for guides and the generated API reference.
|
|
560
|
+
|
|
561
|
+
## Supported Formats
|
|
562
|
+
|
|
563
|
+
| Format | Extension(s) | Loader |
|
|
564
|
+
| --- | --- | --- |
|
|
565
|
+
| Plain text and logs | `.txt`, `.log` | Core |
|
|
566
|
+
| XML | `.xml` | Core |
|
|
567
|
+
| Markdown | `.md`, `.markdown` | Docling |
|
|
568
|
+
| AsciiDoc | `.adoc`, `.asciidoc` | Docling |
|
|
569
|
+
| HTML | `.html`, `.htm` | Docling |
|
|
570
|
+
| CSV / TSV | `.csv`, `.tsv` | Core, one document per row or one for the table |
|
|
571
|
+
| JSON | `.json` | Core, record-aware |
|
|
572
|
+
| JSON Lines | `.jsonl`, `.ndjson` | Core, one document per row |
|
|
573
|
+
| PDF | `.pdf` | Docling, needs the `docling` extra |
|
|
574
|
+
| Word | `.docx` | Docling |
|
|
575
|
+
| PowerPoint | `.pptx` | Docling |
|
|
576
|
+
| Excel | `.xlsx` | Docling |
|
|
577
|
+
| Images | `.png`, `.jpg`, `.jpeg`, `.tif`, `.tiff`, `.bmp` | Docling, needs the `docling` extra |
|
|
578
|
+
| Chat exports | `.json`, `.jsonl`, `.ndjson` | Chat loader, which you pass for a single file |
|
|
579
|
+
|
|
580
|
+
Docling reads every rich format. The core readers keep plain text, XML, and the record formats, so a CSV row keeps its identity. Docling without the `docling` extra reads Markdown, HTML, AsciiDoc, Word, PowerPoint, and Excel files. The extra adds the layout and table models for PDF and image files.
|
|
581
|
+
|
|
582
|
+
## Project Structure
|
|
583
|
+
|
|
584
|
+
```text
|
|
585
|
+
agrag/
|
|
586
|
+
├── common/data_models/ # documents, chunks, schemas, extraction and storage records
|
|
587
|
+
├── chunking/ # the section chunker
|
|
588
|
+
├── loaders/ # core corpus readers and the Docling loaders
|
|
589
|
+
├── ingestion/ # Graph API, extraction, resolution, community detection and pipeline stages
|
|
590
|
+
├── embedding/ # dense and sparse embedding interfaces
|
|
591
|
+
├── graphdb/ # graph-store interface and Neo4j backend
|
|
592
|
+
├── vectordb/ # vector-store interface and Qdrant/Weaviate/Milvus backends
|
|
593
|
+
├── cypher/ # validated Cypher builders
|
|
594
|
+
├── retrieval/ # search methods, retrievers, recipes and rerankers
|
|
595
|
+
├── agents/ # planner, researcher, verifier and citation ledger
|
|
596
|
+
├── eval/ # metrics for answers, retrieval, extraction, resolution and agent runs
|
|
597
|
+
├── llm/ # BAML sources, generated client and provider routing
|
|
598
|
+
└── observability.py # OpenTelemetry helpers
|
|
599
|
+
|
|
600
|
+
tests/
|
|
601
|
+
├── unit/ # isolated tests with external services mocked
|
|
602
|
+
└── integration/ # live backend tests against Docker services
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
## Development
|
|
606
|
+
|
|
607
|
+
```bash
|
|
608
|
+
git clone https://github.com/ontogr/agentic-graphrag.git
|
|
609
|
+
cd agentic-graphrag
|
|
610
|
+
make sync
|
|
611
|
+
make lint-check
|
|
612
|
+
make lint-typing
|
|
613
|
+
make test
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
Integration tests run against local Neo4j, Qdrant, Weaviate, and Milvus services:
|
|
617
|
+
|
|
618
|
+
```bash
|
|
619
|
+
make dev-services-up
|
|
620
|
+
make test-integration
|
|
621
|
+
make dev-services-down
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
## Contributing
|
|
625
|
+
|
|
626
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow, test conventions, and pull request guidelines.
|
|
627
|
+
|
|
628
|
+
## References
|
|
629
|
+
|
|
630
|
+
The work below shaped the design of Agentic GraphRAG.
|
|
631
|
+
|
|
632
|
+
<details>
|
|
633
|
+
<summary>Papers and projects</summary>
|
|
634
|
+
|
|
635
|
+
- [Microsoft GraphRAG](https://arxiv.org/abs/2404.16130): hierarchical communities and community reports
|
|
636
|
+
- [Graphiti](https://github.com/getzep/graphiti): layered graph search and entity-aware retrieval
|
|
637
|
+
- [Cognee](https://github.com/topoteretes/cognee): data pipelines, graph memory, and consolidation
|
|
638
|
+
- [KG-Gen](https://github.com/stair-lab/kg-gen): knowledge-graph extraction and alias deduplication
|
|
639
|
+
- [FalkorDB GraphRAG SDK](https://github.com/FalkorDB/GraphRAG-SDK): graph-native retrieval and entity resolution
|
|
640
|
+
- [Neo4j GraphRAG](https://github.com/neo4j/neo4j-graphrag-python): Neo4j retrieval and vector integration
|
|
641
|
+
- [LightRAG](https://github.com/HKUDS/LightRAG): graph and vector retrieval
|
|
642
|
+
- [PathRAG](https://github.com/BUPT-GAMMA/PathRAG): relational-path retrieval
|
|
643
|
+
- [GLiNER](https://arxiv.org/abs/2311.08526): generalist zero-shot information extraction
|
|
644
|
+
- [BAML](https://boundaryml.com/), [Docling](https://github.com/docling-project/docling), and [Chonkie](https://github.com/chonkie-inc/chonkie)
|
|
645
|
+
|
|
646
|
+
</details>
|
|
647
|
+
|
|
648
|
+
## License
|
|
649
|
+
|
|
650
|
+
This project is licensed under the [Apache License 2.0](LICENSE).
|