Metadata-Version: 2.4
Name: rag-anchor
Version: 0.1.0
Summary: Portable RAG for Python projects: ingestion, vector search and sourced answers, with no imposed infrastructure.
Project-URL: Repository, https://github.com/cylb0/rag-anchor
Author-email: Morgan Foucaut <foucaut.morgan@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: embeddings,gemini,llm,pgvector,rag,retrieval
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: google-genai<3,>=2
Requires-Dist: numpy>=1.24
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: python-dotenv>=1; extra == 'dev'
Description-Content-Type: text/markdown

# 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 be `0.1.0`.

## Install

```bash
pip install rag-anchor
```

## Use

```python
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:

```bash
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

```bash
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.
