UNPKG

@mastra/core

Version:
34 lines 2.12 kB
import type { LanguageModelV2FunctionTool, LanguageModelV2ProviderDefinedTool, LanguageModelV2ToolChoice } from '../../../../_types/@ai-sdk_provider-v5/dist/index.d.ts'; import type { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, LanguageModelV3ToolChoice } from '../../../../_types/@ai-sdk_provider-v6/dist/index.d.ts'; import type { Tool, ToolChoice } from '../../../../_types/@internal_ai-sdk-v5/dist/index.d.ts'; import type { ModelToolDefinition } from '../../../../observability/index.js'; /** Model specification version for tool type conversion */ export type ModelSpecVersion = 'v2' | 'v3' | 'v4'; /** Combined tool types for both V2 and V3 */ type PreparedTool = LanguageModelV2FunctionTool | LanguageModelV2ProviderDefinedTool | LanguageModelV3FunctionTool | LanguageModelV3ProviderTool; type PreparedToolChoice = LanguageModelV2ToolChoice | LanguageModelV3ToolChoice; export declare function prepareToolsAndToolChoice<TOOLS extends Record<string, Tool>>({ tools, toolChoice, activeTools, targetVersion, }: { tools: TOOLS | undefined; toolChoice: ToolChoice<TOOLS> | undefined; activeTools: Array<keyof TOOLS> | undefined; /** Target model version: 'v2' for AI SDK v5, 'v3' for AI SDK v6, 'v4' for AI SDK v7. Defaults to 'v2'. */ targetVersion?: ModelSpecVersion; }): { tools: PreparedTool[] | undefined; toolChoice: PreparedToolChoice | undefined; }; /** * Serialize a tool set into `ModelToolDefinition[]` for the `tools` attribute * on MODEL_GENERATION spans, reusing the same conversion the provider request * goes through so exporters see the schemas the model actually received. * * Never throws — tracing must not break model execution. Returns undefined * when there are no tools or serialization fails. */ export declare function getToolDefinitionsForTracing<TOOLS extends Record<string, Tool>>({ tools, toolChoice, activeTools, }: { tools: TOOLS | undefined; toolChoice: ToolChoice<TOOLS> | undefined; activeTools: Array<keyof TOOLS> | undefined; }): ModelToolDefinition[] | undefined; export {}; //# sourceMappingURL=prepare-tools.d.ts.map