StateTool

inline fun <State, Input> StateTool(name: String, description: String, noinline execute: suspend (State, Input) -> ToolOutcome<State>): StateTool<State>

Creates a StateTool for a graph with the state State, whose input is the @Serializable type Input. The input schema is built from the type as for a Tool. Use StateTool<State, Unit> for a tool that takes no input.

Parameters

name

how the model refers to the tool: 1 to 64 letters, digits, _ or -.

description

tells the model what the tool does and when to use it.

execute

runs the tool and returns the state it leaves and the text the model gets back.

Throws

if name is not valid, or Input is not a class or has a property of a type that cannot be described.


fun <State, Input> StateTool(name: String, description: String, serializer: KSerializer<Input>, execute: suspend (State, Input) -> ToolOutcome<State>): StateTool<State>

Creates a StateTool whose input is read with serializer. See the overload with a reified type.