A production-grade, local-first Agentic RAG library using structural document navigation.
Project description
The High-Accuracy, Local-First Structural Retrieval Infrastructure.
Stop guessing with vectors. Start navigating with agents.
🚀 Overview
ApexRAG has evolved from a simple RAG wrapper into a Multi-Agent, Structural Reasoning Engine built for enterprise deployments.
Traditional RAG relies on vector proximity, chopping documents into arbitrary chunks and losing crucial structural context (like section headings, table definitions, and document hierarchy), leading to hallucinations.
ApexRAG solves this by converting documents into a Universal Document AST (Abstract Syntax Tree) and using an Orchestrator of specialized LLM Agents (Planner, Navigator, Critic) to explicitly "walk" the document's structure to find exact, verifiable answers.
🏗️ The 3-Phase Architecture
Phase 1: Structural Foundation
- Universal Document AST: Documents (PDFs, Markdown, source code) are parsed into strict hierarchical trees (
ASTNode), preserving exact paragraph-to-heading relationships. - Deterministic Retrievers: Initial filtering uses keyword density, FTS5, and structural heading overlap to locate candidate branches without expensive LLM calls.
- Strict Verification: A
StrictLeafVerifierengine empirically checks if a found node actually answers the query, acting as a firewall against hallucination.
Phase 2: Structural Reasoning Engine
- Multi-Agent Orchestrator: Complex queries are managed by three agents working in concert:
- Planner Agent: Breaks down complex, multi-hop queries (e.g., "Compare Q2 and Q3 revenue") into discrete sub-queries.
- Navigator Agent: Explores the AST tree and Semantic Map signposts to find the correct data for each sub-query.
- Critic Agent: Evaluates the aggregated context to ensure all sub-queries were answered before synthesizing the final response.
- Structural Retrieval Graph (SRG): Nodes can have
GraphEdgerelations to other nodes (e.g.,REFERENCES_TABLE), enabling non-linear reasoning.
Phase 3: Enterprise Ecosystem Platform
- Multi-Tenant RBAC: Core SQLAlchemy models (
NodeData,SemanticModelData,GraphEdgeData) and FastAPI middlewares strictly enforce data isolation viatenant_idboundaries. - Distributed Ingestion: A
DistributedIndexerprotocol allows for massive horizontal scaling of document parsing using Celery or Redis queues. - Code Intelligence: Includes a
PythonCodeParserthat extracts ASTs from source code to enable structural code reasoning. - OpenTelemetry: Every agent action (
[PLANNING],[NAVIGATING]) is wrapped in distributed traces for production monitoring.
📦 Quick Start
pip install apex-rag
import asyncio
from apex_rag import ApexIndex, Orchestrator
from apex_rag.enterprise.auth.models import TenantContext
async def main():
# Setup Tenant Context
ctx = TenantContext(tenant_id="corp-abc", user_id="user-1", roles=["admin"])
async with await ApexIndex.create() as index:
# Ingest preserving structure
doc_id = await index.ingest("financial_report.md", tenant_id=ctx.tenant_id)
# Multi-Agent Reasoning Query
# Uses the Planner -> Navigator -> Critic loop internally
result = await index.orchestrate_query("Compare the revenue between Q2 and Q3", doc_id)
print(result)
asyncio.run(main())
📖 Documentation
📄 License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apex_rag-1.0.2.tar.gz.
File metadata
- Download URL: apex_rag-1.0.2.tar.gz
- Upload date:
- Size: 139.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
168b83bb598e00546bec8e76105d3d20b2cd957d4c2988f88612ce64aca470b6
|
|
| MD5 |
b77d49a8c2a781eb1f684b65b26dae71
|
|
| BLAKE2b-256 |
833d63ddb12b35e4977334bb9d33fe00f9dc8846d1ff3dc31bf3c08470b072a5
|
Provenance
The following attestation bundles were made for apex_rag-1.0.2.tar.gz:
Publisher:
ci.yml on abi6374/ApexRAG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apex_rag-1.0.2.tar.gz -
Subject digest:
168b83bb598e00546bec8e76105d3d20b2cd957d4c2988f88612ce64aca470b6 - Sigstore transparency entry: 1631948767
- Sigstore integration time:
-
Permalink:
abi6374/ApexRAG@cdca1e6e68d6a0121489c7ce6de5951e7e923398 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/abi6374
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@cdca1e6e68d6a0121489c7ce6de5951e7e923398 -
Trigger Event:
release
-
Statement type:
File details
Details for the file apex_rag-1.0.2-py3-none-any.whl.
File metadata
- Download URL: apex_rag-1.0.2-py3-none-any.whl
- Upload date:
- Size: 90.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
117b7e14921ba7f436e3ed65db4d9c68dfd70c2e6624c077ff46dabb45b7da92
|
|
| MD5 |
03a7e1b7bba2528a228398c6785bcf08
|
|
| BLAKE2b-256 |
c5fcb43d7539f20cd6dd6eb9849dd0d4466412f16a02cdf4637fb9e050edd948
|
Provenance
The following attestation bundles were made for apex_rag-1.0.2-py3-none-any.whl:
Publisher:
ci.yml on abi6374/ApexRAG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apex_rag-1.0.2-py3-none-any.whl -
Subject digest:
117b7e14921ba7f436e3ed65db4d9c68dfd70c2e6624c077ff46dabb45b7da92 - Sigstore transparency entry: 1631948776
- Sigstore integration time:
-
Permalink:
abi6374/ApexRAG@cdca1e6e68d6a0121489c7ce6de5951e7e923398 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/abi6374
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@cdca1e6e68d6a0121489c7ce6de5951e7e923398 -
Trigger Event:
release
-
Statement type: