Tool
class Tool(val spec: ToolSpec, val reconcile: suspend (JsonObject) -> String??, 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)
}Content copied to clipboard
A tool that charges, books or sends something can also say how to find out whether a call that started did its work, with a reconcile. See the overload that takes one.
Use these constructors when you write the schema by hand.
Constructors
Properties
Link copied to clipboard
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.