aid-runtime-python 0.1.161__py3-none-any.whl → 0.1.162__py3-none-any.whl
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.
- aid_runtime/__init__.py +3 -1
- aid_runtime/evals/__init__.py +2 -0
- aid_runtime/evals/gate.py +42 -1
- aid_runtime/evals/runner.py +31 -2
- {aid_runtime_python-0.1.161.dist-info → aid_runtime_python-0.1.162.dist-info}/METADATA +1 -1
- {aid_runtime_python-0.1.161.dist-info → aid_runtime_python-0.1.162.dist-info}/RECORD +8 -8
- {aid_runtime_python-0.1.161.dist-info → aid_runtime_python-0.1.162.dist-info}/WHEEL +0 -0
- {aid_runtime_python-0.1.161.dist-info → aid_runtime_python-0.1.162.dist-info}/top_level.txt +0 -0
aid_runtime/__init__.py
CHANGED
|
@@ -116,6 +116,7 @@ from aid_runtime.errors import (
|
|
|
116
116
|
)
|
|
117
117
|
from aid_runtime.evals import (
|
|
118
118
|
AgentEvalRunner,
|
|
119
|
+
AggregateBaseline,
|
|
119
120
|
ApprovalPolicy,
|
|
120
121
|
ApprovalRespected,
|
|
121
122
|
BaselineGate,
|
|
@@ -350,7 +351,7 @@ from aid_runtime.types import (
|
|
|
350
351
|
)
|
|
351
352
|
|
|
352
353
|
#: Kept in sync with ``pyproject.toml`` by a test, so the two cannot drift.
|
|
353
|
-
__version__ = "0.1.
|
|
354
|
+
__version__ = "0.1.162"
|
|
354
355
|
|
|
355
356
|
__all__ = [
|
|
356
357
|
"AGENT_LABEL",
|
|
@@ -396,6 +397,7 @@ __all__ = [
|
|
|
396
397
|
"AgentHandoffUnsupportedError",
|
|
397
398
|
"AgentRuntime",
|
|
398
399
|
"AgentTransferCycleError",
|
|
400
|
+
"AggregateBaseline",
|
|
399
401
|
"AidRuntimeError",
|
|
400
402
|
"AnthropicProvider",
|
|
401
403
|
"ApprovalPolicy",
|
aid_runtime/evals/__init__.py
CHANGED
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
from aid_runtime.evals.agent_runner import AgentEvalRunner, ApprovalPolicy
|
|
6
6
|
from aid_runtime.evals.dataset import Dataset, EvalCase, require_reviewed
|
|
7
7
|
from aid_runtime.evals.gate import (
|
|
8
|
+
AggregateBaseline,
|
|
8
9
|
BaselineGate,
|
|
9
10
|
EvalBaseline,
|
|
10
11
|
EvalRun,
|
|
@@ -50,6 +51,7 @@ from aid_runtime.evals.trajectory import RunOutput, Trajectory
|
|
|
50
51
|
|
|
51
52
|
__all__ = [
|
|
52
53
|
"AgentEvalRunner",
|
|
54
|
+
"AggregateBaseline",
|
|
53
55
|
"ApprovalPolicy",
|
|
54
56
|
"ApprovalRespected",
|
|
55
57
|
"AssertMetric",
|
aid_runtime/evals/gate.py
CHANGED
|
@@ -96,6 +96,12 @@ class EvalRun(BaseModel):
|
|
|
96
96
|
dataset_version: str
|
|
97
97
|
runs: int = Field(gt=0)
|
|
98
98
|
metrics: tuple[MetricRun, ...] = Field(min_length=1)
|
|
99
|
+
#: Model spend per run, in the run's currency. Empty when the runner meters no cost,
|
|
100
|
+
#: which is a different answer from "every run spent zero": a promotion ceiling cannot
|
|
101
|
+
#: be judged against a runner that never measured anything.
|
|
102
|
+
cost_usd: tuple[float, ...] = ()
|
|
103
|
+
#: Wall-clock time of each run's model calls, in milliseconds, excluding scoring.
|
|
104
|
+
latency_ms: tuple[float, ...] = ()
|
|
99
105
|
|
|
100
106
|
def means(self) -> dict[str, float]:
|
|
101
107
|
return {entry.metric: statistics.fmean(entry.values) for entry in self.metrics}
|
|
@@ -142,6 +148,29 @@ class MetricBaseline(BaseModel):
|
|
|
142
148
|
)
|
|
143
149
|
|
|
144
150
|
|
|
151
|
+
class AggregateBaseline(BaseModel):
|
|
152
|
+
"""A recorded mean and spread over runs, in the unit of whatever holds it.
|
|
153
|
+
|
|
154
|
+
``mean`` is bounded below only. A metric's baseline is a pass rate and fits in
|
|
155
|
+
``[0, 1]``, but a spend average is a currency figure and a duration is milliseconds,
|
|
156
|
+
so the unit lives in the field name that refers to this record
|
|
157
|
+
(``EvalBaseline.cost``, ``EvalBaseline.latency``) and not in the bound.
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
model_config = ConfigDict(frozen=True, extra="forbid")
|
|
161
|
+
|
|
162
|
+
runs: int = Field(gt=0)
|
|
163
|
+
mean: float = Field(ge=0.0)
|
|
164
|
+
stdev: float = Field(ge=0.0)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _aggregate(values: Sequence[float]) -> AggregateBaseline | None:
|
|
168
|
+
"""The recorded mean and spread of ``values``, or ``None`` when none were measured."""
|
|
169
|
+
if not values:
|
|
170
|
+
return None
|
|
171
|
+
return AggregateBaseline(runs=len(values), mean=statistics.fmean(values), stdev=_stdev(values))
|
|
172
|
+
|
|
173
|
+
|
|
145
174
|
class EvalBaseline(BaseModel):
|
|
146
175
|
"""A committed baseline: the accepted distribution for a dataset and model."""
|
|
147
176
|
|
|
@@ -152,6 +181,14 @@ class EvalBaseline(BaseModel):
|
|
|
152
181
|
model: str
|
|
153
182
|
metrics: tuple[MetricBaseline, ...] = Field(min_length=1)
|
|
154
183
|
note: str = ""
|
|
184
|
+
#: Recorded model spend per run, when the run that produced this baseline metered it.
|
|
185
|
+
#: Absent on a baseline recorded before spend was measured, and on one recorded from a
|
|
186
|
+
#: runner that meters nothing -- a scripted model in CI, for instance. ``aid eval
|
|
187
|
+
#: --compare`` refuses to judge ``allowedCostIncrease`` against either, rather than
|
|
188
|
+
#: read "not measured" as "no increase".
|
|
189
|
+
cost: AggregateBaseline | None = None
|
|
190
|
+
#: Recorded wall-clock time per run, in milliseconds, on the same terms as ``cost``.
|
|
191
|
+
latency: AggregateBaseline | None = None
|
|
155
192
|
|
|
156
193
|
@classmethod
|
|
157
194
|
def from_run(cls, run: EvalRun, *, model: str, note: str = "") -> EvalBaseline:
|
|
@@ -163,6 +200,8 @@ class EvalBaseline(BaseModel):
|
|
|
163
200
|
MetricBaseline.from_values(entry.metric, entry.values) for entry in run.metrics
|
|
164
201
|
),
|
|
165
202
|
note=note,
|
|
203
|
+
cost=_aggregate(run.cost_usd),
|
|
204
|
+
latency=_aggregate(run.latency_ms),
|
|
166
205
|
)
|
|
167
206
|
|
|
168
207
|
def metric(self, name: str) -> MetricBaseline:
|
|
@@ -180,7 +219,9 @@ class EvalBaseline(BaseModel):
|
|
|
180
219
|
return cls.from_json(Path(path).read_text(encoding="utf-8"))
|
|
181
220
|
|
|
182
221
|
def to_json(self) -> str:
|
|
183
|
-
|
|
222
|
+
# ``exclude_none`` keeps a baseline that recorded no spend byte-identical to what
|
|
223
|
+
# this method wrote before cost and latency were recorded at all.
|
|
224
|
+
return self.model_dump_json(indent=2, exclude_none=True) + "\n"
|
|
184
225
|
|
|
185
226
|
|
|
186
227
|
class Threshold(BaseModel):
|
aid_runtime/evals/runner.py
CHANGED
|
@@ -69,6 +69,12 @@ class DatasetRun(BaseModel):
|
|
|
69
69
|
dataset: str
|
|
70
70
|
dataset_version: str
|
|
71
71
|
outcomes: tuple[CaseOutcome, ...] = Field(min_length=1)
|
|
72
|
+
#: Model spend for this pass, in the run's currency, or ``None`` when the runner meters
|
|
73
|
+
#: nothing. ``None`` and ``0.0`` are different answers: only one of them can be compared
|
|
74
|
+
#: against a recorded baseline.
|
|
75
|
+
cost_usd: float | None = None
|
|
76
|
+
#: Wall-clock time of this pass's model calls, in milliseconds, excluding scoring.
|
|
77
|
+
latency_ms: float | None = None
|
|
72
78
|
|
|
73
79
|
def means(self) -> dict[str, float]:
|
|
74
80
|
"""Mean score per metric across the cases of this pass."""
|
|
@@ -202,6 +208,9 @@ async def evaluate_once(
|
|
|
202
208
|
raise ValueError("at least one metric is required")
|
|
203
209
|
label = dataset.name if eval_id is None else eval_id
|
|
204
210
|
outcomes: list[CaseOutcome] = []
|
|
211
|
+
spent = 0.0
|
|
212
|
+
elapsed = 0.0
|
|
213
|
+
metered = True
|
|
205
214
|
for case in dataset.cases:
|
|
206
215
|
cost_before = _runner_cost(runner)
|
|
207
216
|
started = perf_counter()
|
|
@@ -213,8 +222,9 @@ async def evaluate_once(
|
|
|
213
222
|
latency_ms = (perf_counter() - started) * 1000.0
|
|
214
223
|
# Metrics see the pipeline's own spend, measured before scoring, because "what did
|
|
215
224
|
# this task cost" is a property of the product and not of the harness auditing it.
|
|
225
|
+
case_cost = _spent_since(runner, cost_before)
|
|
216
226
|
context = RunContext(
|
|
217
|
-
cost_usd=
|
|
227
|
+
cost_usd=case_cost,
|
|
218
228
|
latency_ms=latency_ms,
|
|
219
229
|
metered=cost_before is not None,
|
|
220
230
|
trajectory=trajectory,
|
|
@@ -230,6 +240,11 @@ async def evaluate_once(
|
|
|
230
240
|
trajectory=trajectory,
|
|
231
241
|
)
|
|
232
242
|
)
|
|
243
|
+
# The pass total is the same pre-scoring figure the metrics saw, so a recorded
|
|
244
|
+
# baseline describes the product rather than the harness that audited it.
|
|
245
|
+
spent += case_cost
|
|
246
|
+
elapsed += latency_ms
|
|
247
|
+
metered = metered and cost_before is not None
|
|
233
248
|
# The published series is read after scoring, because a model-backed metric spends
|
|
234
249
|
# money too and a cost series that ignored the judge would report half the run.
|
|
235
250
|
record_eval_case(
|
|
@@ -238,7 +253,11 @@ async def evaluate_once(
|
|
|
238
253
|
latency_ms=latency_ms,
|
|
239
254
|
)
|
|
240
255
|
return DatasetRun(
|
|
241
|
-
dataset=dataset.name,
|
|
256
|
+
dataset=dataset.name,
|
|
257
|
+
dataset_version=dataset.version,
|
|
258
|
+
outcomes=tuple(outcomes),
|
|
259
|
+
cost_usd=spent if metered else None,
|
|
260
|
+
latency_ms=elapsed,
|
|
242
261
|
)
|
|
243
262
|
|
|
244
263
|
|
|
@@ -291,11 +310,19 @@ async def run_evaluation(
|
|
|
291
310
|
raise ValueError("at least one metric is required")
|
|
292
311
|
|
|
293
312
|
collected: dict[str, list[float]] = {metric.name: [] for metric in metrics}
|
|
313
|
+
costs: list[float] = []
|
|
314
|
+
latencies: list[float] = []
|
|
294
315
|
for _ in range(runs):
|
|
295
316
|
pass_result = await evaluate_once(dataset, runner, metrics, eval_id=eval_id)
|
|
296
317
|
means = pass_result.means()
|
|
297
318
|
for metric in metrics:
|
|
298
319
|
collected[metric.name].append(means[metric.name])
|
|
320
|
+
# A pass that metered nothing contributes no spend figure, so a run built from
|
|
321
|
+
# unmetered passes carries an empty tuple and a baseline recorded from it says so.
|
|
322
|
+
if pass_result.cost_usd is not None:
|
|
323
|
+
costs.append(pass_result.cost_usd)
|
|
324
|
+
if pass_result.latency_ms is not None:
|
|
325
|
+
latencies.append(pass_result.latency_ms)
|
|
299
326
|
|
|
300
327
|
return EvalRun(
|
|
301
328
|
dataset=dataset.name,
|
|
@@ -305,4 +332,6 @@ async def run_evaluation(
|
|
|
305
332
|
MetricRun(metric=metric.name, values=tuple(collected[metric.name]))
|
|
306
333
|
for metric in metrics
|
|
307
334
|
),
|
|
335
|
+
cost_usd=tuple(costs),
|
|
336
|
+
latency_ms=tuple(latencies),
|
|
308
337
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aid-runtime-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.162
|
|
4
4
|
Summary: The AID Framework Python runtime: model gateway with pinning and cost budgets, prompt registry, tool executor, OTel GenAI tracing, plain-async pipeline, and an eval harness that gates on statistical regression against a stored baseline.
|
|
5
5
|
Author: The AID Framework authors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
aid_runtime/__init__.py,sha256=
|
|
1
|
+
aid_runtime/__init__.py,sha256=jFTM3HnzztNWpcicGQ4HeCMsG9E8Y0Sr1VYxiGojaHo,14951
|
|
2
2
|
aid_runtime/cache.py,sha256=jhw_EBd9dfWEUzYeibOvIkVBqqiLUjqF5WKEPz9GkhE,6836
|
|
3
3
|
aid_runtime/concurrency.py,sha256=z0tFQHw35ttFLKfazGBjCMPOLQOnUotE_OPpvR1piH4,2829
|
|
4
4
|
aid_runtime/control.py,sha256=y6wPn0fqYJv0nVSsjzpzfiaq1Y7zBoMxCpdrEuqkfvg,17529
|
|
@@ -29,13 +29,13 @@ aid_runtime/agents/managed.py,sha256=SFyx6Rca2aoiMzA9q6B4Nfes6ZCjn_5_zN0SxzemIII
|
|
|
29
29
|
aid_runtime/agents/memory.py,sha256=6_D6k2bzAiR2euNvzr6HB28wsUUq-R-WTQc12gkB8ao,9156
|
|
30
30
|
aid_runtime/agents/policy.py,sha256=ael0EW_hWfLu95rbqFMrR4WyqAPtgiSNvNw97xnthdw,6122
|
|
31
31
|
aid_runtime/agents/state.py,sha256=4itT7BWv2JKSeWpRrDyxLguOOVnz9gGH_qgRdCbWCaw,6086
|
|
32
|
-
aid_runtime/evals/__init__.py,sha256=
|
|
32
|
+
aid_runtime/evals/__init__.py,sha256=5_qUGwiKR2l4p-F8RZ9QnxzFOxtNj7DWoEsA8uNyHIs,1991
|
|
33
33
|
aid_runtime/evals/agent_runner.py,sha256=E1Vg48gNAeQzGGSyp0cK8H5mxGlVEPBq-FTaaTQ-CLE,12594
|
|
34
34
|
aid_runtime/evals/dataset.py,sha256=ZmTP-jWx9f2udYPyzvTtOuUse5Mp-uj5WNBPy-7aHKM,5946
|
|
35
|
-
aid_runtime/evals/gate.py,sha256=
|
|
35
|
+
aid_runtime/evals/gate.py,sha256=uYUOw57MaGqSOsMvbB0C6MrjW4IbUJ57izyD6FSxkxw,17676
|
|
36
36
|
aid_runtime/evals/metrics.py,sha256=LvzKgW-7CNxcB0MmDXakDnwdgyzjpH8ceHq7mdi8mw4,28541
|
|
37
37
|
aid_runtime/evals/predicate.py,sha256=JaeN1LJFpliI4JHYdFPtXfjH5_Aad-2-U3ZC6_hManE,8726
|
|
38
|
-
aid_runtime/evals/runner.py,sha256=
|
|
38
|
+
aid_runtime/evals/runner.py,sha256=rI5AScHDPnwN5Ohw0I7zR2Df9pGSTE8Un6-lESCSV3g,12827
|
|
39
39
|
aid_runtime/evals/trajectory.py,sha256=X7ssDigfFuMkjM6mR6LGSbb03A8iNf4oRbVqeSsU7Ww,4444
|
|
40
40
|
aid_runtime/providers/__init__.py,sha256=5XMe1kPqckeyv2l_FrfYEiTPWOTGsPKpWtiiTdSn3ic,2284
|
|
41
41
|
aid_runtime/providers/anthropic.py,sha256=xh_fJyujnFRcknEHFRxA5M-izeR2hJtit-865RrISOQ,15853
|
|
@@ -62,7 +62,7 @@ aid_runtime/retrieval/rerank.py,sha256=L4ICBi9YHDzhnKVtImKh5Wzre1HDzS8at-AKDkXBJ
|
|
|
62
62
|
aid_runtime/retrieval/retriever.py,sha256=0Cx-_6Qcf2TRolFy4ktMseyyyr-WLphMYYHane0t9lA,24412
|
|
63
63
|
aid_runtime/retrieval/stores.py,sha256=mG261rUHZIzB7niiTj_DuUzcNMOd4QYENk5ArgI1iBo,6840
|
|
64
64
|
aid_runtime/retrieval/types.py,sha256=hJ5IRSD-PTfrc1xhuK6CBdX0Yr-S6L_JeSMPity8ecM,20447
|
|
65
|
-
aid_runtime_python-0.1.
|
|
66
|
-
aid_runtime_python-0.1.
|
|
67
|
-
aid_runtime_python-0.1.
|
|
68
|
-
aid_runtime_python-0.1.
|
|
65
|
+
aid_runtime_python-0.1.162.dist-info/METADATA,sha256=qAn1akp78XLDV7BYtyv2O2uOsBBkovoiO8nAL1bfCQ8,17163
|
|
66
|
+
aid_runtime_python-0.1.162.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
67
|
+
aid_runtime_python-0.1.162.dist-info/top_level.txt,sha256=QvODgNVRDDMmLcTnoIQ4jYnhqf-N4b9sHWEmaUUxp44,12
|
|
68
|
+
aid_runtime_python-0.1.162.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|