Skip to main content

pytest for RAG — evaluate any HTTP RAG endpoint against a JSONL dataset. One config file, one command.

Project description

KnightEval

pytest for RAG. Point it at any HTTP RAG endpoint, give it a JSONL dataset, get a scorecard — in the terminal, as a self-contained HTML report, as JSON, and as a CI-friendly exit code.

Minimal-config RAG evaluation — one config file, one command.

License: Apache 2.0 Python Status: pre-alpha PRs welcome

🚧 Pre-alpha — built in public. The design is locked (DESIGN.md); the code is landing phase by phase (see the roadmap). Nothing is on PyPI yet. Star the repo to follow the first release, or jump into good first issues.


Why

You built a RAG endpoint. Is it any good? Did that prompt change make retrieval worse? Existing tools — Ragas, DeepEval, TruLens, LangSmith — are powerful, but they ask you to learn pipelines, tracing, and experiment abstractions before you get a single number.

KnightEval trades depth for a fast, honest first result:

  • Works against a black-box HTTP endpoint. No SDK, no instrumentation, no code changes to your app. If it answers HTTP, KnightEval can grade it.
  • Honest about what needs a judge. Latency, reliability, exact match, regex, keyword and schema checks run deterministically with zero config. The LLM-graded metrics (faithfulness, hallucination, context precision/recall, answer relevance/correctness) need a judge you configure — and KnightEval tells you loudly why a metric was skipped instead of silently scoring zero.
  • Made for CI. One command, a stable exit code, JUnit XML. Add a RAG quality gate to your pipeline without writing Python.
  • Local-first. No account, no SaaS, no telemetry. Your data leaves your machine only when you configure an external judge.

The idea (target experience)

pip install knighteval

# interactive, endpoint-aware: probes your API, proposes field paths, picks a judge
knighteval init

# run the evaluation
knighteval run --config knighteval.yaml
KnightEval — 100 cases against http://localhost:8000/query

  Metric                Score    Status
  ─────────────────────────────────────
  Faithfulness          91.4%    PASS
  Context Precision     86.2%    PASS
  Context Recall        79.9%    WARN
  Answer Relevance      88.1%    PASS
  Hallucination Rate     3.2%    PASS
  Latency (p95)         820ms    PASS
  Endpoint Reliability  100.0%   PASS
  ─────────────────────────────────────
  Overall               87.6%    PASS      exit 0

  HTML report → runs/2026-07-12T18-30-00/report.html

Deterministic-only (no judge, nothing leaves your machine):

knighteval run --config knighteval.yaml   # latency, reliability, exact_match, regex, keyword...

What you write (the one config file)

# knighteval.yaml
endpoint:
  url: http://localhost:8000/query
  answer_path: data.answer          # dot-path or JSONPath-subset into the response
  contexts_path: data.contexts[*].text
dataset: tests/rag_cases.jsonl
judge:
  provider: openai                  # or openai_compatible, or omit for deterministic-only
  model: gpt-4o-mini
  # api key comes from the environment, never this file
thresholds:
  faithfulness: { warn: 0.8, fail: 0.6 }
  context_recall: { warn: 0.8, fail: 0.6 }

Dataset is JSONL, one case per line:

{"id": "q1", "question": "What is our refund window?", "expected_answer": "30 days", "expected_context": ["Refunds are accepted within 30 days."]}

In CI

knighteval run --config knighteval.yaml --ci --junit results.xml
# exit 0 = pass · 1 = threshold failure · 2 = usage/config error · 3 = endpoint failure · 4 = judge integrity failure

The --ci flag never prompts and never asks for cost confirmation.

How it compares

KnightEval Ragas / DeepEval LangSmith / TruLens
Evaluates a black-box HTTP endpoint ⚠️ needs wiring ⚠️ needs tracing
Zero-config deterministic metrics
Self-contained HTML report (no server) ❌ (hosted)
CI exit codes + JUnit out of the box ⚠️ ⚠️
Local-first, no account
Deep tracing / experiment tracking ❌ (non-goal) ⚠️

KnightEval is not trying to be a platform. If you need tracing, experiment tracking, or a hosted dashboard, reach for the tools above. If you want a number and an HTML report today, start here.

Metrics

Deterministic (zero-config, no network): exact match, token overlap, keyword presence, regex assertion, JSON schema, citation presence, max answer length, latency limit, endpoint reliability.

LLM-judged (needs a configured judge): faithfulness (+ hallucination rate, one shared judge pass), answer relevance, answer correctness (reference-gated), context precision, context recall.

Status & roadmap

Pre-alpha. Build sequence and release milestones are in ROADMAP.md; the full design rationale (schemas, scoring rules, stable contracts) is in DESIGN.md.

Contributing

Early contributors shape the tool. Start with CONTRIBUTING.md and the good first issue label. Be excellent to each other — Code of Conduct.

License

Apache 2.0.

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

knighteval-0.0.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knighteval-0.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file knighteval-0.0.1.tar.gz.

File metadata

  • Download URL: knighteval-0.0.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for knighteval-0.0.1.tar.gz
Algorithm Hash digest
SHA256 804f5a19c8ded5606fe266aeeaa67001a390b3e9e298fea64673ee81f55bc501
MD5 af8ff0987a5fde5293f7557dd51a117f
BLAKE2b-256 f8acecadc4c59442a066642fcd4467653a2455819fc4e7ae8b983ca4e1b40311

See more details on using hashes here.

File details

Details for the file knighteval-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: knighteval-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for knighteval-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d659d4ffdea4ebd5bbeea09f33fedf63db03c10857a7203f385cc6defaa9c30
MD5 c95c95fd8b4d98caf3862577e33f291d
BLAKE2b-256 0674eda802cc946a0c4f90103edf34510bfa2e56793d4e55bcc6059815a21686

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page