Download testing/agent_evaluation/evaluators/ut_common.py from yuhanqin/ut-evaluation: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/datasets/yuhanqin/ut-evaluation/resolve/main/testing/agent_evaluation/evaluators/ut_common.py
- Command line
-
hf download hf://datasets/yuhanqin/ut-evaluation/testing/agent_evaluation/evaluators/ut_common.py
-
curl -L -o ut_common.py https://huggingface.co/datasets/yuhanqin/ut-evaluation/resolve/main/testing/agent_evaluation/evaluators/ut_common.py
1.38 kB
| """Shared measurement helpers for the UT evaluators.""" | |
| from __future__ import annotations | |
| from typing import Any | |
| from .contracts import EmptyParams, EvaluatorDefinition, EvaluatorResult, measurement_result | |
| def unavailable(metric: str, explanation: str) -> EvaluatorResult: | |
| return measurement_result( | |
| value=None, metric=metric, unit="check", status="unavailable", explanation=explanation, | |
| ) | |
| def check(metric: str, value: dict[str, bool], explanation: str) -> EvaluatorResult: | |
| return measurement_result( | |
| value=value, metric=metric, unit="check", score=float(all(value.values())) if value else 0.0, | |
| explanation=explanation, | |
| ) | |
| def normalize_empty(params: dict[str, Any]) -> EmptyParams: | |
| if params: | |
| raise ValueError(f"unknown evaluator params: {sorted(params)}") | |
| return EmptyParams() | |
| def measurement(evaluator_id: str, rule: Any, metric: str) -> EvaluatorDefinition: | |
| return EvaluatorDefinition( | |
| evaluator_id=evaluator_id, family="execution", result_kind="measurement", | |
| expansion="once", rule=rule, scope="skill", metric=metric, unit="check", | |
| required_evidence=frozenset({"execution_workspace"}), aggregation="mean", | |
| direction="maximize", params_type=EmptyParams, normalize_params=normalize_empty, | |
| params_schema={"type": "object", "additionalProperties": False}, | |
| ) | |