koryTool
inline fun <ARGS, R> koryTool(name: String, description: String? = null, noinline block: (ARGS) -> R): KoryTool<ARGS, R>
Creates a KoryTool from a lambda.
Return
A KoryTool instance.
Parameters
name
The tool's name.
description
A human-readable description of what the tool does.
block
The function to execute when the tool is called.
Type Parameters
ARGS
The type of the tool's input arguments.
R
The return type of the tool's execution.
See also
Samples
@Serializable // @Serializable from kotlinx.serialization for serialization custom data class.
data class TestWeatherToolArgs(
@ToolParam(description = "Location for which weather information is needed") // Description about `location` field for AI.
val location: String
)
val testWeatherTool = koryTool<TestWeatherToolArgs, String>(
name = "get_weather", // Name for tool.
description = "Get weather for the selected location" // Description for tool.
) { args ->
"Current weather in ${args.location} is sunny, 27°C"
}Content copied to clipboard