asToolsByInterface
Converts all instance methods of class/interface T marked as Tool to a list of tools that will be called on object this.
Note: if you manually specify type parameter T that is more common type that the class of this object (like derivedToolset.asTools<MyToolsetInterface>()
) so only the methods of the specified generic type will be converted.
See asTool for detailed description.
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.asToolsByInterface<MyToolsetInterface>() // only interface methods will be added
Content copied to clipboard