execute method
Executes the tool with the given arguments.
Returns the result as a string. Implementations should handle
validation of args and throw exceptions for invalid inputs.
args should be of type T, which represents the structured arguments
for this tool.
Implementation
@override
Future<String> execute(CalculatorArgs args) async {
final op = args.operation;
final a = args.a;
final b = args.b;
num result;
switch (op) {
case 'add':
result = a + b;
break;
case 'subtract':
result = a - b;
break;
case 'multiply':
result = a * b;
break;
case 'divide':
if (b == 0) return 'Error: Division by zero';
result = a / b;
break;
default:
return 'Unknown operation';
}
return 'Result: $result';
}