Skip to main content

A production-grade, local-first Agentic RAG library using structural document navigation.

Project description

ApexRAG

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 StrictLeafVerifier engine 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 GraphEdge relations 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 via tenant_id boundaries.
  • Distributed Ingestion: A DistributedIndexer protocol allows for massive horizontal scaling of document parsing using Celery or Redis queues.
  • Code Intelligence: Includes a PythonCodeParser that 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apex_rag-1.0.2.tar.gz (139.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apex_rag-1.0.2-py3-none-any.whl (90.6 kB view details)

Uploaded Python 3

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

Hashes for apex_rag-1.0.2.tar.gz
Algorithm Hash digest
SHA256 168b83bb598e00546bec8e76105d3d20b2cd957d4c2988f88612ce64aca470b6
MD5 b77d49a8c2a781eb1f684b65b26dae71
BLAKE2b-256 833d63ddb12b35e4977334bb9d33fe00f9dc8846d1ff3dc31bf3c08470b072a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for apex_rag-1.0.2.tar.gz:

Publisher: ci.yml on abi6374/ApexRAG

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for apex_rag-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 117b7e14921ba7f436e3ed65db4d9c68dfd70c2e6624c077ff46dabb45b7da92
MD5 03a7e1b7bba2528a228398c6785bcf08
BLAKE2b-256 c5fcb43d7539f20cd6dd6eb9849dd0d4466412f16a02cdf4637fb9e050edd948

See more details on using hashes here.

Provenance

The following attestation bundles were made for apex_rag-1.0.2-py3-none-any.whl:

Publisher: ci.yml on abi6374/ApexRAG

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page