ai 5.1.0-beta.13 → 5.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -89
- package/dist/index.d.mts +59 -159
- package/dist/index.d.ts +59 -159
- package/dist/index.js +23 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -25
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +7 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +7 -7
- package/dist/internal/index.mjs.map +1 -1
- package/dist/test/index.d.mts +32 -32
- package/dist/test/index.d.ts +32 -32
- package/dist/test/index.js +14 -14
- package/dist/test/index.js.map +1 -1
- package/dist/test/index.mjs +11 -11
- package/dist/test/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { createGateway, gateway } from '@ai-sdk/gateway';
|
|
2
2
|
import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, Schema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, InferSchema, FlexibleSchema, DataContent, Validator, StandardSchemaV1, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
-
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema,
|
|
3
|
+
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
4
4
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
|
5
|
-
import
|
|
6
|
-
import { EmbeddingModelV3, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, LanguageModelV2Middleware, SharedV2ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV2Usage, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV3, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
5
|
+
import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, LanguageModelV2Middleware, SharedV2ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV2Usage, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
|
7
6
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
|
8
7
|
import * as z3 from 'zod/v3';
|
|
9
8
|
import * as z4 from 'zod/v4';
|
|
@@ -158,25 +157,25 @@ type TelemetrySettings = {
|
|
|
158
157
|
/**
|
|
159
158
|
Embedding model that is used by the AI SDK Core functions.
|
|
160
159
|
*/
|
|
161
|
-
type EmbeddingModel<VALUE = string> = string |
|
|
160
|
+
type EmbeddingModel<VALUE = string> = string | EmbeddingModelV2<VALUE>;
|
|
162
161
|
/**
|
|
163
162
|
Embedding.
|
|
164
163
|
*/
|
|
165
|
-
type Embedding =
|
|
164
|
+
type Embedding = EmbeddingModelV2Embedding;
|
|
166
165
|
|
|
167
166
|
/**
|
|
168
167
|
Image model that is used by the AI SDK Core functions.
|
|
169
168
|
*/
|
|
170
|
-
type ImageModel =
|
|
169
|
+
type ImageModel = ImageModelV2;
|
|
171
170
|
/**
|
|
172
171
|
Warning from the model provider for this call. The call will proceed, but e.g.
|
|
173
172
|
some settings might not be supported, which can lead to suboptimal results.
|
|
174
173
|
*/
|
|
175
|
-
type ImageGenerationWarning =
|
|
174
|
+
type ImageGenerationWarning = ImageModelV2CallWarning;
|
|
176
175
|
/**
|
|
177
176
|
Metadata from the model provider for this call
|
|
178
177
|
*/
|
|
179
|
-
type ImageModelProviderMetadata =
|
|
178
|
+
type ImageModelProviderMetadata = ImageModelV2ProviderMetadata;
|
|
180
179
|
|
|
181
180
|
type ImageModelResponseMetadata = {
|
|
182
181
|
/**
|
|
@@ -1594,115 +1593,6 @@ type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
|
|
|
1594
1593
|
dynamic: true;
|
|
1595
1594
|
});
|
|
1596
1595
|
|
|
1597
|
-
declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
1598
|
-
type: z.ZodLiteral<"text-start">;
|
|
1599
|
-
id: z.ZodString;
|
|
1600
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1601
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1602
|
-
type: z.ZodLiteral<"text-delta">;
|
|
1603
|
-
id: z.ZodString;
|
|
1604
|
-
delta: z.ZodString;
|
|
1605
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1606
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1607
|
-
type: z.ZodLiteral<"text-end">;
|
|
1608
|
-
id: z.ZodString;
|
|
1609
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1610
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1611
|
-
type: z.ZodLiteral<"error">;
|
|
1612
|
-
errorText: z.ZodString;
|
|
1613
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1614
|
-
type: z.ZodLiteral<"tool-input-start">;
|
|
1615
|
-
toolCallId: z.ZodString;
|
|
1616
|
-
toolName: z.ZodString;
|
|
1617
|
-
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1618
|
-
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1619
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1620
|
-
type: z.ZodLiteral<"tool-input-delta">;
|
|
1621
|
-
toolCallId: z.ZodString;
|
|
1622
|
-
inputTextDelta: z.ZodString;
|
|
1623
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1624
|
-
type: z.ZodLiteral<"tool-input-available">;
|
|
1625
|
-
toolCallId: z.ZodString;
|
|
1626
|
-
toolName: z.ZodString;
|
|
1627
|
-
input: z.ZodUnknown;
|
|
1628
|
-
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1629
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1630
|
-
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1631
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1632
|
-
type: z.ZodLiteral<"tool-input-error">;
|
|
1633
|
-
toolCallId: z.ZodString;
|
|
1634
|
-
toolName: z.ZodString;
|
|
1635
|
-
input: z.ZodUnknown;
|
|
1636
|
-
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1637
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1638
|
-
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1639
|
-
errorText: z.ZodString;
|
|
1640
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1641
|
-
type: z.ZodLiteral<"tool-output-available">;
|
|
1642
|
-
toolCallId: z.ZodString;
|
|
1643
|
-
output: z.ZodUnknown;
|
|
1644
|
-
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1645
|
-
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1646
|
-
preliminary: z.ZodOptional<z.ZodBoolean>;
|
|
1647
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1648
|
-
type: z.ZodLiteral<"tool-output-error">;
|
|
1649
|
-
toolCallId: z.ZodString;
|
|
1650
|
-
errorText: z.ZodString;
|
|
1651
|
-
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1652
|
-
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1653
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1654
|
-
type: z.ZodLiteral<"reasoning-start">;
|
|
1655
|
-
id: z.ZodString;
|
|
1656
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1657
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1658
|
-
type: z.ZodLiteral<"reasoning-delta">;
|
|
1659
|
-
id: z.ZodString;
|
|
1660
|
-
delta: z.ZodString;
|
|
1661
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1662
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1663
|
-
type: z.ZodLiteral<"reasoning-end">;
|
|
1664
|
-
id: z.ZodString;
|
|
1665
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1666
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1667
|
-
type: z.ZodLiteral<"source-url">;
|
|
1668
|
-
sourceId: z.ZodString;
|
|
1669
|
-
url: z.ZodString;
|
|
1670
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1671
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1672
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1673
|
-
type: z.ZodLiteral<"source-document">;
|
|
1674
|
-
sourceId: z.ZodString;
|
|
1675
|
-
mediaType: z.ZodString;
|
|
1676
|
-
title: z.ZodString;
|
|
1677
|
-
filename: z.ZodOptional<z.ZodString>;
|
|
1678
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1679
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1680
|
-
type: z.ZodLiteral<"file">;
|
|
1681
|
-
url: z.ZodString;
|
|
1682
|
-
mediaType: z.ZodString;
|
|
1683
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1684
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1685
|
-
type: z.ZodCustom<`data-${string}`, `data-${string}`>;
|
|
1686
|
-
id: z.ZodOptional<z.ZodString>;
|
|
1687
|
-
data: z.ZodUnknown;
|
|
1688
|
-
transient: z.ZodOptional<z.ZodBoolean>;
|
|
1689
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1690
|
-
type: z.ZodLiteral<"start-step">;
|
|
1691
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1692
|
-
type: z.ZodLiteral<"finish-step">;
|
|
1693
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1694
|
-
type: z.ZodLiteral<"start">;
|
|
1695
|
-
messageId: z.ZodOptional<z.ZodString>;
|
|
1696
|
-
messageMetadata: z.ZodOptional<z.ZodUnknown>;
|
|
1697
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1698
|
-
type: z.ZodLiteral<"finish">;
|
|
1699
|
-
messageMetadata: z.ZodOptional<z.ZodUnknown>;
|
|
1700
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1701
|
-
type: z.ZodLiteral<"abort">;
|
|
1702
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1703
|
-
type: z.ZodLiteral<"message-metadata">;
|
|
1704
|
-
messageMetadata: z.ZodUnknown;
|
|
1705
|
-
}, z.core.$strict>]>;
|
|
1706
1596
|
type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
|
1707
1597
|
[NAME in keyof DATA_TYPES & string]: {
|
|
1708
1598
|
type: `data-${NAME}`;
|
|
@@ -1797,7 +1687,6 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
1797
1687
|
type: 'file';
|
|
1798
1688
|
url: string;
|
|
1799
1689
|
mediaType: string;
|
|
1800
|
-
providerMetadata?: ProviderMetadata;
|
|
1801
1690
|
} | DataUIMessageChunk<DATA_TYPES> | {
|
|
1802
1691
|
type: 'start-step';
|
|
1803
1692
|
} | {
|
|
@@ -2072,28 +1961,47 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
|
2072
1961
|
*/
|
|
2073
1962
|
consumeStream(options?: ConsumeStreamOptions): Promise<void>;
|
|
2074
1963
|
/**
|
|
2075
|
-
|
|
1964
|
+
Converts the result to a UI message stream.
|
|
2076
1965
|
|
|
2077
|
-
|
|
1966
|
+
@param options.getErrorMessage an optional function that converts an error to an error message.
|
|
1967
|
+
@param options.sendUsage whether to send the usage information to the client. Defaults to true.
|
|
1968
|
+
@param options.sendReasoning whether to send the reasoning information to the client. Defaults to false.
|
|
1969
|
+
@param options.sendSources whether to send the sources information to the client. Defaults to false.
|
|
1970
|
+
@param options.experimental_sendFinish whether to send the finish information to the client. Defaults to true.
|
|
1971
|
+
@param options.experimental_sendStart whether to send the start information to the client. Defaults to true.
|
|
1972
|
+
|
|
1973
|
+
@return A UI message stream.
|
|
2078
1974
|
*/
|
|
2079
1975
|
toUIMessageStream<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamOptions<UI_MESSAGE>): AsyncIterableStream<InferUIMessageChunk<UI_MESSAGE>>;
|
|
2080
1976
|
/**
|
|
2081
|
-
|
|
2082
|
-
|
|
1977
|
+
Writes UI message stream output to a Node.js response-like object.
|
|
1978
|
+
@param response A Node.js response-like object (ServerResponse).
|
|
1979
|
+
@param options.status The status code.
|
|
1980
|
+
@param options.statusText The status text.
|
|
1981
|
+
@param options.headers The headers.
|
|
1982
|
+
@param options.getErrorMessage An optional function that converts an error to an error message.
|
|
1983
|
+
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
|
1984
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
|
1985
|
+
*/
|
|
2083
1986
|
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void;
|
|
2084
1987
|
/**
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
@param init Optional headers, status code, and status text.
|
|
1988
|
+
Writes text delta output to a Node.js response-like object.
|
|
1989
|
+
It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
|
1990
|
+
writes each text delta as a separate chunk.
|
|
1991
|
+
@param response A Node.js response-like object (ServerResponse).
|
|
1992
|
+
@param init Optional headers, status code, and status text.
|
|
2091
1993
|
*/
|
|
2092
1994
|
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void;
|
|
2093
1995
|
/**
|
|
2094
|
-
|
|
1996
|
+
Converts the result to a streamed response object with a stream data part stream.
|
|
2095
1997
|
|
|
2096
|
-
|
|
1998
|
+
@param options.status The status code.
|
|
1999
|
+
@param options.statusText The status text.
|
|
2000
|
+
@param options.headers The headers.
|
|
2001
|
+
@param options.getErrorMessage An optional function that converts an error to an error message.
|
|
2002
|
+
@param options.sendUsage Whether to send the usage information to the client. Defaults to true.
|
|
2003
|
+
@param options.sendReasoning Whether to send the reasoning information to the client. Defaults to false.
|
|
2004
|
+
@return A response object.
|
|
2097
2005
|
*/
|
|
2098
2006
|
toUIMessageStreamResponse<UI_MESSAGE extends UIMessage>(options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Response;
|
|
2099
2007
|
/**
|
|
@@ -2815,7 +2723,7 @@ declare function generateImage({ model, prompt, n, maxImagesPerCall, size, aspec
|
|
|
2815
2723
|
/**
|
|
2816
2724
|
The image model to use.
|
|
2817
2725
|
*/
|
|
2818
|
-
model:
|
|
2726
|
+
model: ImageModelV2;
|
|
2819
2727
|
/**
|
|
2820
2728
|
The prompt that should be used to generate the image.
|
|
2821
2729
|
*/
|
|
@@ -3537,7 +3445,7 @@ declare function generateSpeech({ model, text, voice, outputFormat, instructions
|
|
|
3537
3445
|
headers?: Record<string, string>;
|
|
3538
3446
|
}): Promise<SpeechResult>;
|
|
3539
3447
|
|
|
3540
|
-
type Warning = LanguageModelV2CallWarning |
|
|
3448
|
+
type Warning = LanguageModelV2CallWarning | ImageModelV2CallWarning | SpeechModelV2CallWarning | TranscriptionModelV2CallWarning;
|
|
3541
3449
|
type LogWarningsFunction = (warnings: Warning[]) => void;
|
|
3542
3450
|
|
|
3543
3451
|
/**
|
|
@@ -3600,20 +3508,20 @@ declare const wrapLanguageModel: ({ model, middleware: middlewareArg, modelId, p
|
|
|
3600
3508
|
}) => LanguageModelV2;
|
|
3601
3509
|
|
|
3602
3510
|
/**
|
|
3603
|
-
* Wraps a
|
|
3511
|
+
* Wraps a ProviderV2 instance with middleware functionality.
|
|
3604
3512
|
* This function allows you to apply middleware to all language models
|
|
3605
3513
|
* from the provider, enabling you to transform parameters, wrap generate
|
|
3606
3514
|
* operations, and wrap stream operations for every language model.
|
|
3607
3515
|
*
|
|
3608
3516
|
* @param options - Configuration options for wrapping the provider.
|
|
3609
|
-
* @param options.provider - The original
|
|
3517
|
+
* @param options.provider - The original ProviderV2 instance to be wrapped.
|
|
3610
3518
|
* @param options.languageModelMiddleware - The middleware to be applied to all language models from the provider. When multiple middlewares are provided, the first middleware will transform the input first, and the last middleware will be wrapped directly around the model.
|
|
3611
|
-
* @returns A new
|
|
3519
|
+
* @returns A new ProviderV2 instance with middleware applied to all language models.
|
|
3612
3520
|
*/
|
|
3613
3521
|
declare function wrapProvider({ provider, languageModelMiddleware, }: {
|
|
3614
|
-
provider:
|
|
3522
|
+
provider: ProviderV2;
|
|
3615
3523
|
languageModelMiddleware: LanguageModelMiddleware | LanguageModelMiddleware[];
|
|
3616
|
-
}):
|
|
3524
|
+
}): ProviderV2;
|
|
3617
3525
|
|
|
3618
3526
|
/**
|
|
3619
3527
|
* Creates a custom provider with specified language models, text embedding models, image models, transcription models, speech models, and an optional fallback provider.
|
|
@@ -3629,17 +3537,17 @@ declare function wrapProvider({ provider, languageModelMiddleware, }: {
|
|
|
3629
3537
|
*
|
|
3630
3538
|
* @throws {NoSuchModelError} Throws when a requested model is not found and no fallback provider is available.
|
|
3631
3539
|
*/
|
|
3632
|
-
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModelV2>, EMBEDDING_MODELS extends Record<string,
|
|
3540
|
+
declare function customProvider<LANGUAGE_MODELS extends Record<string, LanguageModelV2>, EMBEDDING_MODELS extends Record<string, EmbeddingModelV2<string>>, IMAGE_MODELS extends Record<string, ImageModelV2>, TRANSCRIPTION_MODELS extends Record<string, TranscriptionModelV2>, SPEECH_MODELS extends Record<string, SpeechModelV2>>({ languageModels, textEmbeddingModels, imageModels, transcriptionModels, speechModels, fallbackProvider, }: {
|
|
3633
3541
|
languageModels?: LANGUAGE_MODELS;
|
|
3634
3542
|
textEmbeddingModels?: EMBEDDING_MODELS;
|
|
3635
3543
|
imageModels?: IMAGE_MODELS;
|
|
3636
3544
|
transcriptionModels?: TRANSCRIPTION_MODELS;
|
|
3637
3545
|
speechModels?: SPEECH_MODELS;
|
|
3638
|
-
fallbackProvider?:
|
|
3639
|
-
}):
|
|
3546
|
+
fallbackProvider?: ProviderV2;
|
|
3547
|
+
}): ProviderV2 & {
|
|
3640
3548
|
languageModel(modelId: ExtractModelId<LANGUAGE_MODELS>): LanguageModelV2;
|
|
3641
|
-
textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>):
|
|
3642
|
-
imageModel(modelId: ExtractModelId<IMAGE_MODELS>):
|
|
3549
|
+
textEmbeddingModel(modelId: ExtractModelId<EMBEDDING_MODELS>): EmbeddingModelV2<string>;
|
|
3550
|
+
imageModel(modelId: ExtractModelId<IMAGE_MODELS>): ImageModelV2;
|
|
3643
3551
|
transcriptionModel(modelId: ExtractModelId<TRANSCRIPTION_MODELS>): TranscriptionModelV2;
|
|
3644
3552
|
speechModel(modelId: ExtractModelId<SPEECH_MODELS>): SpeechModelV2;
|
|
3645
3553
|
};
|
|
@@ -3665,13 +3573,13 @@ declare class NoSuchProviderError extends NoSuchModelError {
|
|
|
3665
3573
|
}
|
|
3666
3574
|
|
|
3667
3575
|
type ExtractLiteralUnion<T> = T extends string ? string extends T ? never : T : never;
|
|
3668
|
-
interface ProviderRegistryProvider<PROVIDERS extends Record<string,
|
|
3576
|
+
interface ProviderRegistryProvider<PROVIDERS extends Record<string, ProviderV2> = Record<string, ProviderV2>, SEPARATOR extends string = ':'> {
|
|
3669
3577
|
languageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['languageModel']>>[0]>}` : never): LanguageModelV2;
|
|
3670
3578
|
languageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): LanguageModelV2;
|
|
3671
|
-
textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['textEmbeddingModel']>>[0]>}` : never):
|
|
3672
|
-
textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never):
|
|
3673
|
-
imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['imageModel']>>[0]>}` : never):
|
|
3674
|
-
imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never):
|
|
3579
|
+
textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['textEmbeddingModel']>>[0]>}` : never): EmbeddingModelV2<string>;
|
|
3580
|
+
textEmbeddingModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): EmbeddingModelV2<string>;
|
|
3581
|
+
imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['imageModel']>>[0]>}` : never): ImageModelV2;
|
|
3582
|
+
imageModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): ImageModelV2;
|
|
3675
3583
|
transcriptionModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['transcriptionModel']>>[0]>}` : never): TranscriptionModelV2;
|
|
3676
3584
|
transcriptionModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${string}` : never): TranscriptionModelV2;
|
|
3677
3585
|
speechModel<KEY extends keyof PROVIDERS>(id: KEY extends string ? `${KEY & string}${SEPARATOR}${ExtractLiteralUnion<Parameters<NonNullable<PROVIDERS[KEY]['speechModel']>>[0]>}` : never): SpeechModelV2;
|
|
@@ -3689,7 +3597,7 @@ interface ProviderRegistryProvider<PROVIDERS extends Record<string, ProviderV3>
|
|
|
3689
3597
|
* @param options.languageModelMiddleware - Optional middleware to be applied to all language models from the registry. When multiple middlewares are provided, the first middleware will transform the input first, and the last middleware will be wrapped directly around the model.
|
|
3690
3598
|
* @returns A new ProviderRegistryProvider instance that provides access to all registered providers with optional middleware applied to language models.
|
|
3691
3599
|
*/
|
|
3692
|
-
declare function createProviderRegistry<PROVIDERS extends Record<string,
|
|
3600
|
+
declare function createProviderRegistry<PROVIDERS extends Record<string, ProviderV2>, SEPARATOR extends string = ':'>(providers: PROVIDERS, { separator, languageModelMiddleware, }?: {
|
|
3693
3601
|
separator?: SEPARATOR;
|
|
3694
3602
|
languageModelMiddleware?: LanguageModelMiddleware | LanguageModelMiddleware[];
|
|
3695
3603
|
}): ProviderRegistryProvider<PROVIDERS, SEPARATOR>;
|
|
@@ -4308,18 +4216,10 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4308
4216
|
* Clear the error state and set the status to ready if the chat is in an error state.
|
|
4309
4217
|
*/
|
|
4310
4218
|
clearError: () => void;
|
|
4311
|
-
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({
|
|
4312
|
-
state?: "output-available";
|
|
4219
|
+
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ tool, toolCallId, output, }: {
|
|
4313
4220
|
tool: TOOL;
|
|
4314
4221
|
toolCallId: string;
|
|
4315
4222
|
output: InferUIMessageTools<UI_MESSAGE>[TOOL]["output"];
|
|
4316
|
-
errorText?: never;
|
|
4317
|
-
} | {
|
|
4318
|
-
state: "output-error";
|
|
4319
|
-
tool: TOOL;
|
|
4320
|
-
toolCallId: string;
|
|
4321
|
-
output?: never;
|
|
4322
|
-
errorText: string;
|
|
4323
4223
|
}) => Promise<void>;
|
|
4324
4224
|
/**
|
|
4325
4225
|
* Abort the current request immediately, keep the generated tokens if any.
|
|
@@ -4599,7 +4499,7 @@ declare global {
|
|
|
4599
4499
|
*
|
|
4600
4500
|
* @see https://ai-sdk.dev/docs/ai-sdk-core/provider-management#global-provider-configuration
|
|
4601
4501
|
*/
|
|
4602
|
-
var AI_SDK_DEFAULT_PROVIDER:
|
|
4502
|
+
var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
|
|
4603
4503
|
/**
|
|
4604
4504
|
* The warning logger to use for the AI SDK.
|
|
4605
4505
|
*
|
|
@@ -4610,4 +4510,4 @@ declare global {
|
|
|
4610
4510
|
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
4611
4511
|
}
|
|
4612
4512
|
|
|
4613
|
-
export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema,
|
|
4513
|
+
export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, MCPClient as experimental_MCPClient, MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDeepEqualData, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,6 @@ __export(src_exports, {
|
|
|
103
103
|
jsonSchema: () => import_provider_utils35.jsonSchema,
|
|
104
104
|
lastAssistantMessageIsCompleteWithToolCalls: () => lastAssistantMessageIsCompleteWithToolCalls,
|
|
105
105
|
modelMessageSchema: () => modelMessageSchema,
|
|
106
|
-
parseJsonEventStream: () => import_provider_utils35.parseJsonEventStream,
|
|
107
106
|
parsePartialJson: () => parsePartialJson,
|
|
108
107
|
pipeTextStreamToResponse: () => pipeTextStreamToResponse,
|
|
109
108
|
pipeUIMessageStreamToResponse: () => pipeUIMessageStreamToResponse,
|
|
@@ -118,7 +117,6 @@ __export(src_exports, {
|
|
|
118
117
|
systemModelMessageSchema: () => systemModelMessageSchema,
|
|
119
118
|
tool: () => import_provider_utils35.tool,
|
|
120
119
|
toolModelMessageSchema: () => toolModelMessageSchema,
|
|
121
|
-
uiMessageChunkSchema: () => uiMessageChunkSchema,
|
|
122
120
|
userModelMessageSchema: () => userModelMessageSchema,
|
|
123
121
|
validateUIMessages: () => validateUIMessages,
|
|
124
122
|
wrapLanguageModel: () => wrapLanguageModel,
|
|
@@ -558,7 +556,7 @@ function resolveLanguageModel(model) {
|
|
|
558
556
|
}
|
|
559
557
|
function resolveEmbeddingModel(model) {
|
|
560
558
|
if (typeof model !== "string") {
|
|
561
|
-
if (model.specificationVersion !== "
|
|
559
|
+
if (model.specificationVersion !== "v2") {
|
|
562
560
|
throw new UnsupportedModelVersionError({
|
|
563
561
|
version: model.specificationVersion,
|
|
564
562
|
provider: model.provider,
|
|
@@ -768,7 +766,7 @@ function detectMediaType({
|
|
|
768
766
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
769
767
|
|
|
770
768
|
// src/version.ts
|
|
771
|
-
var VERSION = true ? "5.1.0-beta.
|
|
769
|
+
var VERSION = true ? "5.1.0-beta.2" : "0.0.0-test";
|
|
772
770
|
|
|
773
771
|
// src/util/download/download.ts
|
|
774
772
|
var download = async ({ url }) => {
|
|
@@ -1058,12 +1056,12 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
1058
1056
|
}));
|
|
1059
1057
|
const downloadedFiles = await download2(plannedDownloads);
|
|
1060
1058
|
return Object.fromEntries(
|
|
1061
|
-
downloadedFiles.
|
|
1062
|
-
(
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
)
|
|
1059
|
+
downloadedFiles.filter(
|
|
1060
|
+
(downloadedFile) => (downloadedFile == null ? void 0 : downloadedFile.data) != null
|
|
1061
|
+
).map(({ data, mediaType }, index) => [
|
|
1062
|
+
plannedDownloads[index].url.toString(),
|
|
1063
|
+
{ data, mediaType }
|
|
1064
|
+
])
|
|
1067
1065
|
);
|
|
1068
1066
|
}
|
|
1069
1067
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
@@ -2990,6 +2988,11 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
2990
2988
|
providerExecuted: import_v47.z.boolean().optional(),
|
|
2991
2989
|
dynamic: import_v47.z.boolean().optional()
|
|
2992
2990
|
}),
|
|
2991
|
+
import_v47.z.strictObject({
|
|
2992
|
+
type: import_v47.z.literal("reasoning"),
|
|
2993
|
+
text: import_v47.z.string(),
|
|
2994
|
+
providerMetadata: providerMetadataSchema.optional()
|
|
2995
|
+
}),
|
|
2993
2996
|
import_v47.z.strictObject({
|
|
2994
2997
|
type: import_v47.z.literal("reasoning-start"),
|
|
2995
2998
|
id: import_v47.z.string(),
|
|
@@ -3006,6 +3009,9 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
3006
3009
|
id: import_v47.z.string(),
|
|
3007
3010
|
providerMetadata: providerMetadataSchema.optional()
|
|
3008
3011
|
}),
|
|
3012
|
+
import_v47.z.strictObject({
|
|
3013
|
+
type: import_v47.z.literal("reasoning-part-finish")
|
|
3014
|
+
}),
|
|
3009
3015
|
import_v47.z.strictObject({
|
|
3010
3016
|
type: import_v47.z.literal("source-url"),
|
|
3011
3017
|
sourceId: import_v47.z.string(),
|
|
@@ -3028,10 +3034,7 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
3028
3034
|
providerMetadata: providerMetadataSchema.optional()
|
|
3029
3035
|
}),
|
|
3030
3036
|
import_v47.z.strictObject({
|
|
3031
|
-
type: import_v47.z.
|
|
3032
|
-
(value) => typeof value === "string" && value.startsWith("data-"),
|
|
3033
|
-
{ message: 'Type must start with "data-"' }
|
|
3034
|
-
),
|
|
3037
|
+
type: import_v47.z.string().startsWith("data-"),
|
|
3035
3038
|
id: import_v47.z.string().optional(),
|
|
3036
3039
|
data: import_v47.z.unknown(),
|
|
3037
3040
|
transient: import_v47.z.boolean().optional()
|
|
@@ -6381,7 +6384,7 @@ async function generateImage({
|
|
|
6381
6384
|
headers
|
|
6382
6385
|
}) {
|
|
6383
6386
|
var _a17, _b;
|
|
6384
|
-
if (model.specificationVersion !== "
|
|
6387
|
+
if (model.specificationVersion !== "v2") {
|
|
6385
6388
|
throw new UnsupportedModelVersionError({
|
|
6386
6389
|
version: model.specificationVersion,
|
|
6387
6390
|
provider: model.provider,
|
|
@@ -9721,11 +9724,9 @@ var AbstractChat = class {
|
|
|
9721
9724
|
}
|
|
9722
9725
|
};
|
|
9723
9726
|
this.addToolResult = async ({
|
|
9724
|
-
state = "output-available",
|
|
9725
9727
|
tool: tool3,
|
|
9726
9728
|
toolCallId,
|
|
9727
|
-
output
|
|
9728
|
-
errorText
|
|
9729
|
+
output
|
|
9729
9730
|
}) => this.jobExecutor.run(async () => {
|
|
9730
9731
|
var _a17, _b;
|
|
9731
9732
|
const messages = this.state.messages;
|
|
@@ -9733,16 +9734,16 @@ var AbstractChat = class {
|
|
|
9733
9734
|
this.state.replaceMessage(messages.length - 1, {
|
|
9734
9735
|
...lastMessage,
|
|
9735
9736
|
parts: lastMessage.parts.map(
|
|
9736
|
-
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state
|
|
9737
|
+
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state: "output-available", output } : part
|
|
9737
9738
|
)
|
|
9738
9739
|
});
|
|
9739
9740
|
if (this.activeResponse) {
|
|
9740
9741
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(
|
|
9741
9742
|
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {
|
|
9742
9743
|
...part,
|
|
9743
|
-
state,
|
|
9744
|
+
state: "output-available",
|
|
9744
9745
|
output,
|
|
9745
|
-
errorText
|
|
9746
|
+
errorText: void 0
|
|
9746
9747
|
} : part
|
|
9747
9748
|
);
|
|
9748
9749
|
}
|
|
@@ -9951,9 +9952,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
|
|
|
9951
9952
|
return part.type === "step-start" ? index : lastIndex;
|
|
9952
9953
|
}, -1);
|
|
9953
9954
|
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart);
|
|
9954
|
-
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
9955
|
-
(part) => part.state === "output-available" || part.state === "output-error"
|
|
9956
|
-
);
|
|
9955
|
+
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
|
|
9957
9956
|
}
|
|
9958
9957
|
|
|
9959
9958
|
// src/ui/transform-text-to-ui-message-stream.ts
|
|
@@ -10471,7 +10470,6 @@ function readUIMessageStream({
|
|
|
10471
10470
|
jsonSchema,
|
|
10472
10471
|
lastAssistantMessageIsCompleteWithToolCalls,
|
|
10473
10472
|
modelMessageSchema,
|
|
10474
|
-
parseJsonEventStream,
|
|
10475
10473
|
parsePartialJson,
|
|
10476
10474
|
pipeTextStreamToResponse,
|
|
10477
10475
|
pipeUIMessageStreamToResponse,
|
|
@@ -10486,7 +10484,6 @@ function readUIMessageStream({
|
|
|
10486
10484
|
systemModelMessageSchema,
|
|
10487
10485
|
tool,
|
|
10488
10486
|
toolModelMessageSchema,
|
|
10489
|
-
uiMessageChunkSchema,
|
|
10490
10487
|
userModelMessageSchema,
|
|
10491
10488
|
validateUIMessages,
|
|
10492
10489
|
wrapLanguageModel,
|