UNPKG

@gensx/vercel-ai

Version:
29 lines (25 loc) 1.02 kB
/** * Check out the docs at https://www.gensx.com/docs * Find us on Github https://github.com/gensx-inc/gensx * Find us on Discord https://discord.gg/F5BSU8Kc */ import { executeExternalTool } from '@gensx/core'; import { jsonSchema } from 'ai'; import { toJsonSchema } from './zod.js'; // Utility function to convert ToolBox to Vercel AI SDK ToolSet format function asToolSet(toolBox) { return Object.entries(toolBox).reduce((acc, [name, toolDef]) => { acc[name] = { description: toolDef.description, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any inputSchema: jsonSchema(toJsonSchema(toolDef.params)), execute: async (args) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-return return await executeExternalTool(toolBox, name, args); }, }; return acc; }, {}); } export { asToolSet }; //# sourceMappingURL=tools.js.map