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 theEmbedderport against something that isn't Voyage. The ports areProtocols, so your adapter imports and subclasses nothing from ragsage.examples/custom_parser.py— implementDocumentParserto bypass the built-inHeuristicBackendon a format it doesn't understand.examples/assembled_engine.py—RagSage.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.
Metadata
Release files for ragsage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ragsage-0.1.0.tar.gz | 389.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ragsage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 507.1 kB
Release files / ragsage-0.1.0.tar.gz
| Download URL | ragsage-0.1.0.tar.gz |
|---|---|
| Size | 389.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1be2ae805e250b9fdd138176a37a9fec37429c7ff616211f1c12a73f5221d607
|
|
BLAKE2b-256 checksum How to use checksums |
2fabb4cf68975c503e3d08a3ea2deb85ef508c953a0eebdc58b6bd4eea5e1406
|
| 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 Jul 30, 2026.
Transparency logRelease files / ragsage-0.1.0-py3-none-any.whl
| Download URL | ragsage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 117.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ac4b66ff890bbe6d944e1dd3b25b9a53ecdcd2aecc7c994480c83052d0fcaaa
|
|
BLAKE2b-256 checksum How to use checksums |
96c8f86f65a068d034e548df3fd876e5e19898c1d31da65caacc0852f42ba45c
|
| 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 Jul 30, 2026.
Transparency log