Skip to main content

Internal Django SSE eval runner

Project description

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 and mount your eval view:

INSTALLED_APPS = [
    "dj_evals",
]
from django.urls import path

urlpatterns = [
    path("evals/run/", eval_run),
]

Protect the eval view with your app's normal authorization checks before using it in production.

Usage

from dj_evals import handle_eval_request

async def eval_run(request):
    return await handle_eval_request(
        request,
        allowed_paths={"myapp.evals.echo_eval"},
    )

Generate a URL for the view with one or more eval argument dictionaries:

from dj_evals import generate_eval_url

url = "/evals/run/" + generate_eval_url(
    "myapp.evals.echo_eval",
    {"model": "gpt-4.1", "text": "hello"},
    {"model": "gemini-3-flash-preview", "text": "hello"},
)

The GET request renders the comparison page. The page starts one POST request per argument set. Each POST response is a direct SSE stream from the eval run, and the browser renders those events into the comparison panels.

Eval function contract

The eval function must be importable by dotted path, whitelisted in allowed_paths, and must be an async generator.

async def echo_eval(text="hello", model=""):
    yield {"type": "response.output_text.delta", "delta": text}
    yield {"type": "response.completed", "response": {"cost": 0}}

Eval argument dictionaries are passed to the eval function as keyword arguments.

Developers

Run a local demo server to try the library in a browser:

uv run --with daphne daphne examples.local_server:application
# or, if you have just installed:
just run

Then open http://127.0.0.1:8000/. The demo redirects to an eval URL that starts three argument sets side by side and streams their events over SSE.

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

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

dj_evals-0.2.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

dj_evals-0.2.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file dj_evals-0.2.0.tar.gz.

File metadata

  • Download URL: dj_evals-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","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}

File hashes

Hashes for dj_evals-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6cda6a5a3b7e4b7918518211690ba7e79217c200426fa39b9472bf65a41b0d62
MD5 6baa164f5ff16d710c32c62ea0bb3329
BLAKE2b-256 2744ebff1e570b1b3a108aa863087fd6d8827004ed37ec2acd466b8df90194a5

See more details on using hashes here.

File details

Details for the file dj_evals-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dj_evals-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","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}

File hashes

Hashes for dj_evals-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb53c624142f36792b5c918df099fa7124e76fa3a470f3275e0f5168c5029478
MD5 45a9e0e8f83a4b2aa42453528bcdadd0
BLAKE2b-256 9ba384021b7c7bfe5c2d0b8b6eaedba3c395a5cfbc7549e3af1d92f0e729eeb8

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