import { tool } from '@ag-kit/tools';
import { z } from 'zod';
const weatherTool = tool(
async (input: unknown) => {
const { location } = input as { location: string };
return { location, temperature: 72, condition: 'sunny' };
},
{
name: 'get_weather',
description: '获取某个位置的天气',
schema: z.object({
location: z.string().describe('城市名称')
})
}
);
const agent = new Agent({
tools: [weatherTool],
instructions: '当被问及天气时使用 get_weather 工具。'
});