ai-sdk-next-openai/app/api/use-chat-human-in-the-loop/tools.ts
2025-09-26 15:46:29 +00:00

25 lines
729 B
TypeScript

import { tool, ToolSet } from 'ai';
import { z } from 'zod';
const getWeatherInformation = tool({
description: 'show the weather in a given city to the user',
inputSchema: z.object({ city: z.string() }),
outputSchema: z.string(), // must define outputSchema
// no execute function, we want human in the loop
});
const getLocalTime = tool({
description: 'get the local time for a specified location',
inputSchema: z.object({ location: z.string() }),
// including execute function -> no confirmation required
execute: async ({ location }) => {
console.log(`Getting local time for ${location}`);
return '10am';
},
});
export const tools = {
getWeatherInformation,
getLocalTime,
} satisfies ToolSet;