yaab.testing¶
Offline deterministic models for tests and examples.
yaab.testing ¶
Testing utilities — deterministic models and fixtures, no API keys needed.
CassetteMiss ¶
Bases: YaabError
Raised when a CassetteModel in replay mode has no recorded interaction matching a request (unknown key, or the recorded sequence is exhausted).
CassetteModel ¶
Record/replay wrapper around a ModelProvider.
modes: record (always call inner, append), once (replay if present
else call+append), replay (replay only; miss -> CassetteMiss).
FunctionModel ¶
A model whose response is computed by a user-supplied function.
TestModel ¶
A scripted, deterministic model.
Parameters¶
custom_output:
Text to return as the final assistant message.
responses:
A sequence of :class:ModelResponse (or strings) returned in order,
one per complete call. Overrides custom_output when set.
call_tools:
Tool names to call (with empty args) on the first response, before
producing a final text answer. Useful for exercising the tool loop.
structured_output:
A dict returned (JSON-encoded) when the agent requests structured
output, so output validation can be tested without a real model.
use_cassette ¶
use_cassette(path: str | Path, *, inner: ModelProvider | None = None, mode: Literal['once', 'record', 'replay'] | None = None) -> Iterator[CassetteModel]
Yield a CassetteModel. mode defaults from env: YAAB_RECORD=1 with an
inner records, otherwise replays — so devs record once and CI replays.