0d3cb498a3
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Waiting to run
Test and Publish Multi-arch Docker Image / test (push) Waiting to run
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Blocked by required conditions
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Blocked by required conditions
Validate Renovate Config / Validate Renovate Configuration (push) Waiting to run
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
87 lines
2.6 KiB
Python
87 lines
2.6 KiB
Python
"""Generate Promptfoo test cases from Inspect's OSWorld dataset."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
CONTAINER_EXAMPLE_PATH = "/tmp/osworld/desktop_env/example.json"
|
|
|
|
|
|
def generate_tests():
|
|
"""Return one Promptfoo test case per Inspect-supported small-suite sample."""
|
|
|
|
dataset = _osworld_small_dataset()
|
|
return [_test_case(dataset[index]) for index in range(len(dataset))]
|
|
|
|
|
|
def generate_full_tests():
|
|
"""Return one Promptfoo test case per Inspect-supported full-suite sample."""
|
|
|
|
dataset = _osworld_full_dataset()
|
|
return [_test_case(dataset[index]) for index in range(len(dataset))]
|
|
|
|
|
|
def _osworld_small_dataset():
|
|
try:
|
|
from inspect_evals.osworld import osworld_small
|
|
except ImportError as exc:
|
|
raise RuntimeError(
|
|
"Could not import inspect_evals.osworld. Install prerequisites with "
|
|
"`pip install 'inspect-evals[osworld]'` before loading OSWorld tests."
|
|
) from exc
|
|
|
|
return osworld_small().dataset
|
|
|
|
|
|
def _osworld_full_dataset():
|
|
try:
|
|
from inspect_evals.osworld import osworld
|
|
except ImportError as exc:
|
|
raise RuntimeError(
|
|
"Could not import inspect_evals.osworld. Install prerequisites with "
|
|
"`pip install 'inspect-evals[osworld]'` before loading OSWorld tests."
|
|
) from exc
|
|
|
|
return osworld(include_connected=True).dataset
|
|
|
|
|
|
def _test_case(sample):
|
|
sample_id = str(sample.id)
|
|
instruction = str(sample.input)
|
|
app = _normalize_app(_example_path(sample).parent.name)
|
|
return {
|
|
"description": f"{app} - {_short_label(instruction)}",
|
|
"vars": {
|
|
"prompt": instruction,
|
|
"app": app,
|
|
"sample_id": sample_id,
|
|
},
|
|
"metadata": {
|
|
"app": app,
|
|
"sample_id": sample_id,
|
|
"testCaseId": f"osworld-{app.replace('_', '-')}-{sample_id.split('-', 1)[0]}",
|
|
},
|
|
}
|
|
|
|
|
|
def _example_path(sample):
|
|
try:
|
|
return Path(str(sample.files[CONTAINER_EXAMPLE_PATH]))
|
|
except (AttributeError, KeyError, TypeError) as exc:
|
|
raise RuntimeError(
|
|
f"Inspect OSWorld sample {getattr(sample, 'id', '<unknown>')} did not "
|
|
f"include {CONTAINER_EXAMPLE_PATH} in sample.files."
|
|
) from exc
|
|
|
|
|
|
def _short_label(instruction, max_length=80):
|
|
label = " ".join(str(instruction).split())
|
|
if len(label) <= max_length:
|
|
return label
|
|
return f"{label[: max_length - 3].rstrip()}..."
|
|
|
|
|
|
def _normalize_app(app):
|
|
normalized = str(app).strip().lower().replace("-", "_").replace(" ", "_")
|
|
return "vscode" if normalized == "vs_code" else normalized
|