Metadata-Version: 2.5
Name: ragmir
Version: 6.12.1
Summary: Cited local retrieval for Python agents and RAG apps: search a project's code, PDFs, and Office files and get passages cited to lines, pages, slides, or cells.
Project-URL: Homepage, https://ragmir.com
Project-URL: Documentation, https://github.com/jcode-works/jcode-ragmir/blob/main/docs/python.md
Project-URL: Repository, https://github.com/jcode-works/jcode-ragmir
Project-URL: Issues, https://github.com/jcode-works/jcode-ragmir/issues
Project-URL: Changelog, https://github.com/jcode-works/jcode-ragmir/releases
Author-email: Jean-Baptiste Thery <jb.thery@jcode.works>
License-Expression: AGPL-3.0-only
License-File: LICENSE
Keywords: agentic-rag,citations,knowledge-base,local-first,mcp,rag,ragmir,retrieval,search
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Text Processing :: Indexing
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: mcp<3,>=2.3
Description-Content-Type: text/markdown

# ragmir

Cited local retrieval for Python agents and RAG apps. [Ragmir](https://github.com/jcode-works/jcode-ragmir)
indexes a project's code, PDFs, Office files, mail, and design files on your machine, and returns
passages cited to lines, pages, slides, cells, or objects. A question the documents cannot answer
returns nothing, so your application can say so instead of guessing.

```bash
pip install ragmir
```

Ragmir runs through Node.js 22.12 or later, or Docker. The client uses the project's own npm
install of `@jcode.labs/ragmir` when there is one, else a global `rgr`, else the matching npm
release through `npx`, else the `ghcr.io/jcode-works/ragmir` image. Set `RAGMIR_COMMAND` to choose
another command.

## Index a project and search it

```python
from ragmir import Ragmir, add_sources, init_project

init_project("my-project")
add_sources("my-project", ["docs/**/*.md", "contracts/**/*.pdf"])

with Ragmir("my-project") as rag:
    rag.ingest()  # incremental: only new and changed files are read again
    for passage in rag.search("termination notice period", top_k=3):
        print(passage.citation, passage.weak_evidence)
        print(passage.text)
```

`Ragmir` keeps one MCP server running for the project and reuses it for every call. It works from
any thread, a notebook, or a web framework, and each method has an async twin (`asearch`,
`aexpand`, `asources`, `astatus`, `aingest`). Asyncio services can use `AsyncRagmir` directly.

- `search(query, top_k=, include_paths=, exclude_paths=, scope=)` returns `Passage` objects with
  `citation`, `path`, `text`, line or page ranges, `weak_evidence`, and `source_status`. Path filters
  take folders, files, or globs such as `"**/*.pdf"`.
- `search_many(queries)` answers up to five related questions in one call.
- `expand(citation, context_radius=1)` returns the passage with its neighbours; expand
  `next_citation` to read a long document through.
- `sources(paths=["contracts/**"])` lists the indexed documents; `status()` and `audit()` report
  readiness and coverage.
- `run_cli(project, "doctor")` runs any `rgr` command, for example an ingest with local OCR, which
  Ragmir leaves to an explicit operator command.

## LangChain and LlamaIndex

- [`langchain-ragmir`](https://pypi.org/project/langchain-ragmir/): a retriever and agent tools.
- [`llama-index-retrievers-ragmir`](https://pypi.org/project/llama-index-retrievers-ragmir/): a
  LlamaIndex retriever.

Read the [Python guide](https://github.com/jcode-works/jcode-ragmir/blob/main/docs/python.md).
Ragmir is open source under AGPL-3.0-only, with a commercial license available from JCode Works.
