Skip to content
7 changes: 7 additions & 0 deletions packages/ai/src/agent/tools-to-model-tools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { LanguageModelV3FunctionTool } from '@ai-sdk/provider';
Comment thread
iNishant marked this conversation as resolved.
Outdated
import { asSchema, type ToolSet } from 'ai';

// Mirrors the tool→LanguageModelV3FunctionTool mapping in the core AI SDK's
// prepareToolsAndToolChoice (ai/src/prompt/prepare-tools-and-tool-choice.ts).
export async function toolsToModelTools(
Comment thread
iNishant marked this conversation as resolved.
tools: ToolSet
): Promise<LanguageModelV3FunctionTool[]> {
Expand All @@ -10,6 +12,11 @@ export async function toolsToModelTools(
name,
description: tool.description,
inputSchema: await asSchema(tool.inputSchema).jsonSchema,
...(tool.inputExamples != null
? { inputExamples: tool.inputExamples }
: {}),
providerOptions: tool.providerOptions,
...(tool.strict != null ? { strict: tool.strict } : {}),
Comment thread
iNishant marked this conversation as resolved.
Outdated
}))
);
}
Loading