asTools

fun ToolSet.asTools(json: Json = Json): List<ToolFromCallable>(source)

Converts all instance methods of this class marked as Tool to a list of tools.

See asTool for detailed description.

Parameters

json

The Json instance to use for serialization.

interface MyToolsetInterface : ToolSet {
@Tool
@LLMDescription("My best tool")
fun my_best_tool(arg1: String, arg2: Int)
}

class MyToolset : MyToolsetInterface {
@Tool
@LLMDescription("My best tool overridden description")
fun my_best_tool(arg1: String, arg2: Int) {
// ...
}

@Tool
@LLMDescription("My best tool 2")
fun my_best_tool_2(arg1: String, arg2: Int) {
// ...
}
}

val myToolset = MyToolset()
val tools = myToolset.asTools()

fun <T : ToolSet> KClass<out T>.asTools(json: Json = Json, thisRef: T? = null): List<ToolFromCallable>(source)

Converts all functions of this class marked as Tool to a list of tools.

Parameters

json

The Json instance to use for serialization.

thisRef

an instance of this class to be used as the 'this' object for the callable in the case of instance methods.

See also