Skip to main content

RagSentry — pytest for RAG

Regression testing and evaluation CLI for Retrieval-Augmented Generation (RAG) systems.

RagSentry connects to your RAG application through a thin adapter, evaluates retrieved contexts and generated answers against your dataset, tracks runs over time, diffs runs to catch regressions, and gates CI builds.


🚀 Quickstart in 5 Minutes

1. Install RagSentry

pip install ragsentry

(Optional PostgreSQL storage support: pip install ragsentry[postgres])


2. Initialize RagSentry in your project

ragsentry init

This scaffolds:

  • ragsentry_adapter.py — starter adapter stub
  • evalset.jsonl — starter evaluation set

3. Connect your RAG application

Edit ragsentry_adapter.py to call your RAG pipeline and return the required contract:

from my_rag_app import ask_rag

def query(question: str) -> dict:
    result = ask_rag(question)
    return {
        "answer": result["answer"],
        "contexts": result["contexts"],  # list[str] of retrieved passages
    }

4. Run an Evaluation

Unscored Generation Pass (No LLM required):

ragsentry run -e evalset.jsonl -a ragsentry_adapter:query --no-scoring

Full Evaluation with LLM Judge:

ragsentry run -e evalset.jsonl -a ragsentry_adapter:query -p openrouter -m openai/gpt-oss-120b

5. Diff Runs & Gate CI

Diff two evaluation runs:

ragsentry diff run_2026-09-27T10-00-00_a1b2c3d4.json run_2026-09-27T11-00-00_e5f6g7h8.json

Quality Gate in CI (Exit code 0 on pass, non-zero on failure):

ragsentry ci \
  --candidate <candidate_run_id> \
  --baseline <baseline_run_id> \
  -t faithfulness=0.80 \
  -t context_recall=0.85 \
  --max-regressed-questions 1 \
  --pr-comment-out pr_comment.md

⚡ Key Features

  • 🔌 Plug-and-Play Adapters: Supports Python callables (pkg.mod:func), REST APIs (http://localhost:8000/query), or CLI tools (shell:python rag_cli.py).
  • 🤖 Provider-Agnostic Judge Scoring: Works with OpenAI, Anthropic, Gemini, Groq, xAI, Ollama, DeepSeek, OpenRouter, or custom OpenAI-compatible endpoints.
  • 💾 Dual Storage Backends: Local JSON file store or PostgreSQL (--storage postgresql://...).
  • 📊 Rich Terminal Diffs: Colorized diff tables highlighting improved, regressed, and unchanged questions per metric.
  • 🚦 CI Quality Gates: Strict threshold enforcement and regression limits with exportable GitHub PR Markdown summaries.
  • 🧩 Agent-Usable Scaffolder Skill: Includes skills/adapter-scaffolder so AI coding assistants can inspect unfamiliar RAG repos and scaffold adapters automatically.

📖 Documentation & Guides


📜 License

MIT License.

Metadata

Release files for ragsentry 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ragsentry 0.1.2
File Size Uploaded
ragsentry-0.1.2.tar.gz 22.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ragsentry 0.1.2
File Interpreter ABI Platform
ragsentry-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 51.0 kB

Release files / ragsentry-0.1.2.tar.gz

Download URL ragsentry-0.1.2.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
685aff219edadb443b076670932c7c760ae2ff0b2632dc7b3086eeceb669db95
BLAKE2b-256 checksum
How to use checksums
bf93cc2a9b58d324ef8048c30771f82fe2c5e3c2cd9568a641429915019dfe79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / ragsentry-0.1.2-py3-none-any.whl

Download URL ragsentry-0.1.2-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3642382028e74cb2c763f69a5f39fb6898b2debab4bd0e0c8b1284f3876e01c9
BLAKE2b-256 checksum
How to use checksums
3029dce03b73f59efab6fc22ca0ca66340b558f91e3da3266a5432573e0cf88e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page