Skip to main content

A sage that only speaks from your corpus — a reusable, tenancy-agnostic RAG engine behind ports

Project description

ragsage

A sage that only speaks from your corpus.

ragsage is a reusable, model-agnostic and tenancy-agnostic Retrieval-Augmented Generation engine. It owns the whole RAG domain — parsing, chunking, embedding, hybrid retrieval, reranking, grounded generation, and verifiable citations — behind provider-agnostic ports, so you can swap any model or store by implementing an interface.

The library never imports web, auth, or tenant concepts. Callers pass an opaque Scope (a namespace plus optional metadata filters); the engine treats it as an untyped label. That single boundary is what lets the same engine run single-tenant from a script or CLI, and multi-tenant behind a SaaS backend, unchanged.

Try it standalone

The library ships in-memory fake adapters for every port, so the full ingest-and-query loop runs offline with no web server, database, or network:

$ ragsage ingest ./docs
  + france.txt: 2 chunks
  corpus saved to .ragsage/state.json

$ ragsage query "What is the capital of France?"
Paris is the capital of France. It sits on the Seine river. [1]

Sources:
  [1] f9d8ec95d8be4f2e (page 1)

Or drive the façades directly, wiring the fakes (swap in real adapters — Voyage embeddings, Cohere rerank, pgvector — behind the same ports for production):

from ragsage import IngestionPipeline, QueryEngine, RawSource, Scope
from ragsage.fakes import FakeEngineKit

kit = FakeEngineKit()
scope = Scope(namespace="local")
# ... build IngestionPipeline / QueryEngine from `kit` and run ingest() / query()

Examples

Runnable, argument-free, and offline — start with the first:

  • examples/fakes_end_to_end.py — the whole ingest-and-query loop against the in-memory fakes, in about ten lines of wiring.
  • examples/custom_embedder.py — implement the Embedder port against something that isn't Voyage. The ports are Protocols, so your adapter imports and subclasses nothing from ragsage.
  • examples/custom_parser.py — implement DocumentParser to bypass the built-in HeuristicBackend on a format it doesn't understand.
  • examples/assembled_engine.pyRagSage.from_config(...): migrate, ingest, query and purge from one config object instead of hand-wiring ports. Wants a Postgres and skips without one.

When retrieval looks wrong

The built-in parser is heuristic and model-free by decision (ADR-0001), which means it has known weak spots — borderless tables, unusual multi-column layouts, vision-route misroutes, and documents whose headings are typographically invisible. docs/failure-modes.md lists them symptom-first, with how to confirm each one from the parser's own output and what to do about it.

Public surface

  • Façades: IngestionPipeline.ingest, QueryEngine.query, Evaluator.evaluate.
  • Ports: DocumentParser, PageClassifier, Chunker, Contextualizer, Embedder, Reranker, LLMClient, VectorStore, LexicalStore, DocumentStore, Cache, Tracer.
  • Models: Document, Chunk, Citation, Answer, Scope, and friends.
  • Fakes: a working in-memory adapter for every port, in ragsage.fakes.

Status

Early. Ports, pipelines, and the standalone CLI are in place with in-memory fakes; production adapters and the async streaming surface land as the backend wires them.

License

MIT — © 2026 Niraj Kumar.

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

ragsage-0.1.0.tar.gz (389.2 kB view details)

Uploaded Source

Built Distribution

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

ragsage-0.1.0-py3-none-any.whl (117.9 kB view details)

Uploaded Python 3

File details

Details for the file ragsage-0.1.0.tar.gz.

File metadata

  • Download URL: ragsage-0.1.0.tar.gz
  • Upload date:
  • Size: 389.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ragsage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1be2ae805e250b9fdd138176a37a9fec37429c7ff616211f1c12a73f5221d607
MD5 cc837685d49aab001c697af7965794ad
BLAKE2b-256 2fabb4cf68975c503e3d08a3ea2deb85ef508c953a0eebdc58b6bd4eea5e1406

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragsage-0.1.0.tar.gz:

Publisher: release.yml on nirajk77777/ragsage

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

File details

Details for the file ragsage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ragsage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 117.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ragsage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ac4b66ff890bbe6d944e1dd3b25b9a53ecdcd2aecc7c994480c83052d0fcaaa
MD5 d202d308f5ffc453893bbe32bfa58c7a
BLAKE2b-256 96c8f86f65a068d034e548df3fd876e5e19898c1d31da65caacc0852f42ba45c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ragsage-0.1.0-py3-none-any.whl:

Publisher: release.yml on nirajk77777/ragsage

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