UNPKG

@mastra/core

Version:
87 lines • 4.28 kB
import type { LanguageModelV2, LanguageModelV2CallOptions } from '../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js'; import type { MastraLanguageModelV2 } from '../../shared.types.js'; type StreamResult = Awaited<ReturnType<LanguageModelV2['doStream']>>; /** * Prepares function tool schemas for strict mode when an AI SDK 5 `@ai-sdk/azure` request is strict. * * The v2 Chat and Responses models copy the single `openai.strictJsonSchema` flag into every * function tool's `strict`, so opting into strict structured output also makes every tool strict. * Azure rejects a strict tool schema that leaves keys out of `required` or uses keywords such as * `uniqueItems` (#28593). Native `openai.*` models are left alone: OpenAI accepts constraints that * preparing would move into descriptions. */ export declare function prepareAzureStrictToolSchemas(options: LanguageModelV2CallOptions): LanguageModelV2CallOptions; /** * Wrapper class for AI SDK V5 (LanguageModelV2) that converts doGenerate to return * a stream format for consistency with Mastra's streaming architecture. */ export declare class AISDKV5LanguageModel implements MastraLanguageModelV2 { #private; /** * The language model must specify which language model interface version it implements. */ readonly specificationVersion: 'v2'; /** * Name of the provider for logging purposes. */ readonly provider: string; /** * Provider-specific model ID for logging purposes. */ readonly modelId: string; /** Full `provider/model` ID this model was resolved from, when known. */ id?: string; readonly gatewayId?: string; /** * Supported URL patterns by media type for the provider. * * The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`). * and the values are arrays of regular expressions that match the URL paths. * The matching should be against lower-case URLs. * Matched URLs are supported natively by the model and are not downloaded. * @returns A map of supported URL patterns by media type (as a promise or a plain object). */ supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>; /** * Whether the wrapped provider model sends native structured output (for example * `@ai-sdk/openai-compatible` models created with `supportsStructuredOutputs: true`). */ readonly supportsStructuredOutputs?: boolean; constructor(config: LanguageModelV2); doGenerate(options: LanguageModelV2CallOptions): Promise<{ content: Array<import("../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js").LanguageModelV2Content>; finishReason: import("../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js").LanguageModelV2FinishReason; usage: import("../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js").LanguageModelV2Usage; providerMetadata?: import("../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js").SharedV2ProviderMetadata; warnings: Array<import("../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js").LanguageModelV2CallWarning>; request: { body?: unknown; }; response: StreamResult['response']; stream: ReadableStream<any>; }>; doStream(options: LanguageModelV2CallOptions): Promise<{ stream: ReadableStream<import("../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js").LanguageModelV2StreamPart>; request?: { body?: unknown; }; response?: { headers?: import("../../../../_types/@ai-sdk_provider@2.0.5/dist/index.js").SharedV2Headers; }; }>; /** * Custom serialization for tracing/observability spans. * `#model` is already a true JS private field and not enumerable, so * the wrapped provider SDK client can't leak. This method makes the * safe shape explicit and avoids walking `supportedUrls` (a * PromiseLike / regex map that isn't useful in spans). */ serializeForSpan(): { specificationVersion: 'v2'; modelId: string; provider: string; gatewayId?: string; }; } export {}; //# sourceMappingURL=model.d.ts.map