Skip to main content

Khora

CI Release codecov Python 3.13+ License: Apache 2.0

"Khora is the receptacle, the space, the matrix in which all things come to be." - Plato, Timaeus

A Python library for creating knowledge repositories that ingest unstructured and structured multi-source data and expose a single query substrate, built for integrating into long-horizon AI agents.

Quickstart

Two supported stacks. Pick by deployment shape - the public API is identical for both.

uv add khora              # Docker: PostgreSQL + pgvector + Neo4j
uv add khora[embedded]    # Embedded: SQLite + LanceDB, no external services
import asyncio
from khora import Khora, context_text

async def main() -> None:
    async with Khora() as kb:  # reads KHORA_DATABASE_URL / KHORA_NEO4J_URL
        ns = await kb.create_namespace()
        await kb.remember(
            "Marie Curie won the Nobel Prize in Physics in 1903.",
            namespace=ns.namespace_id,
            entity_types=["PERSON", "AWARD"],
            relationship_types=["WON"],
        )
        result = await kb.recall("What did Curie win?", namespace=ns.namespace_id)
        print(context_text(result))

asyncio.run(main())

For the Docker stack, set KHORA_DATABASE_URL and KHORA_NEO4J_URL, run uv run alembic upgrade head, then run the snippet above. For the embedded stack, set KHORA_STORAGE_BACKEND=sqlite_lance and the corresponding db_path - no external services required.

See the docs for the full extras list and env-var reference.

Why khora?

Knowledge repositories for long-horizon agents - copilots, customer-support bots, research assistants - hit two problems that pure vector search doesn't solve:

  1. Ingest is more than chunking. A useful repository needs entities, relationships, and temporal anchors extracted from the raw text. Khora runs a 3-phase ingest pipeline (stage → enrich → expand) with selective LLM extraction (default 50% of chunks, configurable) and cross-batch entity resolution.
  2. Retrieval is more than cosine. Real queries mix semantic similarity, multi-hop entity reasoning, freshness, and keyword precision. Khora combines vector + Cypher graph traversal + BM25 + RRF fusion + temporal-anchored reranking, routed per query.

Storage stacks

Stack Install Use when
PostgreSQL + pgvector + Neo4j uv add khora Default. Docker-friendly, multi-tenant ready, scales horizontally.
SQLite + LanceDB (experimental) uv add khora[embedded] Demos, evaluation, tests, single-user CLIs. Documented ceiling: ~1M chunks, ~100k entities, ~500k edges, traversal depth ≤3. Known gaps: no point-in-time queries, partial atomicity in coordinator.transaction(), FTS on chunks only.

Retrieval engines

Khora's retrieval layer is pluggable. More than one engine can sit on the same storage substrate. The default is VectorCypher: it handles structured and unstructured data from multiple sources by combining a knowledge graph with a vector store, then dispatching each query to the best retrieval method via a query-aware router.

The router selects between vector similarity, graph traversal, BM25 keyword, or a fused blend. RRF fusion, optional PPR (Personalized PageRank), and optional cross-encoder reranking shape the result set. Selective per-chunk LLM extraction (KET-RAG style) bounds ingest cost.

Batch processing

submit_batch() stages documents as PENDING and returns a BatchHandle immediately. A background processor picks them up and calls on_result per document as each completes.

The processor is opt-in - call kb.start_pending_processor() after connect() on services that write documents. Read-only services do not need it.

async with Khora() as kb:
    kb.start_pending_processor()
    handle = await kb.submit_batch(
        [{"content": "doc 1"}, {"content": "doc 2"}],
        on_result=lambda completed, total, result: print(result),
        namespace=ns_id,
        entity_types=["PERSON", "ORG"],
        relationship_types=["WORKS_AT"],
    )
    await handle.wait()

Integrations

Opt-in adapters for the major agentic frameworks. Each adapter is in its own extra; the framework is imported lazily so import khora never pulls in a framework you don't use.

Framework Install Khora surface
CrewAI uv add khora[crewai] KhoraMemory - drop-in storage backend for CrewAI's unified Memory.
LangGraph uv add khora[langgraph] KhoraStore - BaseStore implementation for StateGraph semantic long-term memory.
Google ADK uv add khora[google-adk] KhoraMemoryService - BaseMemoryService drop-in for ADK Runner.
OpenAI Agents SDK uv add khora[openai-agents] KhoraSession, khora_recall_tool, KhoraMemoryHooks.
LlamaIndex uv add khora[llamaindex] KhoraRetriever, KhoraMemoryBlock.

See the docs for per-adapter guides and the "write your own" Protocol surface.

Examples

Runnable demos under examples/:

  • 00_quickstart/ - remember + recall, grounded answers, forget, namespaces.
  • 10_core_apis/ - batch ingest, recall filters, ontology config, entities + relationships, graph traversal.
  • 20_integrations/ - LangGraph, OpenAI Agents SDK, CrewAI.
  • 30_workloads/ - per-user preferences with temporal decay, document Q&A with multi-signal abstention, support-ticket knowledge graphs, agent conversation history, namespace versioning, resume search with cross-document entity resolution.

Run any demo from the repo root, e.g. uv run python examples/30_workloads/01_per_user_preferences.py. The embedded backend (examples/khora.embedded.yaml) needs no external services; pass --config examples/khora.standard.yaml to target PostgreSQL + Neo4j.

Rust acceleration (optional)

Khora ships an optional Rust extension (khora-accel) that speeds up MMR, cosine similarity, PageRank, entity resolution, community detection, and temporal operators. Pure-Python fallbacks ship in the base package; the Rust path is opt-in.

uv add khora[rust]

Prebuilt wheels cover the common platforms (macOS arm64/x86_64, Linux x86_64/aarch64, Windows x86_64), so most users won't need a toolchain. Building from source requires Rust 1.85+.

Observability

Khora emits OpenTelemetry spans and metrics through the OTel API. Export path is your choice: vanilla OTel SDK (uv add khora[otel]), Logfire (uv add khora[logfire]), or nothing (zero-cost no-op). Credential fields on KhoraConfig are pydantic.SecretStr; free-text never leaks into span attributes.

See the docs for the env-var contract, vendor recipes, and the telemetry surface reference.

Documentation

Full documentation at docs.deyta.ai/khora - API reference, configuration, architecture, migrations, integrations, and the downstream-consumer guide.

Development

make dev         # start PostgreSQL + Neo4j (Docker); alias: make db-up
make test        # pytest with coverage
make format      # ruff format + isort
make lint        # ruff + ty typecheck

See CHANGELOG.md for release history.

License

Copyright 2026 AllTheData Inc.

Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.

Metadata

Release files for khora 0.26.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for khora 0.26.0
File Size Uploaded
khora-0.26.0.tar.gz 7.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for khora 0.26.0
File Interpreter ABI Platform
khora-0.26.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 MB

Release files / khora-0.26.0.tar.gz

Download URL khora-0.26.0.tar.gz
Size 7.3 MB
Tags Source
SHA-256 checksum
How to use checksums
a3f348d6bdf4f6495b6c11dd334e41e355561a0754d395693269fd2e0ef64edb
BLAKE2b-256 checksum
How to use checksums
decdec27bae04ea7868ffd147e6a427a1f0840f36c611126f6993361a03ba0f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release files / khora-0.26.0-py3-none-any.whl

Download URL khora-0.26.0-py3-none-any.whl
Size 1.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
d4e8a295efff520ad039de208d1f759007ecc74a790932a5bd04f79668dbcbcf
BLAKE2b-256 checksum
How to use checksums
a3c0062c9c61dd224965b37524435460204c3adc291228b2cbec09c37e195969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.26.0 This release

2 release files

0.25.0

2 release files

0.24.0

2 release files

0.23.1

2 release files

0.23.0

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.20.0

2 release files

0.17.4

2 release files

0.17.3

2 release files

0.17.2

2 release files

0.17.1

2 release files

0.17.0

2 release files

0.16.4

2 release files

0.16.3

2 release files

0.16.2

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.15.3

2 release files

0.15.2

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.8

2 release files

0.10.7

2 release files

0.10.6

2 release files

0.10.5

2 release files

0.10.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page