Tool

class Tool(val spec: ToolSpec, val execute: suspend (JsonObject) -> String)

A function a model may call. The usual way to create one is from a @Serializable class that holds the input, which also gives the model the input's schema:

@Serializable
data class Forecast(
@Description("The city, for example \"Madrid\"") val city: String,
val days: Int = 1,
)

val forecast = Tool<Forecast>("forecast", "Returns the weather forecast of a city.") { input ->
weatherService.forecast(input.city, input.days)
}

Use this constructor when you write the schema by hand.

Constructors

Link copied to clipboard
constructor(spec: ToolSpec, execute: suspend (JsonObject) -> String)

Properties

Link copied to clipboard
val execute: suspend (JsonObject) -> String

runs the tool with the input the model sent and returns the text the model gets back. An exception it throws reaches the model as an error result; see List.execute.

Link copied to clipboard

what the model is told about the tool.