aid-runtime-python 0.1.160__tar.gz → 0.1.162__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.
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/PKG-INFO +1 -1
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/pyproject.toml +1 -1
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/__init__.py +6 -1
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/__init__.py +2 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/gate.py +42 -1
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/runner.py +31 -2
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/gateway.py +15 -3
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/prompts.py +10 -0
- aid_runtime_python-0.1.162/src/aid_runtime/redaction.py +46 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/tracing.py +5 -3
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/types.py +14 -3
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime_python.egg-info/PKG-INFO +1 -1
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime_python.egg-info/SOURCES.txt +2 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_evals_gate.py +63 -0
- aid_runtime_python-0.1.162/tests/test_redaction.py +76 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/README.md +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/setup.cfg +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/__init__.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/chat_model.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/deep_agents.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/engine.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/guardrails.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/ir.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/loop.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/managed.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/memory.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/policy.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/state.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/cache.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/concurrency.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/control.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/cost.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/decisions.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/errors.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/agent_runner.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/dataset.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/metrics.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/predicate.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/trajectory.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/local_trace.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/metrics.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/pipeline.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/__init__.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/anthropic.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/base.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/bedrock.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/fake.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/gemini.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/gemini_wire.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/http.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/recorded.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/vertex.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/py.typed +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/__init__.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/chunking.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/citations.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/connectors.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/embedding.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/filters.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/gate.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/hybrid.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/knowledge_base.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/metrics.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/pgvector.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/rerank.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/retriever.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/stores.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/types.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/steps.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/structured.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/telemetry.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/tools.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime_python.egg-info/dependency_links.txt +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime_python.egg-info/requires.txt +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime_python.egg-info/top_level.txt +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_agent_eval_runner.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_agents_budget.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_agents_deep_agents.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_agents_hitl.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_agents_loop.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_agents_memory.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_anthropic_provider.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_bedrock_provider.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_cache.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_concurrency.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_control.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_cost.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_dataset.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_decisions.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_evals.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_evals_assert_gate.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_evals_budgets.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_evals_decision.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_evals_predicate.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_evals_trajectory.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_gateway.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_gemini_provider.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_guardrails.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_guardrails_managed.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_guardrails_model_armor.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_http_provider.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_local_trace.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_metrics.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_package.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_pipeline.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_prompts.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_recorded_provider.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_chunking.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_citations.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_connectors.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_embedding.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_filters.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_gate.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_hybrid.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_knowledge_base.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_metrics.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_rerank.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_stores.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_types.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_steps.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_streaming.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_structured.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_telemetry.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_tool_permissions.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_tools.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_tracing.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_types.py +0 -0
- {aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_vertex_provider.py +0 -0
|
@@ -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
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "aid-runtime-python"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.162"
|
|
8
8
|
description = "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."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -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,
|
|
@@ -201,6 +202,7 @@ from aid_runtime.providers import (
|
|
|
201
202
|
default_bedrock_base_url,
|
|
202
203
|
default_vertex_base_url,
|
|
203
204
|
)
|
|
205
|
+
from aid_runtime.redaction import REDACTED_FORMAT, redact_values
|
|
204
206
|
from aid_runtime.retrieval import (
|
|
205
207
|
DEFAULT_CANDIDATE_FACTOR,
|
|
206
208
|
DEFAULT_SYNC_TIMEOUT_SECONDS,
|
|
@@ -349,7 +351,7 @@ from aid_runtime.types import (
|
|
|
349
351
|
)
|
|
350
352
|
|
|
351
353
|
#: Kept in sync with ``pyproject.toml`` by a test, so the two cannot drift.
|
|
352
|
-
__version__ = "0.1.
|
|
354
|
+
__version__ = "0.1.162"
|
|
353
355
|
|
|
354
356
|
__all__ = [
|
|
355
357
|
"AGENT_LABEL",
|
|
@@ -380,6 +382,7 @@ __all__ = [
|
|
|
380
382
|
"METRIC_NAMES",
|
|
381
383
|
"OTLP_EXTRA",
|
|
382
384
|
"PRINCIPAL_KEY",
|
|
385
|
+
"REDACTED_FORMAT",
|
|
383
386
|
"REDUCED_KEY",
|
|
384
387
|
"RESERVED_KEYS",
|
|
385
388
|
"STEPS_KEY",
|
|
@@ -394,6 +397,7 @@ __all__ = [
|
|
|
394
397
|
"AgentHandoffUnsupportedError",
|
|
395
398
|
"AgentRuntime",
|
|
396
399
|
"AgentTransferCycleError",
|
|
400
|
+
"AggregateBaseline",
|
|
397
401
|
"AidRuntimeError",
|
|
398
402
|
"AnthropicProvider",
|
|
399
403
|
"ApprovalPolicy",
|
|
@@ -635,6 +639,7 @@ __all__ = [
|
|
|
635
639
|
"record_exception",
|
|
636
640
|
"record_hitl",
|
|
637
641
|
"record_usage",
|
|
642
|
+
"redact_values",
|
|
638
643
|
"reduce_step",
|
|
639
644
|
"repair_prompt",
|
|
640
645
|
"require_reviewed",
|
|
@@ -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",
|
|
@@ -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):
|
|
@@ -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
|
)
|
|
@@ -32,6 +32,7 @@ from aid_runtime.errors import (
|
|
|
32
32
|
UnknownModelAliasError,
|
|
33
33
|
)
|
|
34
34
|
from aid_runtime.providers.base import Provider
|
|
35
|
+
from aid_runtime.redaction import redact_values
|
|
35
36
|
from aid_runtime.tracing import (
|
|
36
37
|
ATTRIBUTES,
|
|
37
38
|
get_tracer,
|
|
@@ -67,8 +68,11 @@ def _prompt_text(request: CompletionRequest) -> str:
|
|
|
67
68
|
|
|
68
69
|
Role-prefixed rather than concatenated, so a captured prompt still shows which
|
|
69
70
|
turn a line came from once it is a row of JSONL rather than a live message list.
|
|
71
|
+
Redacted with the request's own bindings: what the provider received is
|
|
72
|
+
unchanged, and what a trace keeps no longer carries a value the spec forbids.
|
|
70
73
|
"""
|
|
71
|
-
|
|
74
|
+
text = "\n\n".join(f"{message.role}: {message.content}" for message in request.messages)
|
|
75
|
+
return redact_values(text, request.redactions)
|
|
72
76
|
|
|
73
77
|
|
|
74
78
|
def _sse(payload: dict[str, Any]) -> bytes:
|
|
@@ -286,7 +290,11 @@ class ModelGateway:
|
|
|
286
290
|
cost = spec.cost.cost_usd(usage)
|
|
287
291
|
record_usage(span, usage)
|
|
288
292
|
record_cost(span, cost, alias=pinned.alias)
|
|
289
|
-
record_content(
|
|
293
|
+
record_content(
|
|
294
|
+
span,
|
|
295
|
+
input_text=_prompt_text(request),
|
|
296
|
+
output_text=redact_values(text, request.redactions),
|
|
297
|
+
)
|
|
290
298
|
|
|
291
299
|
entry = LedgerEntry(
|
|
292
300
|
alias=pinned.alias,
|
|
@@ -358,7 +366,11 @@ class ModelGateway:
|
|
|
358
366
|
cost = spec.cost.cost_usd(response.usage)
|
|
359
367
|
record_usage(span, response.usage)
|
|
360
368
|
record_cost(span, cost, alias=pinned.alias)
|
|
361
|
-
record_content(
|
|
369
|
+
record_content(
|
|
370
|
+
span,
|
|
371
|
+
input_text=_prompt_text(request),
|
|
372
|
+
output_text=redact_values(response.text, request.redactions),
|
|
373
|
+
)
|
|
362
374
|
if len(attempted) > 1:
|
|
363
375
|
span.set_attribute(ATTRIBUTES["attempts"], list(attempted))
|
|
364
376
|
|
|
@@ -15,6 +15,7 @@ from typing import Self
|
|
|
15
15
|
from pydantic import BaseModel, ConfigDict, Field
|
|
16
16
|
|
|
17
17
|
from aid_runtime.errors import PromptNotFoundError, PromptRenderError
|
|
18
|
+
from aid_runtime.redaction import Redaction
|
|
18
19
|
|
|
19
20
|
__all__ = ["Example", "PromptRegistry", "PromptTemplate", "RenderedPrompt"]
|
|
20
21
|
|
|
@@ -89,6 +90,7 @@ class PromptTemplate(BaseModel):
|
|
|
89
90
|
version=self.version,
|
|
90
91
|
text=body,
|
|
91
92
|
examples=self.examples,
|
|
93
|
+
bindings=tuple(sorted(values.items())),
|
|
92
94
|
)
|
|
93
95
|
|
|
94
96
|
|
|
@@ -106,6 +108,14 @@ class RenderedPrompt(BaseModel):
|
|
|
106
108
|
version: str
|
|
107
109
|
text: str
|
|
108
110
|
examples: tuple[Example, ...] = ()
|
|
111
|
+
#: Every ``(name, value)`` pair the caller supplied, so a redact set naming a
|
|
112
|
+
#: field can be turned into the exact substring to strip from a recorded copy.
|
|
113
|
+
bindings: tuple[Redaction, ...] = ()
|
|
114
|
+
|
|
115
|
+
def redactions(self, names: Iterable[str]) -> tuple[Redaction, ...]:
|
|
116
|
+
"""The bound pairs whose variable name appears in ``names``."""
|
|
117
|
+
wanted = set(names)
|
|
118
|
+
return tuple((name, value) for name, value in self.bindings if name in wanted)
|
|
109
119
|
|
|
110
120
|
def as_messages(self, *, system: str | None = None) -> tuple[tuple[str, str], ...]:
|
|
111
121
|
"""Flatten to ``(role, content)`` pairs, examples inlined as few-shot turns."""
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Value-bound redaction for recorded traces.
|
|
2
|
+
|
|
3
|
+
``observability.redact`` names *fields*, and a field name cannot be stripped out of
|
|
4
|
+
prose. What can be stripped is a **value**: the moment a prompt is rendered, the
|
|
5
|
+
runtime knows which variable supplied which substring, so a name in the redact set
|
|
6
|
+
becomes an exact value to remove from the copy that is written to a trace.
|
|
7
|
+
|
|
8
|
+
Redaction applies to the recorded copy only. The model still receives what the
|
|
9
|
+
application sent, because editing a request would change the answer and a framework
|
|
10
|
+
that silently rewrote one could not honestly report what it ran.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from collections.abc import Iterable, Sequence
|
|
16
|
+
|
|
17
|
+
__all__ = ["REDACTED_FORMAT", "redact_values"]
|
|
18
|
+
|
|
19
|
+
#: What replaces a stripped value. The field name, not the value, so a trace reader
|
|
20
|
+
#: can still see that a field was present and which one it was.
|
|
21
|
+
REDACTED_FORMAT = "[redacted:{name}]"
|
|
22
|
+
|
|
23
|
+
#: One ``(name, value)`` pair bound when a prompt was rendered.
|
|
24
|
+
Redaction = tuple[str, str]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _usable(pairs: Iterable[Redaction]) -> list[Redaction]:
|
|
28
|
+
"""The pairs that can be applied at all.
|
|
29
|
+
|
|
30
|
+
A blank value is dropped rather than replaced: ``str.replace("", marker)``
|
|
31
|
+
inserts a marker at every position, so an empty variable would destroy the
|
|
32
|
+
text it was meant to protect instead of protecting it.
|
|
33
|
+
"""
|
|
34
|
+
return [(name, value) for name, value in pairs if value.strip() != ""]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def redact_values(text: str, pairs: Sequence[Redaction]) -> str:
|
|
38
|
+
"""Replace every occurrence of a bound value with ``[redacted:name]``."""
|
|
39
|
+
if not text or not pairs:
|
|
40
|
+
return text
|
|
41
|
+
redacted = text
|
|
42
|
+
# Longest value first: where one value contains another, the shorter pass would
|
|
43
|
+
# otherwise leave a fragment of the longer one on either side of its marker.
|
|
44
|
+
for name, value in sorted(_usable(pairs), key=lambda pair: len(pair[1]), reverse=True):
|
|
45
|
+
redacted = redacted.replace(value, REDACTED_FORMAT.format(name=name))
|
|
46
|
+
return redacted
|
|
@@ -194,9 +194,11 @@ def record_content(span: Span, *, input_text: str | None, output_text: str | Non
|
|
|
194
194
|
|
|
195
195
|
- The sink writes to a local directory that a repository may commit and a CI log
|
|
196
196
|
may echo, so text that is off by default cannot leak by accident.
|
|
197
|
-
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
- Redaction happens before this call, in the caller that rendered the prompt: the
|
|
198
|
+
gateway replaces every value the spec withholds with ``[redacted:<name>]`` in the
|
|
199
|
+
text it hands to this function, so what arrives here is already the recordable
|
|
200
|
+
form. This function does not redact, and must not: it receives prose, not the
|
|
201
|
+
field bindings a value could be recognised by.
|
|
200
202
|
- ``aid trace export --dataset`` is the one reader that wants the text, and it
|
|
201
203
|
can only build a case from a run that recorded one.
|
|
202
204
|
|
|
@@ -264,18 +264,29 @@ class CompletionRequest(BaseModel):
|
|
|
264
264
|
tools: tuple[ToolDefinition, ...] = ()
|
|
265
265
|
stop: tuple[str, ...] = ()
|
|
266
266
|
metadata: dict[str, str] = Field(default_factory=dict)
|
|
267
|
+
#: ``(name, value)`` pairs bound by the redact set, used only for the recorded
|
|
268
|
+
#: copy of this call. They never reach the provider and never change a fingerprint.
|
|
269
|
+
redactions: tuple[tuple[str, str], ...] = ()
|
|
267
270
|
|
|
268
271
|
@classmethod
|
|
269
|
-
def prompt(
|
|
272
|
+
def prompt(
|
|
273
|
+
cls,
|
|
274
|
+
text: str,
|
|
275
|
+
*,
|
|
276
|
+
system: str | None = None,
|
|
277
|
+
redactions: tuple[tuple[str, str], ...] = (),
|
|
278
|
+
) -> CompletionRequest:
|
|
270
279
|
messages = []
|
|
271
280
|
if system is not None:
|
|
272
281
|
messages.append(Message.system(system))
|
|
273
282
|
messages.append(Message.user(text))
|
|
274
|
-
return cls(messages=tuple(messages))
|
|
283
|
+
return cls(messages=tuple(messages), redactions=redactions)
|
|
275
284
|
|
|
276
285
|
def fingerprint(self) -> str:
|
|
277
286
|
"""Stable hash of everything that can change the model's output."""
|
|
278
|
-
|
|
287
|
+
# ``redactions`` is excluded: it describes how the call is *recorded*, so two
|
|
288
|
+
# calls that differ only in their redact set must share one cache entry.
|
|
289
|
+
payload = self.model_dump(mode="json", exclude_none=True, exclude={"redactions"})
|
|
279
290
|
blob = json.dumps(payload, sort_keys=True, separators=(",", ":"))
|
|
280
291
|
return hashlib.sha256(blob.encode("utf-8")).hexdigest()
|
|
281
292
|
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime_python.egg-info/PKG-INFO
RENAMED
|
@@ -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
|
|
@@ -13,6 +13,7 @@ src/aid_runtime/metrics.py
|
|
|
13
13
|
src/aid_runtime/pipeline.py
|
|
14
14
|
src/aid_runtime/prompts.py
|
|
15
15
|
src/aid_runtime/py.typed
|
|
16
|
+
src/aid_runtime/redaction.py
|
|
16
17
|
src/aid_runtime/steps.py
|
|
17
18
|
src/aid_runtime/structured.py
|
|
18
19
|
src/aid_runtime/telemetry.py
|
|
@@ -101,6 +102,7 @@ tests/test_package.py
|
|
|
101
102
|
tests/test_pipeline.py
|
|
102
103
|
tests/test_prompts.py
|
|
103
104
|
tests/test_recorded_provider.py
|
|
105
|
+
tests/test_redaction.py
|
|
104
106
|
tests/test_retrieval_chunking.py
|
|
105
107
|
tests/test_retrieval_citations.py
|
|
106
108
|
tests/test_retrieval_connectors.py
|
|
@@ -11,6 +11,7 @@ alone would let the real regression through.
|
|
|
11
11
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
|
+
import json
|
|
14
15
|
import math
|
|
15
16
|
from pathlib import Path
|
|
16
17
|
|
|
@@ -22,6 +23,7 @@ from aid_runtime import (
|
|
|
22
23
|
CostProfile,
|
|
23
24
|
Dataset,
|
|
24
25
|
EvalBaseline,
|
|
26
|
+
EvalCase,
|
|
25
27
|
EvalError,
|
|
26
28
|
EvalRun,
|
|
27
29
|
ExactMatch,
|
|
@@ -422,3 +424,64 @@ async def test_a_failing_pass_names_the_cases_that_moved(dataset: Dataset) -> No
|
|
|
422
424
|
assert len(failures) == 1
|
|
423
425
|
assert f"FAIL {failures[0].case_id}:" in summary
|
|
424
426
|
assert pass_result.outcome(failures[0].case_id).passed is False
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
async def test_a_run_records_the_spend_and_latency_of_each_pass(dataset: Dataset) -> None:
|
|
430
|
+
"""A baseline can only answer a cost comparison if the run that made it recorded one.
|
|
431
|
+
|
|
432
|
+
``evaluate_once`` already measures both numbers to publish ``eval.cost`` and
|
|
433
|
+
``eval.latency.p95``. A published series an alarm watches is not the same thing as a
|
|
434
|
+
committed baseline a promotion compares against, so this asserts the numbers survive
|
|
435
|
+
into the baseline as well.
|
|
436
|
+
"""
|
|
437
|
+
run = await run_evaluation(
|
|
438
|
+
dataset, _runner(dataset, accuracy=1.0, seed=0), (ExactMatch(),), runs=3
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
assert len(run.cost_usd) == 3
|
|
442
|
+
assert len(run.latency_ms) == 3
|
|
443
|
+
assert all(value >= 0.0 for value in run.cost_usd)
|
|
444
|
+
|
|
445
|
+
baseline = EvalBaseline.from_run(run, model="fake-small-1")
|
|
446
|
+
assert baseline.cost is not None
|
|
447
|
+
assert baseline.cost.runs == 3
|
|
448
|
+
assert baseline.cost.mean == pytest.approx(sum(run.cost_usd) / 3)
|
|
449
|
+
assert baseline.latency is not None
|
|
450
|
+
assert baseline.latency.runs == 3
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
def test_a_baseline_without_recorded_spend_omits_the_key_and_reads_as_absent() -> None:
|
|
454
|
+
"""An old committed baseline keeps validating, and never claims a spend of zero.
|
|
455
|
+
|
|
456
|
+
Every baseline written before spend was recorded has no ``cost`` key. Reading one as
|
|
457
|
+
``$0.00`` would make every candidate look like an infinite cost increase, so the
|
|
458
|
+
absent key has to mean "not recorded" -- which is exactly what ``None`` is.
|
|
459
|
+
"""
|
|
460
|
+
payload = (
|
|
461
|
+
'{"dataset": "capitals", "dataset_version": "1.0.0", "model": "fake-small-1",'
|
|
462
|
+
' "metrics": [{"metric": "exact-match", "runs": 2, "mean": 1.0, "stdev": 0.0}],'
|
|
463
|
+
' "note": ""}'
|
|
464
|
+
)
|
|
465
|
+
baseline = EvalBaseline.from_json(payload)
|
|
466
|
+
|
|
467
|
+
assert baseline.cost is None
|
|
468
|
+
assert baseline.latency is None
|
|
469
|
+
assert "cost" not in json.loads(baseline.to_json())
|
|
470
|
+
assert json.loads(baseline.to_json()) == json.loads(payload)
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
async def test_a_runner_that_meters_nothing_records_no_spend(dataset: Dataset) -> None:
|
|
474
|
+
"""``None`` and ``0.0`` stay different answers all the way into the baseline.
|
|
475
|
+
|
|
476
|
+
A scripted runner spends nothing and cannot say so, because it has no ledger. A run
|
|
477
|
+
built from its passes carries no spend figure at all, so a baseline recorded from it
|
|
478
|
+
leaves the cost comparison unanswerable instead of answering it with zero.
|
|
479
|
+
"""
|
|
480
|
+
|
|
481
|
+
async def answer(case: EvalCase) -> str:
|
|
482
|
+
return case.id
|
|
483
|
+
|
|
484
|
+
run = await run_evaluation(dataset, answer, (ExactMatch(),), runs=2)
|
|
485
|
+
|
|
486
|
+
assert run.cost_usd == ()
|
|
487
|
+
assert EvalBaseline.from_run(run, model="scripted").cost is None
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Redaction: a redact set names fields, and a rendered prompt binds values to them."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from aid_runtime import REDACTED_FORMAT, CompletionRequest, PromptTemplate, redact_values
|
|
6
|
+
from aid_runtime.gateway import _prompt_text
|
|
7
|
+
|
|
8
|
+
EMAIL = "ada@example.com"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_a_bound_value_is_replaced_with_its_field_name() -> None:
|
|
12
|
+
text = f"contact: {EMAIL}"
|
|
13
|
+
|
|
14
|
+
assert redact_values(text, [("email", EMAIL)]) == "contact: [redacted:email]"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_no_pairs_leaves_the_text_alone() -> None:
|
|
18
|
+
assert redact_values(f"contact: {EMAIL}", []) == f"contact: {EMAIL}"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_a_blank_value_is_never_applied() -> None:
|
|
22
|
+
"""``str.replace("")`` would insert a marker everywhere and destroy the copy."""
|
|
23
|
+
assert redact_values("hello", [("email", " ")]) == "hello"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_the_longest_value_is_stripped_before_a_shorter_one_inside_it() -> None:
|
|
27
|
+
text = "id ada@example.com extra end"
|
|
28
|
+
pairs = [("email", "ada@example.com"), ("contact", "ada@example.com extra")]
|
|
29
|
+
|
|
30
|
+
redacted = redact_values(text, pairs)
|
|
31
|
+
|
|
32
|
+
assert redacted == f"id {REDACTED_FORMAT.format(name='contact')} end"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_every_occurrence_of_a_value_is_stripped() -> None:
|
|
36
|
+
text = f"{EMAIL} and {EMAIL}"
|
|
37
|
+
|
|
38
|
+
assert redact_values(text, [("email", EMAIL)]) == "[redacted:email] and [redacted:email]"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_a_rendered_prompt_exposes_only_the_bindings_that_were_named() -> None:
|
|
42
|
+
template = PromptTemplate(
|
|
43
|
+
name="classify",
|
|
44
|
+
version="1",
|
|
45
|
+
template="message: {message}\ncontact: {email}",
|
|
46
|
+
)
|
|
47
|
+
rendered = template.render(message="refund please", email=EMAIL)
|
|
48
|
+
|
|
49
|
+
assert rendered.redactions(["email"]) == (("email", EMAIL),)
|
|
50
|
+
assert rendered.redactions([]) == ()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_the_trace_keeps_the_redacted_copy_and_the_model_keeps_the_original() -> None:
|
|
54
|
+
"""Redaction is a recording decision: it must never edit what was sent."""
|
|
55
|
+
template = PromptTemplate(
|
|
56
|
+
name="classify",
|
|
57
|
+
version="1",
|
|
58
|
+
template="message: {message}\ncontact: {email}",
|
|
59
|
+
)
|
|
60
|
+
rendered = template.render(message="refund please", email=EMAIL)
|
|
61
|
+
request = CompletionRequest.prompt(
|
|
62
|
+
rendered.text,
|
|
63
|
+
redactions=rendered.redactions(["email"]),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
assert EMAIL not in _prompt_text(request)
|
|
67
|
+
assert "[redacted:email]" in _prompt_text(request)
|
|
68
|
+
assert EMAIL in request.messages[-1].content
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_redactions_do_not_change_the_fingerprint() -> None:
|
|
72
|
+
"""A redact set describes the recording, not the call, so a cache key survives it."""
|
|
73
|
+
plain = CompletionRequest.prompt("hello")
|
|
74
|
+
redacted = CompletionRequest.prompt("hello", redactions=(("email", EMAIL),))
|
|
75
|
+
|
|
76
|
+
assert plain.fingerprint() == redacted.fingerprint()
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/__init__.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/chat_model.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/deep_agents.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/agents/guardrails.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/agent_runner.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/predicate.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/evals/trajectory.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/__init__.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/anthropic.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/bedrock.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/gemini.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/gemini_wire.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/recorded.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/providers/vertex.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/__init__.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/chunking.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/citations.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/connectors.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/embedding.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/filters.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/hybrid.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/metrics.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/pgvector.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/rerank.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/retriever.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/stores.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/src/aid_runtime/retrieval/types.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_guardrails_model_armor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_connectors.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.160 → aid_runtime_python-0.1.162}/tests/test_retrieval_knowledge_base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|