A fast, honest, self-hosted RAG engine — hybrid dense+sparse retrieval, streaming, provider fallback, and real token usage reporting. BYOK, no vendor lock-in.
Project description
ragleap-rag
A fast, honest, self-hosted RAG engine. Hybrid dense+sparse retrieval, streaming, provider fallback, and real token usage reporting — no vendor lock-in, bring your own API keys.
pip install ragleap-rag[gemini]
from ragleap import RagLeap, ProviderConfig
rag = RagLeap(
database_url="postgresql://user:pass@localhost/mydb",
embedder_api_key="your-gemini-key",
primary=ProviderConfig(provider="gemini", api_key="your-gemini-key"),
)
rag.init_schema() # one-time, idempotent
with open("document.pdf", "rb") as f:
result = rag.ingest("document.pdf", f.read())
print(f"Ingested {result.chunks_stored} chunks")
answer = rag.ask("What does this document say?")
print(answer["answer"])
print("Sources:", answer["sources"])
print("Tokens used:", answer["usage"])
Why ragleap-rag
- Hybrid search by default — combines pgvector dense similarity with Postgres full-text sparse search via Reciprocal Rank Fusion, catching both semantic matches and exact keyword/identifier matches.
- Real provider fallback — configure backup LLM providers; if your primary fails (rate limit, outage, bad key), it retries automatically.
- Streaming — real per-provider streaming for Gemini, Anthropic, and any OpenAI-compatible endpoint.
- Real token usage — every answer reports actual
prompt_tokens,completion_tokens,total_tokensfrom the provider's own response, not an estimate. - Context budget trimming — automatically drops lowest-ranked chunks to stay within a character budget, so you're not paying for more context than necessary.
- BYOK, always — no system-provided keys, ever. You own your data, your database, and your API costs.
Requirements
A PostgreSQL database with the pgvector
extension available (CREATE EXTENSION vector — rag.init_schema() handles
the rest). Embeddings currently use Google Gemini (gemini-embedding-001);
generation supports Gemini, Anthropic, and any OpenAI-compatible provider
(OpenAI, Groq, Mistral, Together, OpenRouter, Ollama, DeepSeek, xAI, Cohere,
Perplexity, or a custom endpoint).
Status
This is a young, actively-developed extraction from
ragleap-core, the open-source
self-hosted RAG platform. Full documentation, more embedding providers, and
companion packages (ragleap-graph for knowledge-graph-boosted retrieval,
ragleap-integrations for CRM/database connectors) are in progress.
License
MIT
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
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 ragleap_rag-0.1.0.tar.gz.
File metadata
- Download URL: ragleap_rag-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a01ca62475924fed996945c165bbb87ad0ee5cb23dcca1dbbb491141826257c7
|
|
| MD5 |
e4fa440a947fc5faeb7f810de6f00438
|
|
| BLAKE2b-256 |
79b85f94b379bad3c81d0838365ab77f74bd663f49f721b7c145ba763e2012dd
|
File details
Details for the file ragleap_rag-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ragleap_rag-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c933a0360c8ab1d467d960ccf81e9959e147fc09b2834e44e8966c28fb344c91
|
|
| MD5 |
83fbdd3ef65a367d0a59861b8643cd1e
|
|
| BLAKE2b-256 |
917ad665c1e284ae7242d7bc8ef53e9e7a04d1fb8c2ddc92a64ea1385bda268d
|