diffscore 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffscore-0.1.0/.dockerignore +13 -0
- diffscore-0.1.0/.env.example +42 -0
- diffscore-0.1.0/.github/workflows/ci.yml +40 -0
- diffscore-0.1.0/.github/workflows/publish.yml +57 -0
- diffscore-0.1.0/.gitignore +36 -0
- diffscore-0.1.0/.python-version +1 -0
- diffscore-0.1.0/Dockerfile +28 -0
- diffscore-0.1.0/LICENSE +21 -0
- diffscore-0.1.0/PKG-INFO +351 -0
- diffscore-0.1.0/README.md +302 -0
- diffscore-0.1.0/RELEASING.md +42 -0
- diffscore-0.1.0/TRADEMARK.md +52 -0
- diffscore-0.1.0/alembic.ini +159 -0
- diffscore-0.1.0/brand/README.md +61 -0
- diffscore-0.1.0/brand/head-snippet.html +21 -0
- diffscore-0.1.0/brand/icons/github-avatar-460.png +0 -0
- diffscore-0.1.0/brand/svg/favicon.svg +1 -0
- diffscore-0.1.0/brand/svg/lockup-dark.svg +1 -0
- diffscore-0.1.0/brand/svg/lockup-light.svg +1 -0
- diffscore-0.1.0/brand/svg/mark-dark.svg +1 -0
- diffscore-0.1.0/brand/svg/mark.svg +1 -0
- diffscore-0.1.0/brand/svg/og-image.svg +1 -0
- diffscore-0.1.0/docker-compose.yml +62 -0
- diffscore-0.1.0/docs/diffscore-build-spec.md +328 -0
- diffscore-0.1.0/docs/diffscore-roadmap.md +238 -0
- diffscore-0.1.0/docs/how_it_works.md +260 -0
- diffscore-0.1.0/docs/ui-design-language.md +481 -0
- diffscore-0.1.0/examples/prompts/support.md +22 -0
- diffscore-0.1.0/examples/reference/larkspur-policy.md +16 -0
- diffscore-0.1.0/examples/support.yaml +302 -0
- diffscore-0.1.0/examples/tallyloop/README.md +37 -0
- diffscore-0.1.0/examples/tallyloop/help-assistant.yaml +273 -0
- diffscore-0.1.0/examples/tallyloop/prompts/help-assistant.md +12 -0
- diffscore-0.1.0/examples/tallyloop/prompts/help-assistant.v1.md +11 -0
- diffscore-0.1.0/examples/tallyloop/prompts/ticket-triage.md +23 -0
- diffscore-0.1.0/examples/tallyloop/ticket-triage.yaml +254 -0
- diffscore-0.1.0/pyproject.toml +119 -0
- diffscore-0.1.0/src/diffscore/__init__.py +3 -0
- diffscore-0.1.0/src/diffscore/api.py +729 -0
- diffscore-0.1.0/src/diffscore/calibration.py +374 -0
- diffscore-0.1.0/src/diffscore/cli.py +867 -0
- diffscore-0.1.0/src/diffscore/config.py +88 -0
- diffscore-0.1.0/src/diffscore/db/__init__.py +27 -0
- diffscore-0.1.0/src/diffscore/db/base.py +25 -0
- diffscore-0.1.0/src/diffscore/db/migrate.py +61 -0
- diffscore-0.1.0/src/diffscore/db/models.py +257 -0
- diffscore-0.1.0/src/diffscore/db/session.py +37 -0
- diffscore-0.1.0/src/diffscore/diffing.py +292 -0
- diffscore-0.1.0/src/diffscore/graders.py +281 -0
- diffscore-0.1.0/src/diffscore/jobs.py +161 -0
- diffscore-0.1.0/src/diffscore/judge.py +355 -0
- diffscore-0.1.0/src/diffscore/labeling.py +167 -0
- diffscore-0.1.0/src/diffscore/llm.py +120 -0
- diffscore-0.1.0/src/diffscore/migrations/README +1 -0
- diffscore-0.1.0/src/diffscore/migrations/env.py +84 -0
- diffscore-0.1.0/src/diffscore/migrations/script.py.mako +28 -0
- diffscore-0.1.0/src/diffscore/migrations/versions/2026_11_30-03d94780829e_run_error_and_cache_latency.py +34 -0
- diffscore-0.1.0/src/diffscore/migrations/versions/2026_11_30-8c8961902e49_run_spend.py +34 -0
- diffscore-0.1.0/src/diffscore/migrations/versions/2026_11_30-da2445f19a6c_initial_schema.py +280 -0
- diffscore-0.1.0/src/diffscore/migrations/versions/2026_12_01-053ee29c31c6_run_case_keys.py +55 -0
- diffscore-0.1.0/src/diffscore/migrations/versions/2026_12_01-9dc97334c9d9_judge_calibration.py +69 -0
- diffscore-0.1.0/src/diffscore/migrations/versions/2026_12_01-a85ad738bd12_run_provider_keys.py +32 -0
- diffscore-0.1.0/src/diffscore/queries.py +165 -0
- diffscore-0.1.0/src/diffscore/runner.py +393 -0
- diffscore-0.1.0/src/diffscore/secrets.py +130 -0
- diffscore-0.1.0/src/diffscore/stats.py +83 -0
- diffscore-0.1.0/src/diffscore/suite.py +329 -0
- diffscore-0.1.0/src/diffscore/templates/env.example +14 -0
- diffscore-0.1.0/src/diffscore/templates/example-prompt.md +14 -0
- diffscore-0.1.0/src/diffscore/templates/example.yaml +75 -0
- diffscore-0.1.0/tests/conftest.py +37 -0
- diffscore-0.1.0/tests/test_api.py +286 -0
- diffscore-0.1.0/tests/test_calibration.py +250 -0
- diffscore-0.1.0/tests/test_cli_label.py +62 -0
- diffscore-0.1.0/tests/test_config.py +28 -0
- diffscore-0.1.0/tests/test_diffing.py +163 -0
- diffscore-0.1.0/tests/test_graders.py +118 -0
- diffscore-0.1.0/tests/test_init_sqlite.py +93 -0
- diffscore-0.1.0/tests/test_judge.py +227 -0
- diffscore-0.1.0/tests/test_llm.py +73 -0
- diffscore-0.1.0/tests/test_models.py +96 -0
- diffscore-0.1.0/tests/test_runner.py +168 -0
- diffscore-0.1.0/tests/test_secrets_jobs.py +119 -0
- diffscore-0.1.0/tests/test_stats.py +61 -0
- diffscore-0.1.0/tests/test_suite.py +130 -0
- diffscore-0.1.0/uv.lock +3784 -0
- diffscore-0.1.0/web/.gitignore +44 -0
- diffscore-0.1.0/web/README.md +44 -0
- diffscore-0.1.0/web/components.json +25 -0
- diffscore-0.1.0/web/eslint.config.mjs +25 -0
- diffscore-0.1.0/web/next.config.ts +7 -0
- diffscore-0.1.0/web/package-lock.json +17495 -0
- diffscore-0.1.0/web/package.json +36 -0
- diffscore-0.1.0/web/postcss.config.mjs +5 -0
- diffscore-0.1.0/web/public/favicon.ico +0 -0
- diffscore-0.1.0/web/public/icons/apple-touch-icon.png +0 -0
- diffscore-0.1.0/web/public/icons/favicon-16x16.png +0 -0
- diffscore-0.1.0/web/public/icons/favicon-32x32.png +0 -0
- diffscore-0.1.0/web/public/icons/favicon-48x48.png +0 -0
- diffscore-0.1.0/web/public/icons/favicon-96x96.png +0 -0
- diffscore-0.1.0/web/public/icons/favicon.ico +0 -0
- diffscore-0.1.0/web/public/icons/github-avatar-460.png +0 -0
- diffscore-0.1.0/web/public/icons/icon-192.png +0 -0
- diffscore-0.1.0/web/public/icons/icon-512.png +0 -0
- diffscore-0.1.0/web/public/icons/icon-maskable-512.png +0 -0
- diffscore-0.1.0/web/public/icons/icon-rounded-512.png +0 -0
- diffscore-0.1.0/web/public/logo/lockup-dark.png +0 -0
- diffscore-0.1.0/web/public/logo/lockup-dark@2x.png +0 -0
- diffscore-0.1.0/web/public/logo/lockup-light.png +0 -0
- diffscore-0.1.0/web/public/logo/lockup-light@2x.png +0 -0
- diffscore-0.1.0/web/public/logo/mark-256.png +0 -0
- diffscore-0.1.0/web/public/logo/mark-512.png +0 -0
- diffscore-0.1.0/web/public/logo/mark-dark-512.png +0 -0
- diffscore-0.1.0/web/public/site.webmanifest +14 -0
- diffscore-0.1.0/web/public/social/og-image-dark.png +0 -0
- diffscore-0.1.0/web/public/social/og-image.png +0 -0
- diffscore-0.1.0/web/public/social/twitter-card.png +0 -0
- diffscore-0.1.0/web/public/svg/favicon.svg +1 -0
- diffscore-0.1.0/web/public/svg/lockup-dark.svg +1 -0
- diffscore-0.1.0/web/public/svg/lockup-light.svg +1 -0
- diffscore-0.1.0/web/public/svg/mark-dark.svg +1 -0
- diffscore-0.1.0/web/public/svg/mark.svg +1 -0
- diffscore-0.1.0/web/public/svg/og-image.svg +1 -0
- diffscore-0.1.0/web/src/app/(app)/diff/page.tsx +14 -0
- diffscore-0.1.0/web/src/app/(app)/layout.tsx +20 -0
- diffscore-0.1.0/web/src/app/(app)/runs/[id]/page.tsx +17 -0
- diffscore-0.1.0/web/src/app/(app)/runs/page.tsx +8 -0
- diffscore-0.1.0/web/src/app/(legal)/layout.tsx +18 -0
- diffscore-0.1.0/web/src/app/(legal)/privacy/page.tsx +123 -0
- diffscore-0.1.0/web/src/app/(legal)/terms/page.tsx +141 -0
- diffscore-0.1.0/web/src/app/globals.css +471 -0
- diffscore-0.1.0/web/src/app/layout.tsx +130 -0
- diffscore-0.1.0/web/src/app/page.tsx +29 -0
- diffscore-0.1.0/web/src/app/robots.ts +10 -0
- diffscore-0.1.0/web/src/app/sitemap.ts +27 -0
- diffscore-0.1.0/web/src/components/app/diff-view.tsx +150 -0
- diffscore-0.1.0/web/src/components/app/parts.tsx +250 -0
- diffscore-0.1.0/web/src/components/app/run-view.tsx +303 -0
- diffscore-0.1.0/web/src/components/app/runs-view.tsx +296 -0
- diffscore-0.1.0/web/src/components/copy-button.tsx +76 -0
- diffscore-0.1.0/web/src/components/icons.tsx +15 -0
- diffscore-0.1.0/web/src/components/legal.tsx +79 -0
- diffscore-0.1.0/web/src/components/logo.tsx +81 -0
- diffscore-0.1.0/web/src/components/primitives.tsx +244 -0
- diffscore-0.1.0/web/src/components/query-provider.tsx +16 -0
- diffscore-0.1.0/web/src/components/sections/grader-ladder.tsx +93 -0
- diffscore-0.1.0/web/src/components/sections/hero.tsx +114 -0
- diffscore-0.1.0/web/src/components/sections/how-it-works.tsx +198 -0
- diffscore-0.1.0/web/src/components/sections/install.tsx +82 -0
- diffscore-0.1.0/web/src/components/sections/judge-trust.tsx +248 -0
- diffscore-0.1.0/web/src/components/sections/non-goals.tsx +29 -0
- diffscore-0.1.0/web/src/components/sections/run-diff.tsx +233 -0
- diffscore-0.1.0/web/src/components/sections/significance.tsx +158 -0
- diffscore-0.1.0/web/src/components/site-footer.tsx +91 -0
- diffscore-0.1.0/web/src/components/site-header.tsx +97 -0
- diffscore-0.1.0/web/src/components/structured-data.tsx +59 -0
- diffscore-0.1.0/web/src/components/theme-provider.tsx +11 -0
- diffscore-0.1.0/web/src/components/theme-toggle.tsx +51 -0
- diffscore-0.1.0/web/src/components/ui/accordion.tsx +80 -0
- diffscore-0.1.0/web/src/components/ui/badge.tsx +48 -0
- diffscore-0.1.0/web/src/components/ui/button.tsx +66 -0
- diffscore-0.1.0/web/src/components/ui/card.tsx +102 -0
- diffscore-0.1.0/web/src/components/ui/separator.tsx +27 -0
- diffscore-0.1.0/web/src/components/ui/table.tsx +115 -0
- diffscore-0.1.0/web/src/components/ui/tooltip.tsx +56 -0
- diffscore-0.1.0/web/src/lib/api.ts +227 -0
- diffscore-0.1.0/web/src/lib/sample-data.ts +200 -0
- diffscore-0.1.0/web/src/lib/site.ts +43 -0
- diffscore-0.1.0/web/src/lib/utils.ts +1 -0
- diffscore-0.1.0/web/tsconfig.json +27 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Copy to .env and fill in only what you use. .env is git-ignored.
|
|
2
|
+
|
|
3
|
+
# Core
|
|
4
|
+
# Default: a SQLite file at .diffscore/diffscore.db (no setup). For Postgres
|
|
5
|
+
# (the API, or docker compose up -d), set:
|
|
6
|
+
# DATABASE_URL=postgresql+psycopg://diffscore:diffscore@localhost:5432/diffscore
|
|
7
|
+
REDIS_URL=redis://localhost:6379/0
|
|
8
|
+
SECRET_KEY= # app signing
|
|
9
|
+
FERNET_KEY= # encrypts users' provider keys at rest (Phase 5)
|
|
10
|
+
API_KEY= # the single v1 auth token
|
|
11
|
+
|
|
12
|
+
# Model providers (only the ones you actually use)
|
|
13
|
+
OPENROUTER_API_KEY=
|
|
14
|
+
GEMINI_API_KEY=
|
|
15
|
+
GROQ_API_KEY=
|
|
16
|
+
OPENAI_API_KEY=
|
|
17
|
+
ANTHROPIC_API_KEY=
|
|
18
|
+
OLLAMA_BASE_URL=http://localhost:11434
|
|
19
|
+
|
|
20
|
+
# Default model for `diffscore smoke` (any LiteLLM model string)
|
|
21
|
+
DEFAULT_MODEL=gemini/gemini-3.5-flash-lite
|
|
22
|
+
# Model for the LLM judge; never the same as the model under test.
|
|
23
|
+
# gemini-3.6-flash is stronger but its free tier allows only 20 requests a day.
|
|
24
|
+
JUDGE_MODEL=gemini/gemini-3.1-flash-lite
|
|
25
|
+
JUDGE_RPM= # judge calls per minute, if it differs from MODEL_RPM
|
|
26
|
+
|
|
27
|
+
# Guardrails
|
|
28
|
+
MAX_TOKENS_PER_RUN=500000
|
|
29
|
+
MAX_CASES_ANONYMOUS=25
|
|
30
|
+
MODEL_RPM= # max model calls per minute; 14 suits Gemini's free tier
|
|
31
|
+
|
|
32
|
+
# API and queue
|
|
33
|
+
QUEUE_SYNC=false # true: run jobs inside the API process (no worker needed)
|
|
34
|
+
CORS_ORIGINS=http://localhost:3000,https://diffscore.space
|
|
35
|
+
PUBLIC_PROJECTS=sample,playground # readable without API_KEY
|
|
36
|
+
SAMPLES_DIR=examples
|
|
37
|
+
ANON_RUNS_PER_HOUR=10
|
|
38
|
+
TRUST_PROXY=false
|
|
39
|
+
|
|
40
|
+
# Ops
|
|
41
|
+
SENTRY_DSN=
|
|
42
|
+
PUBLIC_BASE_URL=https://diffscore.space
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, dev]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
python:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: astral-sh/setup-uv@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- run: uv sync --all-extras --frozen
|
|
20
|
+
- run: uv run ruff check .
|
|
21
|
+
- run: uv run ruff format --check .
|
|
22
|
+
- run: uv run mypy
|
|
23
|
+
- run: uv run pytest
|
|
24
|
+
|
|
25
|
+
web:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
defaults:
|
|
28
|
+
run:
|
|
29
|
+
working-directory: web
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: actions/setup-node@v4
|
|
33
|
+
with:
|
|
34
|
+
node-version: 22
|
|
35
|
+
cache: npm
|
|
36
|
+
cache-dependency-path: web/package-lock.json
|
|
37
|
+
- run: npm ci
|
|
38
|
+
- run: npx tsc --noEmit
|
|
39
|
+
- run: npm run lint
|
|
40
|
+
- run: npm run build
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Publishes to PyPI when a GitHub Release is published (tag v0.1.0 -> version 0.1.0).
|
|
2
|
+
#
|
|
3
|
+
# Uses PyPI Trusted Publishing: no token is stored anywhere. One-time setup on
|
|
4
|
+
# pypi.org -> Your account -> Publishing -> "Add a new pending publisher":
|
|
5
|
+
# PyPI project name: diffscore Owner: tejhagargi9 Repository: Diffscore
|
|
6
|
+
# Workflow name: publish.yml Environment name: pypi
|
|
7
|
+
name: publish
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
release:
|
|
11
|
+
types: [published]
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.12"
|
|
24
|
+
- name: Tag must match the package version
|
|
25
|
+
run: |
|
|
26
|
+
version=$(uv run --no-project python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
27
|
+
tag="${GITHUB_REF_NAME#v}"
|
|
28
|
+
echo "package $version, tag $tag"
|
|
29
|
+
test "$version" = "$tag"
|
|
30
|
+
- run: uv build
|
|
31
|
+
- name: Smoke-test the wheel in a clean environment
|
|
32
|
+
run: |
|
|
33
|
+
uv venv /tmp/smoke
|
|
34
|
+
uv pip install --python /tmp/smoke dist/*.whl
|
|
35
|
+
cd "$(mktemp -d)"
|
|
36
|
+
/tmp/smoke/bin/diffscore init
|
|
37
|
+
/tmp/smoke/bin/diffscore validate evals/example.yaml
|
|
38
|
+
/tmp/smoke/bin/diffscore runs
|
|
39
|
+
- uses: actions/upload-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: dist
|
|
42
|
+
path: dist/
|
|
43
|
+
|
|
44
|
+
pypi:
|
|
45
|
+
needs: build
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
environment:
|
|
48
|
+
name: pypi
|
|
49
|
+
url: https://pypi.org/p/diffscore
|
|
50
|
+
permissions:
|
|
51
|
+
id-token: write
|
|
52
|
+
steps:
|
|
53
|
+
- uses: actions/download-artifact@v4
|
|
54
|
+
with:
|
|
55
|
+
name: dist
|
|
56
|
+
path: dist/
|
|
57
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
venv/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.ruff_cache/
|
|
9
|
+
.mypy_cache/
|
|
10
|
+
dist/
|
|
11
|
+
build/
|
|
12
|
+
|
|
13
|
+
# Node
|
|
14
|
+
node_modules/
|
|
15
|
+
.next/
|
|
16
|
+
out/
|
|
17
|
+
*.tsbuildinfo
|
|
18
|
+
|
|
19
|
+
# Env / secrets
|
|
20
|
+
.env
|
|
21
|
+
.env.*
|
|
22
|
+
!.env.example
|
|
23
|
+
|
|
24
|
+
# Editors / OS
|
|
25
|
+
.vscode/
|
|
26
|
+
.idea/
|
|
27
|
+
.DS_Store
|
|
28
|
+
Thumbs.db
|
|
29
|
+
|
|
30
|
+
# Local data
|
|
31
|
+
.diffscore/
|
|
32
|
+
*.db
|
|
33
|
+
*.sqlite3
|
|
34
|
+
|
|
35
|
+
# Brand kit source archive (contents live in brand/ and web/public/)
|
|
36
|
+
diffscore-brand.zip
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# One image for the API and the queue worker.
|
|
2
|
+
# docker compose up -d # postgres, redis, api, worker
|
|
3
|
+
FROM python:3.12-slim
|
|
4
|
+
|
|
5
|
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
6
|
+
PYTHONUNBUFFERED=1 \
|
|
7
|
+
UV_COMPILE_BYTECODE=1 \
|
|
8
|
+
UV_LINK_MODE=copy \
|
|
9
|
+
UV_PROJECT_ENVIRONMENT=/opt/venv \
|
|
10
|
+
PATH="/opt/venv/bin:$PATH"
|
|
11
|
+
|
|
12
|
+
COPY --from=ghcr.io/astral-sh/uv:0.13.10 /uv /usr/local/bin/uv
|
|
13
|
+
|
|
14
|
+
WORKDIR /app
|
|
15
|
+
|
|
16
|
+
# Dependencies first, so code changes don't reinstall them.
|
|
17
|
+
COPY pyproject.toml uv.lock README.md LICENSE ./
|
|
18
|
+
RUN uv sync --frozen --no-dev --extra server --no-install-project
|
|
19
|
+
|
|
20
|
+
COPY src ./src
|
|
21
|
+
COPY examples ./examples
|
|
22
|
+
RUN uv sync --frozen --no-dev --extra server
|
|
23
|
+
|
|
24
|
+
RUN useradd --create-home --uid 10001 diffscore
|
|
25
|
+
USER diffscore
|
|
26
|
+
|
|
27
|
+
EXPOSE 8000
|
|
28
|
+
CMD ["uvicorn", "diffscore.api:app", "--host", "0.0.0.0", "--port", "8000"]
|
diffscore-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tej Hagargi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
diffscore-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: diffscore
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pre-deploy regression tests for LLM prompts, with scoring you can verify.
|
|
5
|
+
Project-URL: Homepage, https://diffscore.space
|
|
6
|
+
Project-URL: Documentation, https://github.com/tejhagargi9/Diffscore#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/tejhagargi9/Diffscore
|
|
8
|
+
Project-URL: Issues, https://github.com/tejhagargi9/Diffscore/issues
|
|
9
|
+
Author: Tej Hagargi
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ci,cohens-kappa,evals,evaluation,llm,llm-as-judge,mcnemar,prompt engineering,rag,regression testing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Classifier: Topic :: Software Development :: Testing
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.12
|
|
25
|
+
Requires-Dist: alembic>=1.13
|
|
26
|
+
Requires-Dist: jsonschema>=4.18
|
|
27
|
+
Requires-Dist: litellm>=1.50
|
|
28
|
+
Requires-Dist: numpy>=1.26
|
|
29
|
+
Requires-Dist: pydantic-settings>=2.4
|
|
30
|
+
Requires-Dist: pydantic>=2.8
|
|
31
|
+
Requires-Dist: pyyaml>=6.0
|
|
32
|
+
Requires-Dist: rich>=13.7
|
|
33
|
+
Requires-Dist: scikit-learn>=1.3
|
|
34
|
+
Requires-Dist: sqlalchemy>=2.0.30
|
|
35
|
+
Requires-Dist: statsmodels>=0.14
|
|
36
|
+
Requires-Dist: tenacity>=8.2
|
|
37
|
+
Requires-Dist: typer>=0.12
|
|
38
|
+
Provides-Extra: postgres
|
|
39
|
+
Requires-Dist: psycopg[binary]>=3.2; extra == 'postgres'
|
|
40
|
+
Provides-Extra: server
|
|
41
|
+
Requires-Dist: cryptography>=42; extra == 'server'
|
|
42
|
+
Requires-Dist: fastapi>=0.115; extra == 'server'
|
|
43
|
+
Requires-Dist: psycopg[binary]>=3.2; extra == 'server'
|
|
44
|
+
Requires-Dist: redis>=5.0; extra == 'server'
|
|
45
|
+
Requires-Dist: rq>=3.0; extra == 'server'
|
|
46
|
+
Requires-Dist: sentry-sdk>=2.0; extra == 'server'
|
|
47
|
+
Requires-Dist: uvicorn[standard]>=0.30; extra == 'server'
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
<p>
|
|
51
|
+
<img src="https://raw.githubusercontent.com/tejhagargi9/Diffscore/main/web/public/logo/lockup-light@2x.png" alt="Diffscore" width="280">
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
**Pre-deploy regression tests for LLM prompts, with scoring you can verify.**
|
|
55
|
+
|
|
56
|
+
[diffscore.space](https://diffscore.space) · Python 3.12 · FastAPI · Next.js 15
|
|
57
|
+
|
|
58
|
+
> **Status: pre-alpha.** Phases 0–5 are built: the landing page, a CLI that
|
|
59
|
+
> runs a suite with cached model calls, a diff with a p-value that gates CI,
|
|
60
|
+
> an LLM judge with calibration tooling, and an HTTP API, queue worker and web
|
|
61
|
+
> screens. Not deployed yet, and the judge's kappa is not published: it needs a
|
|
62
|
+
> hand-labelled gold set first. See the [roadmap](https://github.com/tejhagargi9/Diffscore/blob/main/docs/diffscore-roadmap.md).
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## The problem
|
|
67
|
+
|
|
68
|
+
You ship an LLM feature. You tweak the system prompt, swap a model, change the
|
|
69
|
+
chunk size — and you verify it by eyeballing three examples in a playground. You
|
|
70
|
+
have no idea what broke everywhere else.
|
|
71
|
+
|
|
72
|
+
Diffscore answers one question: **did my prompt change make this better or worse?**
|
|
73
|
+
|
|
74
|
+
## The workflow
|
|
75
|
+
|
|
76
|
+
1. **Define a suite** — inputs plus what good looks like, as a CSV upload or a YAML file.
|
|
77
|
+
2. **Run it** against a prompt version and a model.
|
|
78
|
+
3. **Read the diff** against the previous run — which cases improved, which regressed, and why.
|
|
79
|
+
|
|
80
|
+
If you can do those three steps in under five minutes with your own API key, the
|
|
81
|
+
product works.
|
|
82
|
+
|
|
83
|
+
**Not in v1:** no prompt playground, no production request tracing, no
|
|
84
|
+
fine-tuning, no team accounts.
|
|
85
|
+
|
|
86
|
+
## Quick start
|
|
87
|
+
|
|
88
|
+
Python 3.12 or newer, and an API key for any model provider (Gemini has a free tier).
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install diffscore
|
|
92
|
+
diffscore init # writes evals/example.yaml, its prompt, and a .env
|
|
93
|
+
# put your key in .env, e.g. GEMINI_API_KEY=...
|
|
94
|
+
diffscore run evals/example.yaml # the first run becomes the baseline
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Now edit `evals/prompts/example.md` the way you'd really change a prompt, and run
|
|
98
|
+
it again. Diffscore re-asks only what changed (everything else comes from its
|
|
99
|
+
cache) and tells you whether the change made things better, worse, or made no
|
|
100
|
+
real difference:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
diffscore run evals/example.yaml
|
|
104
|
+
diffscore show <run-id> --failed --outputs # what failed, with the model's answers
|
|
105
|
+
diffscore runs # history
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
No database to set up: results and the response cache live in
|
|
109
|
+
`.diffscore/diffscore.db` beside your project. Add `.diffscore/` and `.env` to
|
|
110
|
+
your `.gitignore`. `--rpm 14` (or `MODEL_RPM=14`) keeps under Gemini's free-tier
|
|
111
|
+
limit of 15 requests a minute, and `--model` swaps in any
|
|
112
|
+
[LiteLLM model](https://docs.litellm.ai/docs/providers).
|
|
113
|
+
|
|
114
|
+
A suite is a YAML file: a prompt, a model, and cases with graders.
|
|
115
|
+
`diffscore validate <file>` checks one without running it. Graders:
|
|
116
|
+
`equals`, `contains`, `not_contains`, `regex`, `json_schema`, `max_latency_ms`,
|
|
117
|
+
`max_cost`, and `judge` (an LLM with a rubric; see below).
|
|
118
|
+
|
|
119
|
+
## How it's put together
|
|
120
|
+
|
|
121
|
+
Grading is a separate stage from generation, so fixing a rubric costs no model calls.
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Web UI ──► API (FastAPI) ──► Workers (Redis/RQ) ◄──► Model providers
|
|
125
|
+
│ │ (via LiteLLM)
|
|
126
|
+
│ ▼
|
|
127
|
+
│ Graders — deterministic, then LLM judge
|
|
128
|
+
│ │
|
|
129
|
+
▼ ▼
|
|
130
|
+
Postgres ◄── Aggregator — diff vs baseline, p-value
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Four decisions carry the design:
|
|
134
|
+
|
|
135
|
+
- **One job per case, not per run.** A 500-case suite that dies at case 400
|
|
136
|
+
resumes from 400 — and you get a real progress bar.
|
|
137
|
+
- **Generation and grading are separate rows.** Model calls are expensive,
|
|
138
|
+
grader calls are cheap, so stored outputs can be re-graded with a new rubric
|
|
139
|
+
for free.
|
|
140
|
+
- **Cache keyed on content hash** — `hash(prompt + input + model + params)`.
|
|
141
|
+
Reruns cost nothing.
|
|
142
|
+
- **Graders are plugins.** A uniform `score / verdict / reason` interface means
|
|
143
|
+
adding one is a single file.
|
|
144
|
+
|
|
145
|
+
The interesting work is the judge layer: measuring the judge against your own
|
|
146
|
+
labels (Cohen's kappa against a gold set), controlling for position, verbosity,
|
|
147
|
+
self-preference and version-leak bias, and never calling a two-case difference a
|
|
148
|
+
regression without a p-value.
|
|
149
|
+
|
|
150
|
+
## Stack
|
|
151
|
+
|
|
152
|
+
| Layer | Pick |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| API | FastAPI + Pydantic v2, Python 3.12 |
|
|
155
|
+
| Database | PostgreSQL 16 (`JSONB`), SQLAlchemy 2.0 + Alembic |
|
|
156
|
+
| Queue | Redis + RQ |
|
|
157
|
+
| Model calls | LiteLLM |
|
|
158
|
+
| Statistics | `statsmodels`, `scikit-learn`, `numpy` |
|
|
159
|
+
| Web | Next.js 15 App Router, TypeScript, Tailwind + shadcn/ui, TanStack Query |
|
|
160
|
+
| Local dev | Docker Compose — api, worker, postgres, redis |
|
|
161
|
+
| Hosting | Vercel (web) + Fly.io or a Hetzner VPS (api, worker) |
|
|
162
|
+
|
|
163
|
+
Deliberately absent: Kafka, Kubernetes, GraphQL, a microservice split, a
|
|
164
|
+
separate vector database.
|
|
165
|
+
|
|
166
|
+
## Roadmap
|
|
167
|
+
|
|
168
|
+
~71 hours across seven phases, each with a gate to pass.
|
|
169
|
+
|
|
170
|
+
| Phase | | Hours |
|
|
171
|
+
| --- | --- | --- |
|
|
172
|
+
| 0 | The face | 8 |
|
|
173
|
+
| 1 | Foundations | 3 |
|
|
174
|
+
| 2 | Core loop | 15 |
|
|
175
|
+
| 3 | The verdict | 12 |
|
|
176
|
+
| 4 | Judge and calibration ✦ | 14 |
|
|
177
|
+
| 5 | Make it visible | 11 |
|
|
178
|
+
| 6 | Ship it | 8 |
|
|
179
|
+
|
|
180
|
+
Phase 4 is the one that matters.
|
|
181
|
+
|
|
182
|
+
## Docs
|
|
183
|
+
|
|
184
|
+
- [`docs/diffscore-build-spec.md`](https://github.com/tejhagargi9/Diffscore/blob/main/docs/diffscore-build-spec.md) — what and why:
|
|
185
|
+
architecture, data model, the judge layer, stack, costs, traps.
|
|
186
|
+
- [`docs/diffscore-roadmap.md`](https://github.com/tejhagargi9/Diffscore/blob/main/docs/diffscore-roadmap.md) — in what order, with
|
|
187
|
+
a gate at the end of each phase.
|
|
188
|
+
- [`brand/README.md`](https://github.com/tejhagargi9/Diffscore/blob/main/brand/README.md) — brand kit: palette, typeface, what to
|
|
189
|
+
use where, and the rules worth keeping.
|
|
190
|
+
|
|
191
|
+
## Using it
|
|
192
|
+
|
|
193
|
+
### Did my change make it better or worse?
|
|
194
|
+
|
|
195
|
+
The first completed run of a suite becomes its **baseline**. Every later
|
|
196
|
+
`diffscore run` is diffed against it, and the verdict comes first:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
regression on 7 cases (p = 0.02)
|
|
200
|
+
run #7 (baseline) -> run #10 | prompt changed | support
|
|
201
|
+
7 regressed, 0 improved, 43 unchanged | McNemar exact, alpha 0.05
|
|
202
|
+
mean score change -0.047 (95% CI -0.080 to -0.020)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
That is a real run: the shipping section was deleted from the example prompt.
|
|
206
|
+
A tweak that fixes one case and breaks another reports
|
|
207
|
+
`no significant change (p = 1.00)` instead — two flipped cases are noise, not
|
|
208
|
+
a regression. The p-value is McNemar's test on the paired pass/fail flips
|
|
209
|
+
(exact below 25 flips); the interval is a paired bootstrap of the mean score.
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
uv run diffscore diff 10 # run 10 vs its suite's baseline
|
|
213
|
+
uv run diffscore diff 7 10 --all # any two runs, including unchanged cases
|
|
214
|
+
uv run diffscore baseline 10 # promote a run to baseline
|
|
215
|
+
uv run diffscore run suite.yaml --baseline previous # diff vs the last run instead
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`diffscore run` and `diffscore diff` exit **1 only on a statistically
|
|
219
|
+
significant regression**, so they can gate a pull request.
|
|
220
|
+
|
|
221
|
+
### Grading what string checks can't: the judge
|
|
222
|
+
|
|
223
|
+
For faithfulness, helpfulness or tone, add an LLM judge with a rubric. It
|
|
224
|
+
grades each answer against every criterion and must quote the answer as
|
|
225
|
+
evidence. It sees the customer's input, the answer and your reference
|
|
226
|
+
material, **never the prompt under test or which model wrote the answer**.
|
|
227
|
+
|
|
228
|
+
```yaml
|
|
229
|
+
graders:
|
|
230
|
+
- judge:
|
|
231
|
+
context_file: reference/policy.md # ground truth the judge may consult
|
|
232
|
+
rubric:
|
|
233
|
+
- name: accurate
|
|
234
|
+
description: Every fact agrees with the reference policy.
|
|
235
|
+
- name: tone
|
|
236
|
+
description: Polite and calm; acknowledges an upset customer.
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The judge runs on `JUDGE_MODEL` (default `gemini/gemini-3.1-flash-lite`, which fits
|
|
240
|
+
Gemini's free tier; a stronger judge is better) and refuses
|
|
241
|
+
to grade answers from its own model. A judge that can't produce a verdict
|
|
242
|
+
marks the case as an error, not a failure, so it never shows up as a regression.
|
|
243
|
+
|
|
244
|
+
### Can I trust the judge?
|
|
245
|
+
|
|
246
|
+
Not until you've measured it. Label some outputs yourself, then compare:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
uv run diffscore label 15 # pass/fail in the terminal; the judge's verdict stays hidden
|
|
250
|
+
uv run diffscore calibrate examples/support.yaml
|
|
251
|
+
uv run diffscore calibrate examples/support.yaml --disagreements # which answers you and the judge disagree on
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
judge (version 1-<rubric hash>, judged by <judge model>)
|
|
256
|
+
kappa <κ> trustworthy | below 0.6: rewrite the rubric (raw agreement <%>)
|
|
257
|
+
bias checks
|
|
258
|
+
verbosity r = <r> (score vs length, flag > 0.3)
|
|
259
|
+
self-preference judge <model> vs outputs from <models>
|
|
260
|
+
position <k>/<n> pairwise verdicts survive swapping the order
|
|
261
|
+
variance <k>/<n> verdicts flipped across 3 repeats
|
|
262
|
+
evidence <k>/<n> quotes found verbatim in the output
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**Cohen's kappa below 0.6 means the judge is close to guessing**: rewrite the rubric and calibrate
|
|
266
|
+
again. Calibration re-judges your labelled outputs with the rubric as the file
|
|
267
|
+
defines it now, so that loop never regenerates an answer. Labels belong to
|
|
268
|
+
outputs, not runs, so a label made once covers every later run that reuses
|
|
269
|
+
that answer. Around 50–100 labels make kappa stable.
|
|
270
|
+
|
|
271
|
+
### The web app
|
|
272
|
+
|
|
273
|
+
Everything the CLI does is also an HTTP API, and the site has screens for it:
|
|
274
|
+
a runs list with live progress, a run page with every case, the judge's
|
|
275
|
+
evidence and its trust status, and a diff page that leads with the verdict.
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
docker compose --profile app up -d # + API on :8000 and the queue worker
|
|
279
|
+
cd web && npm install && npm run dev # http://localhost:3000/runs
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
A run started from the web is queued as **one job per case**, so a crashed
|
|
283
|
+
worker resumes where it stopped and the progress bar is real. Without the
|
|
284
|
+
`API_KEY`, visitors can read public projects, run a sample suite, or run their
|
|
285
|
+
own suite with **their own provider key**. That key is encrypted with
|
|
286
|
+
`FERNET_KEY`, used for that run only and wiped when it finishes. Visitor runs
|
|
287
|
+
are rate limited per IP, capped at `MAX_CASES_ANONYMOUS` cases and limited to
|
|
288
|
+
safe model params. Owner keys for a project are stored encrypted and never
|
|
289
|
+
returned. Everything key-shaped is scrubbed from logs and Sentry events.
|
|
290
|
+
|
|
291
|
+
API docs are served at `http://localhost:8000/docs`.
|
|
292
|
+
|
|
293
|
+
### In CI
|
|
294
|
+
|
|
295
|
+
Run the suite on the base branch's prompt, then on the pull request's, and
|
|
296
|
+
diff the two. The job fails only when the regression is significant.
|
|
297
|
+
|
|
298
|
+
```yaml
|
|
299
|
+
# .github/workflows/prompt-regression.yml
|
|
300
|
+
name: prompt regression
|
|
301
|
+
on:
|
|
302
|
+
pull_request:
|
|
303
|
+
paths: ["prompts/**", "evals/**"]
|
|
304
|
+
|
|
305
|
+
jobs:
|
|
306
|
+
diffscore:
|
|
307
|
+
runs-on: ubuntu-latest
|
|
308
|
+
env:
|
|
309
|
+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
|
310
|
+
MODEL_RPM: "14"
|
|
311
|
+
steps:
|
|
312
|
+
- uses: actions/checkout@v4
|
|
313
|
+
with: { fetch-depth: 0 }
|
|
314
|
+
- uses: actions/setup-python@v5
|
|
315
|
+
with: { python-version: "3.12" }
|
|
316
|
+
- run: pip install diffscore
|
|
317
|
+
- name: Baseline = the base branch's prompt
|
|
318
|
+
run: |
|
|
319
|
+
git worktree add /tmp/base "origin/${{ github.base_ref }}"
|
|
320
|
+
diffscore run /tmp/base/evals/support.yaml --no-diff --quiet
|
|
321
|
+
- name: Diff the pull request against it
|
|
322
|
+
run: diffscore run evals/support.yaml --baseline previous
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
The runner's SQLite file starts empty, so both runs make real model calls;
|
|
326
|
+
cache `.diffscore/` between jobs with `actions/cache` to make repeats free.
|
|
327
|
+
|
|
328
|
+
## Developing Diffscore
|
|
329
|
+
|
|
330
|
+
Needs [uv](https://docs.astral.sh/uv/) and Docker.
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
uv sync --all-extras
|
|
334
|
+
uv run pytest && uv run ruff check . && uv run mypy
|
|
335
|
+
docker compose --profile app up -d # Postgres, Redis, the API and the worker
|
|
336
|
+
uv run alembic revision --autogenerate -m "..." # after changing a model
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
The CLI defaults to SQLite; set `DATABASE_URL` to use Postgres (`pip install
|
|
340
|
+
"diffscore[postgres]"`). The API and worker need `pip install "diffscore[server]"`.
|
|
341
|
+
Example suites live in [`examples/`](https://github.com/tejhagargi9/Diffscore/blob/main/examples), and the website in
|
|
342
|
+
[`web/`](https://github.com/tejhagargi9/Diffscore/blob/main/web/README.md).
|
|
343
|
+
|
|
344
|
+
## License
|
|
345
|
+
|
|
346
|
+
[MIT](https://github.com/tejhagargi9/Diffscore/blob/main/LICENSE). Use it, fork it, ship it in a closed product — no conditions
|
|
347
|
+
beyond keeping the copyright notice.
|
|
348
|
+
|
|
349
|
+
The name and the brand assets are not covered by that licence; see
|
|
350
|
+
[TRADEMARK.md](https://github.com/tejhagargi9/Diffscore/blob/main/TRADEMARK.md). Short version: use the mark to refer to this
|
|
351
|
+
project freely, give a fork its own name.
|