According to the Tool documentation, the arguments to the tool are specified as a static struct type T, which is given to tool.call(argument: T) However, if the arguments are not known until runtime, is it possible to still create a Tool object with the proper parameters? Let's say a JSON-style dictionary is passed into the Tool init function to specify T, is this achievable?
Hi @ecoarcgaming, dynamically defined tool parameters are fully supported. In your tool implementation, you just need to implement var parameters: GenerationSchema
and pass GeneratedContent
as the argument to the call
method. Here's documentation on defining generation schemas at runtime.
struct MyDynamicTool: Tool {
// name, description...
var parameters: GenerationSchema {
// Define your parameters at runtime
}
func call(arguments: GeneratedContent) -> ToolOutput { ... }
}