// 来自 multimodal/tarko/agent/examples/tool-calls/basic.ts
import { Agent, Tool, z, LogLevel } from '@tarko/agent';
const locationTool = new Tool({
id: 'getCurrentLocation',
description: "获取用户当前位置",
parameters: z.object({}),
function: async () => {
return { location: 'Boston' };
},
});
const weatherTool = new Tool({
id: 'getWeather',
description: '获取指定位置的天气信息',
parameters: z.object({
location: z.string().describe('位置名称,如城市名'),
}),
function: async (input) => {
const { location } = input;
return {
location,
temperature: '70°F (21°C)',
condition: 'Sunny',
precipitation: '10%',
humidity: '45%',
wind: '5 mph',
};
},
});
const agent = new Agent({
model: {
provider: 'volcengine',
id: 'doubao-seed-1-6-vision-250815',
apiKey: process.env.ARK_API_KEY,
},
tools: [locationTool, weatherTool],
logLevel: LogLevel.DEBUG,
});
export default agent;