rag-anchor
A Python library for adding RAG (Retrieval-Augmented Generation) to an existing project: ingest documents, store them as vectors, and answer questions from them.
Status: under development. The version published on PyPI (
0.0.0) only reserves the name. The first working release will be0.1.0.
Install
pip install rag-anchor
Use
from rag_anchor import GoogleProvider, MemoryStore, RagAnchor
provider = GoogleProvider() # reads GEMINI_API_KEY
rag = RagAnchor(store=MemoryStore(), embedder=provider, generator=provider)
rag.ingest_directory("notes/")
answer = rag.ask("Where did you work in 2022?")
print(answer.text)
for hit in answer.hits:
print(f" {hit.score:.2f} {hit.chunk.content[:60]}")
Or from the command line:
rag-anchor build notes/ # ingest a directory -> index.json
rag-anchor ask "..." -v # answer, with the score of each excerpt
rag-anchor chunks # see what was actually indexed
Principles
- No web dependency in the core — usable from Django, FastAPI, a cron script or a notebook.
- No infrastructure required — the index can be a plain file; Postgres with pgvector is an option, not a prerequisite.
- Similarity scores are always exposed, so "the information is absent from the corpus" can be told apart from "retrieval missed it".
Development
pip install -e ".[dev]"
pytest
examples/ holds a small demo corpus about a fictional person, which the test
suite runs the whole pipeline against without touching the network.
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 rag_anchor-0.1.0.tar.gz.
File metadata
- Download URL: rag_anchor-0.1.0.tar.gz
- Upload date:
- Size: 52.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
445f613e9645a2c0659286c2da5b024fd8d17a1727fe95a2b4210b5cb94f3006
|
|
| MD5 |
6182fb186130c10c9a96fee14e186f63
|
|
| BLAKE2b-256 |
12bf71daa239236c694728fb27951f12fb0dca50e687d7e474b0dde2bba3a05c
|
File details
Details for the file rag_anchor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rag_anchor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
104a718710911dc94d5ccfdd61ad4d0cb80552e04f77c017a51b8eb955b53190
|
|
| MD5 |
1f433f84191195f074da38fb0fddb93e
|
|
| BLAKE2b-256 |
08fb9f47dbb2ca055ab826e59d1bc6f6f4a3a5824f8d79be3f84a4116d8afcc8
|