const weatherTool = tool({
name: 'getWeather',
description: '查询城市的天气信息',
schema: z.object({ city: z.string().describe('城市名称') }),
execute: async input => getWeather(input.city),
})
const calculatorTool = tool({
name: 'calculator',
description: '执行数学计算',
schema: z.object({ expression: z.string().describe('数学表达式') }),
execute: async input => evaluate(input.expression),
})
const agent = createAgent({
model,
tools: [weatherTool, calculatorTool],
})
const result = await agent.generate({
prompt: '北京天气怎么样?另外帮我算一下 25 * 4。',
})