Package-level declarations

Types

Link copied to clipboard

The script of a ScriptedChatModel: each call adds the answer to one request, in order.

Link copied to clipboard

The script of a ScriptedDecisionModel: each call adds the decision for one request, in order.

Link copied to clipboard

The checks of a test or a replay. Each check is about what happened right after what the check before it was about, so a test reads as the path of the run:

Link copied to clipboard
class RunRecord<State>(val events: List<GraphEvent<State>>)

What happened in one run of a graph, read from the events of its stream. Get one with record.

Link copied to clipboard

A ChatModel for tests: it gives the answers of its script, in the order they were written, and keeps every request it received. A graph with an agent is tested with it without an API key and without a network.

Link copied to clipboard

A DecisionModel for tests: it gives the decisions of its script, in the order they were written, and keeps every request it received. A graph that is routed by a model is tested with it without an API key.

Functions

Link copied to clipboard
suspend fun <State> Flow<GraphEvent<State>>.record(): RunRecord<State>

Runs the graph of this stream to its end and returns what happened, in a form a test can compare:

Link copied to clipboard
suspend fun <State> CompiledGraph<State>.replay(checkpoint: Checkpoint<State>, config: GraphConfig<State> = GraphConfig(), update: suspend (State) -> State = { it }, scenario: suspend GraphTest<State>.() -> Unit)

Runs this graph again from checkpoint, a checkpoint of an earlier run, and checks in scenario what it does from there. scenario holds the same checks as in test.

Link copied to clipboard
suspend fun <State> CompiledGraph<State>.test(input: State, config: GraphConfig<State> = GraphConfig(), scenario: suspend GraphTest<State>.() -> Unit)

Runs this graph with input and checks, in scenario, the path the run takes: which nodes finish, in which order, where the run pauses and how it ends.