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 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.
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1be2ae805e250b9fdd138176a37a9fec37429c7ff616211f1c12a73f5221d607
|
|
| MD5 |
cc837685d49aab001c697af7965794ad
|
|
| BLAKE2b-256 |
2fabb4cf68975c503e3d08a3ea2deb85ef508c953a0eebdc58b6bd4eea5e1406
|
Provenance
The following attestation bundles were made for ragsage-0.1.0.tar.gz:
Publisher:
release.yml on nirajk77777/ragsage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ragsage-0.1.0.tar.gz -
Subject digest:
1be2ae805e250b9fdd138176a37a9fec37429c7ff616211f1c12a73f5221d607 - Sigstore transparency entry: 2287614868
- Sigstore integration time:
-
Permalink:
nirajk77777/ragsage@e66ac41373d2430e8891652e8d53b2abdc7d21e5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nirajk77777
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e66ac41373d2430e8891652e8d53b2abdc7d21e5 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ac4b66ff890bbe6d944e1dd3b25b9a53ecdcd2aecc7c994480c83052d0fcaaa
|
|
| MD5 |
d202d308f5ffc453893bbe32bfa58c7a
|
|
| BLAKE2b-256 |
96c8f86f65a068d034e548df3fd876e5e19898c1d31da65caacc0852f42ba45c
|
Provenance
The following attestation bundles were made for ragsage-0.1.0-py3-none-any.whl:
Publisher:
release.yml on nirajk77777/ragsage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ragsage-0.1.0-py3-none-any.whl -
Subject digest:
3ac4b66ff890bbe6d944e1dd3b25b9a53ecdcd2aecc7c994480c83052d0fcaaa - Sigstore transparency entry: 2287614893
- Sigstore integration time:
-
Permalink:
nirajk77777/ragsage@e66ac41373d2430e8891652e8d53b2abdc7d21e5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nirajk77777
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e66ac41373d2430e8891652e8d53b2abdc7d21e5 -
Trigger Event:
push
-
Statement type: