StateTool
class StateTool<State>(val spec: ToolSpec, val execute: suspend (State, JsonObject) -> ToolOutcome<State>)
A function a model may call that reads the state of the run and changes it: add a line to an order, book a seat, move a piece. What it did is in the state, so a checkpoint holds it and the next node sees it.
@Serializable
data class NewLine(@Description("The item, for example \"margherita\"") val item: String)
val addLine = StateTool<Order, NewLine>("add_line", "Adds a line to the order.") { order, line ->
ToolOutcome(order.copy(lines = order.lines + line.item), "Added ${line.item}.")
}Content copied to clipboard
Give it to toolLoop as one of its stateTools. A Tool is enough for a function that only needs its input, such as a lookup.
Use this constructor when you write the schema by hand.