final timeTool = Tool(
name: 'get_time',
description: 'Get current time in a location',
inputSchema: JsonSchema.create({
'type': 'object',
'properties': {
'location': {'type': 'string'},
},
'required': ['location'],
}),
onCall: (args) async {
// NOTE: insert actual timezone magic here
return {
'time': '3:42 PM',
'location': args['location'],
};
},
);
final agent = Agent('openai', tools: [timeTool]);
final result = await agent.send("What time is it in New York?");
print(result.output); // "It's currently 3:42 PM in New York"