( tools: RunAgentInput["tools"], )
| 640 | } |
| 641 | |
| 642 | export function convertToolsToVercelAITools( |
| 643 | tools: RunAgentInput["tools"], |
| 644 | ): ToolSet { |
| 645 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 646 | const result: Record<string, any> = {}; |
| 647 | |
| 648 | for (const tool of tools) { |
| 649 | if (!isJsonSchema(tool.parameters)) { |
| 650 | throw new Error(`Invalid JSON schema for tool ${tool.name}`); |
| 651 | } |
| 652 | const zodSchema = convertJsonSchemaToZodSchema(tool.parameters, true); |
| 653 | result[tool.name] = createVercelAISDKTool({ |
| 654 | description: tool.description, |
| 655 | inputSchema: toLanguageModelSchema(zodSchema), |
| 656 | }); |
| 657 | } |
| 658 | |
| 659 | return result; |
| 660 | } |
| 661 | |
| 662 | /** |
| 663 | * Check whether a schema is a Zod schema by inspecting its Standard Schema vendor. |
no test coverage detected
searching dependent graphs…