aid-runtime-python 0.1.93__tar.gz → 0.1.95__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.93 → aid_runtime_python-0.1.95}/PKG-INFO +1 -1
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/pyproject.toml +1 -1
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/__init__.py +3 -1
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/guardrails.py +11 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/control.py +90 -2
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime_python.egg-info/PKG-INFO +1 -1
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_control.py +127 -1
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_guardrails.py +13 -1
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/README.md +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/setup.cfg +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/__init__.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/chat_model.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/deep_agents.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/engine.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/ir.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/loop.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/memory.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/policy.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/state.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/cache.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/concurrency.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/cost.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/decisions.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/errors.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/evals/__init__.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/evals/dataset.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/evals/gate.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/evals/metrics.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/evals/predicate.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/evals/runner.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/gateway.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/local_trace.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/pipeline.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/prompts.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/__init__.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/anthropic.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/base.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/bedrock.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/fake.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/http.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/vertex.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/py.typed +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/__init__.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/chunking.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/citations.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/connectors.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/embedding.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/gate.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/hybrid.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/metrics.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/pgvector.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/rerank.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/retriever.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/stores.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/types.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/steps.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/structured.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/tools.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/tracing.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/types.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime_python.egg-info/SOURCES.txt +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime_python.egg-info/dependency_links.txt +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime_python.egg-info/requires.txt +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime_python.egg-info/top_level.txt +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_agents_budget.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_agents_deep_agents.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_agents_hitl.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_agents_loop.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_agents_memory.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_anthropic_provider.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_bedrock_provider.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_cache.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_concurrency.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_cost.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_dataset.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_decisions.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_evals.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_evals_assert_gate.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_evals_decision.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_evals_gate.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_evals_predicate.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_gateway.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_http_provider.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_local_trace.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_package.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_pipeline.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_prompts.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_chunking.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_citations.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_connectors.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_embedding.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_gate.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_hybrid.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_metrics.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_rerank.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_stores.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_retrieval_types.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_steps.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_streaming.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_structured.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_tool_permissions.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_tools.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_tracing.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/tests/test_types.py +0 -0
- {aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/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.95
|
|
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.95"
|
|
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"
|
|
@@ -60,6 +60,7 @@ from aid_runtime.control import (
|
|
|
60
60
|
map_step,
|
|
61
61
|
parallel,
|
|
62
62
|
reduce_step,
|
|
63
|
+
route,
|
|
63
64
|
)
|
|
64
65
|
from aid_runtime.cost import (
|
|
65
66
|
Budget,
|
|
@@ -294,7 +295,7 @@ from aid_runtime.types import (
|
|
|
294
295
|
)
|
|
295
296
|
|
|
296
297
|
#: Kept in sync with ``pyproject.toml`` by a test, so the two cannot drift.
|
|
297
|
-
__version__ = "0.1.
|
|
298
|
+
__version__ = "0.1.95"
|
|
298
299
|
|
|
299
300
|
__all__ = [
|
|
300
301
|
"ANTHROPIC_VERSION",
|
|
@@ -539,6 +540,7 @@ __all__ = [
|
|
|
539
540
|
"resolve_uri",
|
|
540
541
|
"retrieval_metrics",
|
|
541
542
|
"retrieve_step",
|
|
543
|
+
"route",
|
|
542
544
|
"rrf_score",
|
|
543
545
|
"run_evaluation",
|
|
544
546
|
"run_structured",
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/guardrails.py
RENAMED
|
@@ -461,6 +461,17 @@ class GuardrailEngine:
|
|
|
461
461
|
"input",
|
|
462
462
|
f"decision {name!r} answered {label!r}, which this guardrail does not map",
|
|
463
463
|
)
|
|
464
|
+
if guardrail.min_confidence > 0 and answer.confidence is None:
|
|
465
|
+
# A `noul` answer carries only its probability, and the wire contract forbids
|
|
466
|
+
# a confidence on it. A floor that cannot be read must not pass: silently
|
|
467
|
+
# treating the missing value as "no opinion, therefore allow" is exactly the
|
|
468
|
+
# failure this check exists to stop.
|
|
469
|
+
raise GuardrailBlockedError(
|
|
470
|
+
guardrail.id,
|
|
471
|
+
"input",
|
|
472
|
+
f"decision {name!r} answered without a confidence, and this guardrail "
|
|
473
|
+
f"requires at least {guardrail.min_confidence:.2f}",
|
|
474
|
+
)
|
|
464
475
|
if answer.confidence is not None and answer.confidence < guardrail.min_confidence:
|
|
465
476
|
raise GuardrailBlockedError(
|
|
466
477
|
guardrail.id,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Composite pipeline steps: ``branch``, ``parallel``, ``map`` and ``reduce``.
|
|
1
|
+
"""Composite pipeline steps: ``branch``, ``route``, ``parallel``, ``map`` and ``reduce``.
|
|
2
2
|
|
|
3
3
|
:class:`~aid_runtime.pipeline.Pipeline` is a sequential reducer, and it stays one.
|
|
4
4
|
Each factory here returns an ordinary :data:`~aid_runtime.pipeline.Step`, so a
|
|
@@ -27,13 +27,18 @@ from __future__ import annotations
|
|
|
27
27
|
|
|
28
28
|
import asyncio
|
|
29
29
|
from collections.abc import Awaitable, Callable, Mapping, Sequence
|
|
30
|
-
from typing import Any, TypeVar
|
|
30
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
31
31
|
|
|
32
32
|
from aid_runtime.agents.policy import Principal, evaluate_policy, policy_source
|
|
33
33
|
from aid_runtime.concurrency import ConcurrencyLimiter, holds_slot
|
|
34
|
+
from aid_runtime.decisions import DecisionClient, DecisionQuestion
|
|
34
35
|
from aid_runtime.errors import PipelineError
|
|
35
36
|
from aid_runtime.pipeline import STEPS_KEY, Pipeline, PipelineContext
|
|
36
37
|
|
|
38
|
+
if TYPE_CHECKING:
|
|
39
|
+
from aid_runtime.agents.guardrails import DecisionAsker
|
|
40
|
+
from aid_runtime.agents.ir import DecisionDefinition
|
|
41
|
+
|
|
37
42
|
__all__ = [
|
|
38
43
|
"DEPTH_KEY",
|
|
39
44
|
"INDEX_KEY",
|
|
@@ -47,6 +52,7 @@ __all__ = [
|
|
|
47
52
|
"map_step",
|
|
48
53
|
"parallel",
|
|
49
54
|
"reduce_step",
|
|
55
|
+
"route",
|
|
50
56
|
]
|
|
51
57
|
|
|
52
58
|
#: Deepest composite nesting a pipeline may declare.
|
|
@@ -208,6 +214,88 @@ def branch(
|
|
|
208
214
|
return _named(_branch, name)
|
|
209
215
|
|
|
210
216
|
|
|
217
|
+
def route(
|
|
218
|
+
*,
|
|
219
|
+
decision: str,
|
|
220
|
+
state: str,
|
|
221
|
+
on: Mapping[str, Pipeline],
|
|
222
|
+
otherwise: Pipeline | None = None,
|
|
223
|
+
as_: str | None = None,
|
|
224
|
+
decisions: Mapping[str, DecisionDefinition] | None = None,
|
|
225
|
+
client_factory: Callable[[], DecisionAsker] | None = None,
|
|
226
|
+
max_depth: int = MAX_STEP_DEPTH,
|
|
227
|
+
name: str | None = None,
|
|
228
|
+
) -> CompositeStep:
|
|
229
|
+
"""Ask one ``choice`` decision which arm to run, then run that arm.
|
|
230
|
+
|
|
231
|
+
This is the one composite that asks a model a question, and it is the difference
|
|
232
|
+
between a ``branch`` and a ``route``: a branch's predicate is a policy over the
|
|
233
|
+
caller, so it can only answer who is asking. A route's question is asked about
|
|
234
|
+
``state`` -- the rendered text of what the pipeline has produced so far -- so it
|
|
235
|
+
can answer what the request *means*.
|
|
236
|
+
|
|
237
|
+
Every way the question can fail fails the run rather than picking an arm:
|
|
238
|
+
a decision with no definition in this runtime, a client that raises, an answer
|
|
239
|
+
with no choice, and a label no arm maps. A default is deliberately not a fourth
|
|
240
|
+
outcome; it is the arm an *unexpected* label runs, and the spec gate refuses a
|
|
241
|
+
default that a mapped set already covers.
|
|
242
|
+
|
|
243
|
+
``as_`` binds the label that was answered -- including one that fell through to
|
|
244
|
+
``otherwise`` -- so a later step can name the arm that ran rather than re-deriving
|
|
245
|
+
it. The client is built on first use, not when the pipeline is assembled: an app
|
|
246
|
+
with no TypeSafe key still boots as long as no request reaches a route.
|
|
247
|
+
"""
|
|
248
|
+
declared = dict(decisions or {})
|
|
249
|
+
factory = client_factory or DecisionClient
|
|
250
|
+
client: DecisionAsker | None = None
|
|
251
|
+
|
|
252
|
+
async def _route(context: PipelineContext) -> PipelineContext:
|
|
253
|
+
nonlocal client
|
|
254
|
+
nested = _enter(context, max_depth, f"route ({decision})")
|
|
255
|
+
definition = declared.get(decision)
|
|
256
|
+
if definition is None:
|
|
257
|
+
raise PipelineError(
|
|
258
|
+
f"route needs a definition for decision {decision!r}; the generated app "
|
|
259
|
+
f"carries one for every decision its routes name"
|
|
260
|
+
)
|
|
261
|
+
if client is None:
|
|
262
|
+
client = factory()
|
|
263
|
+
question = DecisionQuestion(
|
|
264
|
+
type="choice",
|
|
265
|
+
instructions=definition.instructions,
|
|
266
|
+
criteria=definition.criteria,
|
|
267
|
+
)
|
|
268
|
+
try:
|
|
269
|
+
response = await client.decide(
|
|
270
|
+
model=definition.model,
|
|
271
|
+
state=state,
|
|
272
|
+
questions={decision: question},
|
|
273
|
+
)
|
|
274
|
+
except Exception as error:
|
|
275
|
+
raise PipelineError(f"route decision {decision!r} could not answer: {error}") from error
|
|
276
|
+
answer = response.answers.get(decision)
|
|
277
|
+
label = None if answer is None else answer.choice
|
|
278
|
+
if label is None:
|
|
279
|
+
raise PipelineError(
|
|
280
|
+
f"route decision {decision!r} returned no choice, so no arm can be "
|
|
281
|
+
f"selected; a route does not guess which one was meant"
|
|
282
|
+
)
|
|
283
|
+
chosen = on.get(label)
|
|
284
|
+
if chosen is None:
|
|
285
|
+
if otherwise is None:
|
|
286
|
+
raise PipelineError(
|
|
287
|
+
f"route decision {decision!r} answered {label!r}, which no arm maps "
|
|
288
|
+
f"and no `default` catches"
|
|
289
|
+
)
|
|
290
|
+
chosen = otherwise
|
|
291
|
+
_, added = await _run_body(chosen, nested)
|
|
292
|
+
if as_ is not None:
|
|
293
|
+
added[as_] = label
|
|
294
|
+
return _escape(context.with_values(**added))
|
|
295
|
+
|
|
296
|
+
return _named(_route, name)
|
|
297
|
+
|
|
298
|
+
|
|
211
299
|
def parallel(
|
|
212
300
|
*,
|
|
213
301
|
branches: Sequence[Pipeline],
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/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.95
|
|
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
|
-
"""The composite step family: branch, parallel, map and
|
|
1
|
+
"""The composite step family: branch, parallel, map, reduce and route.
|
|
2
2
|
|
|
3
3
|
Each test drives real pipelines rather than asserting that the factories were
|
|
4
4
|
called, because every property this family promises -- the cap, the ordering, the
|
|
@@ -33,7 +33,10 @@ from aid_runtime import (
|
|
|
33
33
|
map_step,
|
|
34
34
|
parallel,
|
|
35
35
|
reduce_step,
|
|
36
|
+
route,
|
|
36
37
|
)
|
|
38
|
+
from aid_runtime.agents.ir import DecisionDefinition
|
|
39
|
+
from aid_runtime.decisions import DecisionAnswer, DecisionResponse
|
|
37
40
|
|
|
38
41
|
IS_AUTHENTICATED: Mapping[str, Any] = {"kind": "call", "name": "isAuthenticated", "args": []}
|
|
39
42
|
HAS_ROLE_ADMIN: Mapping[str, Any] = {
|
|
@@ -462,3 +465,126 @@ def test_the_sequence_guard_refuses_a_string_even_though_it_is_a_sequence() -> N
|
|
|
462
465
|
_items(context(text="abc"), "text", "map")
|
|
463
466
|
assert _items(context(text=["abc"]), "text", "map") == ["abc"]
|
|
464
467
|
assert isinstance([], Sequence)
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
TOPIC = DecisionDefinition(
|
|
471
|
+
id="topic",
|
|
472
|
+
model="jev-1.14.0",
|
|
473
|
+
instructions="Which part of the product is this question about",
|
|
474
|
+
criteria=("product", "billing"),
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
DECISIONS = {"topic": TOPIC}
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
class ScriptedAsker:
|
|
481
|
+
"""A ``DecisionAsker`` returning one scripted answer and recording every call."""
|
|
482
|
+
|
|
483
|
+
def __init__(self, choice: str | None = None, *, error: Exception | None = None) -> None:
|
|
484
|
+
self._choice = choice
|
|
485
|
+
self._error = error
|
|
486
|
+
self.calls: list[dict[str, Any]] = []
|
|
487
|
+
|
|
488
|
+
async def decide(
|
|
489
|
+
self,
|
|
490
|
+
*,
|
|
491
|
+
model: str,
|
|
492
|
+
state: Any,
|
|
493
|
+
questions: Any,
|
|
494
|
+
reproducible: bool = False,
|
|
495
|
+
) -> DecisionResponse:
|
|
496
|
+
self.calls.append({"model": model, "state": state, "questions": dict(questions)})
|
|
497
|
+
if self._error is not None:
|
|
498
|
+
raise self._error
|
|
499
|
+
answer = DecisionAnswer(type="choice", choice=self._choice)
|
|
500
|
+
return DecisionResponse(model=model, answers={"topic": answer})
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def topic_route(asker: ScriptedAsker, **kwargs: Any) -> Any:
|
|
504
|
+
"""A route over two mapped labels, so an answer outside them has to find a default."""
|
|
505
|
+
options: dict[str, Any] = {
|
|
506
|
+
"decision": "topic",
|
|
507
|
+
"state": "How much does the pro plan cost",
|
|
508
|
+
"on": {
|
|
509
|
+
"product": Pipeline.of(step("product_ran")),
|
|
510
|
+
"billing": Pipeline.of(step("billing_ran")),
|
|
511
|
+
},
|
|
512
|
+
"decisions": DECISIONS,
|
|
513
|
+
"client_factory": lambda: asker,
|
|
514
|
+
}
|
|
515
|
+
options.update(kwargs)
|
|
516
|
+
return route(**options)
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
async def test_route_runs_the_arm_the_decision_names_and_binds_the_label() -> None:
|
|
520
|
+
asker = ScriptedAsker("product")
|
|
521
|
+
result = await Pipeline.of(topic_route(asker, as_="path")).run(context())
|
|
522
|
+
|
|
523
|
+
assert result.get("product_ran") == "product_ran"
|
|
524
|
+
assert "billing_ran" not in result.values
|
|
525
|
+
assert result.get("path") == "product"
|
|
526
|
+
assert asker.calls[0]["state"] == "How much does the pro plan cost"
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
async def test_route_asks_a_choice_question_from_the_carried_definition() -> None:
|
|
530
|
+
asker = ScriptedAsker("product")
|
|
531
|
+
await Pipeline.of(topic_route(asker)).run(context())
|
|
532
|
+
|
|
533
|
+
assert asker.calls[0]["model"] == TOPIC.model
|
|
534
|
+
question = asker.calls[0]["questions"]["topic"]
|
|
535
|
+
assert question.type == "choice"
|
|
536
|
+
assert question.instructions == TOPIC.instructions
|
|
537
|
+
assert question.criteria == TOPIC.criteria
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
async def test_route_runs_the_default_for_an_unmapped_label_and_binds_it() -> None:
|
|
541
|
+
asker = ScriptedAsker("off_topic")
|
|
542
|
+
result = await Pipeline.of(
|
|
543
|
+
topic_route(asker, otherwise=Pipeline.of(step("default_ran")), as_="path")
|
|
544
|
+
).run(context())
|
|
545
|
+
|
|
546
|
+
assert result.get("default_ran") == "default_ran"
|
|
547
|
+
assert result.get("path") == "off_topic"
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
async def test_route_fails_closed_for_an_unmapped_label_with_no_default() -> None:
|
|
551
|
+
with pytest.raises(PipelineError, match="no arm maps"):
|
|
552
|
+
await Pipeline.of(topic_route(ScriptedAsker("off_topic"))).run(context())
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
async def test_route_fails_when_the_decision_has_no_definition() -> None:
|
|
556
|
+
asker = ScriptedAsker("product")
|
|
557
|
+
with pytest.raises(PipelineError, match="needs a definition"):
|
|
558
|
+
await Pipeline.of(topic_route(asker, decision="nowhere")).run(context())
|
|
559
|
+
|
|
560
|
+
assert asker.calls == []
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
async def test_route_fails_when_the_client_raises() -> None:
|
|
564
|
+
with pytest.raises(PipelineError, match="could not answer: vendor exploded"):
|
|
565
|
+
await Pipeline.of(
|
|
566
|
+
topic_route(ScriptedAsker("product", error=RuntimeError("vendor exploded")))
|
|
567
|
+
).run(context())
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
async def test_route_fails_when_the_answer_carries_no_choice() -> None:
|
|
571
|
+
with pytest.raises(PipelineError, match="returned no choice"):
|
|
572
|
+
await Pipeline.of(topic_route(ScriptedAsker())).run(context())
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
async def test_route_builds_its_client_on_first_use_and_reuses_it() -> None:
|
|
576
|
+
asker = ScriptedAsker("product")
|
|
577
|
+
built: list[ScriptedAsker] = []
|
|
578
|
+
|
|
579
|
+
def factory() -> ScriptedAsker:
|
|
580
|
+
built.append(asker)
|
|
581
|
+
return asker
|
|
582
|
+
|
|
583
|
+
pipeline = Pipeline.of(topic_route(asker, client_factory=factory))
|
|
584
|
+
assert built == []
|
|
585
|
+
|
|
586
|
+
await pipeline.run(context())
|
|
587
|
+
await pipeline.run(context())
|
|
588
|
+
|
|
589
|
+
assert built == [asker]
|
|
590
|
+
assert len(asker.calls) == 2
|
|
@@ -908,7 +908,7 @@ class FakeDecisionClient:
|
|
|
908
908
|
self,
|
|
909
909
|
label: str = "product",
|
|
910
910
|
*,
|
|
911
|
-
confidence: float = 0.9,
|
|
911
|
+
confidence: float | None = 0.9,
|
|
912
912
|
error: Exception | None = None,
|
|
913
913
|
) -> None:
|
|
914
914
|
self.label = label
|
|
@@ -1012,6 +1012,18 @@ async def test_a_low_confidence_answer_is_a_blocked_check() -> None:
|
|
|
1012
1012
|
)
|
|
1013
1013
|
|
|
1014
1014
|
|
|
1015
|
+
async def test_a_missing_confidence_cannot_satisfy_a_declared_floor() -> None:
|
|
1016
|
+
# A `noul` answer carries only its probability, and the wire contract forbids a
|
|
1017
|
+
# confidence on it. The floor must not be defaulted to "pass": a check whose value
|
|
1018
|
+
# cannot be read has not been passed.
|
|
1019
|
+
client = FakeDecisionClient(label="product", confidence=None)
|
|
1020
|
+
|
|
1021
|
+
with pytest.raises(GuardrailBlockedError, match="without a confidence"):
|
|
1022
|
+
await decision_engine(client).check_input_async(
|
|
1023
|
+
(decision_guardrail(min_confidence=0.6),), CLEAN
|
|
1024
|
+
)
|
|
1025
|
+
|
|
1026
|
+
|
|
1015
1027
|
async def test_an_answer_outside_the_declared_labels_is_a_blocked_check() -> None:
|
|
1016
1028
|
client = FakeDecisionClient(label="maybe")
|
|
1017
1029
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/chat_model.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/agents/deep_agents.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
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/__init__.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/anthropic.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/providers/bedrock.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/__init__.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/chunking.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/citations.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/connectors.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/embedding.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/metrics.py
RENAMED
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/pgvector.py
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime/retrieval/retriever.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
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime_python.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{aid_runtime_python-0.1.93 → aid_runtime_python-0.1.95}/src/aid_runtime_python.egg-info/requires.txt
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
|
|
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
|