dj-evals
Internal Django helper for running one eval function with multiple argument sets in parallel, so you can visually compare output, tool calls, usage, cost, and completion behavior as the runs happen.
Django setup
Add dj_evals to INSTALLED_APPS:
INSTALLED_APPS = [
"dj_evals",
]
Create one view that connects the package to your project. This is the only view required by dj-evals:
from django.contrib.admin.views.decorators import staff_member_required
from dj_evals import handle_eval_request
@staff_member_required
async def eval_run(request):
return await handle_eval_request(
request,
allowed_paths={"myapp.evals.echo_eval"},
# evaluation_model="anthropic/claude-opus-5.5", # Optional.
)
Mount that view in your URL configuration:
from django.urls import path
urlpatterns = [
path("evals/run/", eval_run, name="eval-run"),
]
Replace staff_member_required with your project's authorization check if staff-only access is not appropriate.
Link to eval suites
A project can have a small page that lists its eval suites. Use generate_eval_url() to build the URL behind each link:
from django.contrib.admin.views.decorators import staff_member_required
from django.shortcuts import render
from django.urls import reverse
from dj_evals import generate_eval_url
@staff_member_required
def eval_index(request):
question = (
"Give me 7 tips to improve my game in chess. "
"My ELO is 500. I make lots of blunders."
)
url = reverse("eval-run") + generate_eval_url(
"myapp.evals.echo_eval",
{
"model": "gpt-5.6-terra",
"question": question,
},
{
"model": "gpt-5.6-luna",
"question": question,
},
# Optional. Requires the configured evaluation model's API key.
expectations=[
"Don't leave things hanging",
"Castle early",
"The answer mentions using a checklist",
"The checklist is something simple yet effective",
],
)
return render(
request,
"eval_index.html",
{"eval_suites": [("Chess tips for beginners", url)]},
)
Render those URLs as normal links in eval_index.html:
{% for name, url in eval_suites %}
<a href="{{ url }}">{{ name }}</a>
{% endfor %}
Clicking the link opens the comparison page. Use Run all to start one POST request per argument set and render the streamed results side by side.
Expectations are checked by TypeSafe's Jev, which needs TYPESAFE_API_KEY. Auto-rate uses meta/muse-spark-1.2 with medium reasoning through OpenRouter by default. OpenRouter model IDs (provider/model) use OPENROUTER_API_KEY; direct OpenAI model names use OPENAI_API_KEY.
Expectations and Re-judge
Jev checks each expectation separately and gives the probability that the output meets it; 50% or more passes. It takes about a second and costs a fraction of a cent, but gives no reasons; use Auto-rate for those. The run's status shows the share of expectations passed. Re-judge checks the current expectations against completed outputs without rerunning the evals.
Auto-rate
Auto-rate shows an LLM judge every completed run at once, so it can calibrate against the strongest and weakest answers. For each run it gives feedback and scores out of 10 overall and for correctness, prioritization and readability.
Both judges are importable for batch runs outside the page: run_expectations(output, expectations, question=...) and rate_runs(outputs, expectations, question=...).
Eval function contract
The eval function must be importable by dotted path and whitelisted in allowed_paths. It can be a sync or async function that returns one event, or an async generator that yields events.
def echo_eval(question="hello", model=""):
return question
async def async_eval(question="hello", model=""):
return question
async def streaming_eval(question="hello"):
yield {"type": "response.output_text.delta", "delta": question}
yield {"type": "response.output_text.done", "text": question}
yield {"type": "response.completed", "response": {"cost": 0}}
Eval argument dictionaries are passed to the eval function as keyword arguments. OpenAI Responses API events have first-class rendering for output text, reasoning, and tool calls.
Helper utilities
Split eval arguments
split_eval_arguments() separates arguments shared by every run from the arguments that differ:
from dj_evals import split_eval_arguments
common, different = split_eval_arguments(
{"company": "Avantel", "model": "fast"},
{"company": "Avantel", "model": "expert"},
)
Here, common is {"company": "Avantel"} and different contains the two model arguments.
Progress messages
You can yield EvalEvent for custom progress messages in the output panel:
from dj_evals import EvalEvent
async def streaming_eval():
event: EvalEvent = {
"type": "dj_evals.event",
"message": "Fetched documents",
}
yield event
Developers
Run a local demo server to try the library in a browser:
uv run --with daphne daphne -p 8003 examples.local_server:application
# or, if you have just installed:
just run
Then open http://127.0.0.1:8003/ and choose an example. The OpenAI example uses OPENAI_API_KEY; expectations use OPENROUTER_API_KEY.
Run checks from this repo:
uv run --with ruff ruff check .
uv run --with pytest --with pytest-asyncio pytest -q
# or, if you have just installed:
just test
Metadata
Release files for dj-evals 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dj_evals-0.11.0.tar.gz | 107.0 kB | Without provenance | Details for dj_evals-0.11.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dj_evals-0.11.0-py3-none-any.whl | Python 3 | none | any | Details for dj_evals-0.11.0-py3-none-any.whl |
Total release size: 207.2 kB
Release files / dj_evals-0.11.0.tar.gz
| Download URL | dj_evals-0.11.0.tar.gz |
|---|---|
| Size | 107.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ca855a5924c35f4c8451283ebd20130f7f0b30395070957825dfe1421e7e71c
|
|
BLAKE2b-256 checksum How to use checksums |
b11660be223ec99a5295becf3406f757a35b6deff047c5e18f95a2a8742eedad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / dj_evals-0.11.0-py3-none-any.whl
| Download URL | dj_evals-0.11.0-py3-none-any.whl |
|---|---|
| Size | 100.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03859b5f740d024719e8fbf7b73ee7389d225433494af056f95161827c641856
|
|
BLAKE2b-256 checksum How to use checksums |
04d34f22989029590af3676f591dce0bfc651d919019198a2dfad1732e22658d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for dj-evals 0.11.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.