import { Tool } from '../types/index.js'; export const weatherTool: Tool = { name: 'get_weather', description: '获取指定城市的当前天气信息', parameters: { type: 'object', properties: { city: { type: 'string', description: '城市名称,如"北京"、"上海"' }, }, required: ['city'], }, execute: async (args) => { // 模拟异步 API 调用 const weathers = ['晴', '多云', '小雨', '阴天']; const picked = weathers[Math.floor(Math.random() * weathers.length)]; return `城市:${args.city},天气:${picked},温度:${Math.floor(Math.random() * 15 + 15)}°C`; }, };