ai 5.0.0-alpha.12 → 5.0.0-alpha.13
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 +17 -0
- package/dist/index.d.mts +106 -117
- package/dist/index.d.ts +106 -117
- package/dist/index.js +261 -255
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -197
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 5.0.0-alpha.13
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- 0a710d8: feat (ui): typed tool parts in ui messages
|
8
|
+
- 6a83f7d: refactoring (ai): restructure message metadata transfer
|
9
|
+
- 1f55c21: chore (ai): send reasoning to the client by default
|
10
|
+
- 33eb499: feat (ai): inject message id in createUIMessageStream
|
11
|
+
- 901df02: feat (ui): use UI_MESSAGE generic
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- Updated dependencies [68ecf2f]
|
16
|
+
- @ai-sdk/provider@2.0.0-alpha.13
|
17
|
+
- @ai-sdk/gateway@1.0.0-alpha.13
|
18
|
+
- @ai-sdk/provider-utils@3.0.0-alpha.13
|
19
|
+
|
3
20
|
## 5.0.0-alpha.12
|
4
21
|
|
5
22
|
### Major Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ToolResultContent, Schema,
|
1
|
+
import { ToolResultContent, Schema, IdGenerator, Validator, StandardSchemaV1, ToolCall, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
2
2
|
export { IdGenerator, Schema, ToolCall, ToolResult, asSchema, createIdGenerator, generateId, jsonSchema } from '@ai-sdk/provider-utils';
|
3
3
|
import { AISDKError, SharedV2ProviderMetadata, SharedV2ProviderOptions, EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SpeechModelV1, SpeechModelV1CallWarning, TranscriptionModelV1, TranscriptionModelV1CallWarning, LanguageModelV2Usage, JSONObject, LanguageModelV2ToolCall, JSONSchema7, LanguageModelV2CallOptions, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
4
4
|
export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
|
@@ -2130,29 +2130,34 @@ declare class InvalidMessageRoleError extends AISDKError {
|
|
2130
2130
|
}
|
2131
2131
|
|
2132
2132
|
/**
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2133
|
+
Create a type from an object with all keys and nested keys set to optional.
|
2134
|
+
The helper supports normal objects and Zod schemas (which are resolved automatically).
|
2135
|
+
It always recurses into arrays.
|
2136
2136
|
|
2137
|
-
|
2138
|
-
back to a sequence of LLM assistant/tool result message pairs.
|
2139
|
-
It is optional for backwards compatibility.
|
2137
|
+
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
2140
2138
|
*/
|
2141
|
-
type
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2139
|
+
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
2140
|
+
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
2141
|
+
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2142
|
+
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
2143
|
+
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2144
|
+
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
2145
|
+
type PartialObject<ObjectType extends object> = {
|
2146
|
+
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
2147
|
+
};
|
2148
|
+
|
2148
2149
|
/**
|
2149
2150
|
The data types that can be used in the UI message for the UI message data parts.
|
2150
2151
|
*/
|
2151
2152
|
type UIDataTypes = Record<string, unknown>;
|
2153
|
+
type UITools = Record<string, {
|
2154
|
+
args: unknown;
|
2155
|
+
result: unknown | undefined;
|
2156
|
+
}>;
|
2152
2157
|
/**
|
2153
2158
|
AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
|
2154
2159
|
*/
|
2155
|
-
interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataTypes> {
|
2160
|
+
interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataTypes, TOOLS extends UITools = UITools> {
|
2156
2161
|
/**
|
2157
2162
|
A unique identifier for the message.
|
2158
2163
|
*/
|
@@ -2175,22 +2180,9 @@ interface UIMessage<METADATA = unknown, DATA_PARTS extends UIDataTypes = UIDataT
|
|
2175
2180
|
|
2176
2181
|
Assistant messages can have text, reasoning, tool invocation, and file parts.
|
2177
2182
|
*/
|
2178
|
-
parts: Array<UIMessagePart<DATA_PARTS>>;
|
2183
|
+
parts: Array<UIMessagePart<DATA_PARTS, TOOLS>>;
|
2179
2184
|
}
|
2180
|
-
type UIMessagePart<DATA_TYPES extends UIDataTypes> = TextUIPart | ReasoningUIPart |
|
2181
|
-
type DataUIPart<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
2182
|
-
[NAME in keyof DATA_TYPES & string]: {
|
2183
|
-
type: `data-${NAME}`;
|
2184
|
-
id?: string;
|
2185
|
-
data: DATA_TYPES[NAME];
|
2186
|
-
};
|
2187
|
-
}>;
|
2188
|
-
type UIDataPartSchemas = Record<string, Validator<any> | StandardSchemaV1<any>>;
|
2189
|
-
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
2190
|
-
[K in keyof T]: T[K] extends Validator<infer U> ? U : T[K] extends StandardSchemaV1<infer U> ? U : unknown;
|
2191
|
-
};
|
2192
|
-
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
2193
|
-
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA, UIDataTypes> ? METADATA : unknown;
|
2185
|
+
type UIMessagePart<DATA_TYPES extends UIDataTypes, TOOLS extends UITools> = TextUIPart | ReasoningUIPart | ToolUIPart<TOOLS> | SourceUrlUIPart | SourceDocumentUIPart | FileUIPart | DataUIPart<DATA_TYPES> | StepStartUIPart;
|
2194
2186
|
/**
|
2195
2187
|
* A text part of a message.
|
2196
2188
|
*/
|
@@ -2215,16 +2207,6 @@ type ReasoningUIPart = {
|
|
2215
2207
|
*/
|
2216
2208
|
providerMetadata?: Record<string, any>;
|
2217
2209
|
};
|
2218
|
-
/**
|
2219
|
-
* A tool invocation part of a message.
|
2220
|
-
*/
|
2221
|
-
type ToolInvocationUIPart = {
|
2222
|
-
type: 'tool-invocation';
|
2223
|
-
/**
|
2224
|
-
* The tool invocation.
|
2225
|
-
*/
|
2226
|
-
toolInvocation: ToolInvocation;
|
2227
|
-
};
|
2228
2210
|
/**
|
2229
2211
|
* A source part of a message.
|
2230
2212
|
*/
|
@@ -2273,10 +2255,33 @@ type FileUIPart = {
|
|
2273
2255
|
type StepStartUIPart = {
|
2274
2256
|
type: 'step-start';
|
2275
2257
|
};
|
2276
|
-
type
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2258
|
+
type DataUIPart<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
2259
|
+
[NAME in keyof DATA_TYPES & string]: {
|
2260
|
+
type: `data-${NAME}`;
|
2261
|
+
id?: string;
|
2262
|
+
data: DATA_TYPES[NAME];
|
2263
|
+
};
|
2264
|
+
}>;
|
2265
|
+
type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
|
2266
|
+
[NAME in keyof TOOLS & string]: {
|
2267
|
+
type: `tool-${NAME}`;
|
2268
|
+
toolCallId: string;
|
2269
|
+
} & ({
|
2270
|
+
state: 'partial-call';
|
2271
|
+
args: DeepPartial<TOOLS[NAME]['args']>;
|
2272
|
+
} | {
|
2273
|
+
state: 'call';
|
2274
|
+
args: TOOLS[NAME]['args'];
|
2275
|
+
} | {
|
2276
|
+
state: 'result';
|
2277
|
+
args: TOOLS[NAME]['args'];
|
2278
|
+
result: TOOLS[NAME]['result'];
|
2279
|
+
});
|
2280
|
+
}>;
|
2281
|
+
declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
|
2282
|
+
declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): keyof TOOLS;
|
2283
|
+
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA> ? METADATA : unknown;
|
2284
|
+
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
2280
2285
|
|
2281
2286
|
declare const symbol$3: unique symbol;
|
2282
2287
|
declare class MessageConversionError extends AISDKError {
|
@@ -2381,6 +2386,8 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
2381
2386
|
type: 'reasoning';
|
2382
2387
|
text: string;
|
2383
2388
|
providerMetadata?: ProviderMetadata;
|
2389
|
+
} | {
|
2390
|
+
type: 'reasoning-part-finish';
|
2384
2391
|
} | {
|
2385
2392
|
type: 'source-url';
|
2386
2393
|
sourceId: string;
|
@@ -2399,23 +2406,19 @@ type UIMessageStreamPart<METADATA = unknown, DATA_TYPES extends UIDataTypes = UI
|
|
2399
2406
|
url: string;
|
2400
2407
|
mediaType: string;
|
2401
2408
|
} | DataUIMessageStreamPart<DATA_TYPES> | {
|
2402
|
-
type: 'metadata';
|
2403
|
-
metadata: METADATA;
|
2404
|
-
} | {
|
2405
2409
|
type: 'start-step';
|
2406
|
-
metadata?: METADATA;
|
2407
2410
|
} | {
|
2408
2411
|
type: 'finish-step';
|
2409
|
-
metadata?: METADATA;
|
2410
2412
|
} | {
|
2411
2413
|
type: 'start';
|
2412
2414
|
messageId?: string;
|
2413
|
-
|
2415
|
+
messageMetadata?: METADATA;
|
2414
2416
|
} | {
|
2415
2417
|
type: 'finish';
|
2416
|
-
|
2418
|
+
messageMetadata?: METADATA;
|
2417
2419
|
} | {
|
2418
|
-
type: '
|
2420
|
+
type: 'message-metadata';
|
2421
|
+
messageMetadata: METADATA;
|
2419
2422
|
};
|
2420
2423
|
type InferUIMessageStreamPart<T extends UIMessage> = UIMessageStreamPart<InferUIMessageMetadata<T>, InferUIMessageData<T>>;
|
2421
2424
|
|
@@ -2437,13 +2440,14 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
|
|
2437
2440
|
}
|
2438
2441
|
|
2439
2442
|
declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, // mask error messages for safety by default
|
2440
|
-
originalMessages, onFinish, }: {
|
2443
|
+
originalMessages, onFinish, generateId, }: {
|
2441
2444
|
execute: (options: {
|
2442
2445
|
writer: UIMessageStreamWriter<UI_MESSAGE>;
|
2443
2446
|
}) => Promise<void> | void;
|
2444
2447
|
onError?: (error: unknown) => string;
|
2445
2448
|
/**
|
2446
|
-
* The original messages.
|
2449
|
+
* The original messages. If they are provided, persistence mode is assumed,
|
2450
|
+
* and a message ID is provided for the response message.
|
2447
2451
|
*/
|
2448
2452
|
originalMessages?: UI_MESSAGE[];
|
2449
2453
|
onFinish?: (options: {
|
@@ -2462,6 +2466,7 @@ originalMessages, onFinish, }: {
|
|
2462
2466
|
*/
|
2463
2467
|
responseMessage: UI_MESSAGE;
|
2464
2468
|
}) => void;
|
2469
|
+
generateId?: IdGenerator;
|
2465
2470
|
}): ReadableStream<InferUIMessageStreamPart<UI_MESSAGE>>;
|
2466
2471
|
|
2467
2472
|
declare function createUIMessageStreamResponse({ status, statusText, headers, stream, }: ResponseInit & {
|
@@ -2477,15 +2482,26 @@ declare class JsonToSseTransformStream extends TransformStream<unknown, string>
|
|
2477
2482
|
constructor();
|
2478
2483
|
}
|
2479
2484
|
|
2480
|
-
interface ChatTransport<
|
2485
|
+
interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
2481
2486
|
submitMessages: (options: {
|
2482
2487
|
chatId: string;
|
2483
|
-
messages:
|
2488
|
+
messages: UI_MESSAGE[];
|
2484
2489
|
abortSignal: AbortSignal | undefined;
|
2485
2490
|
requestType: 'generate' | 'resume';
|
2486
2491
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageStreamPart>>;
|
2487
2492
|
}
|
2488
2493
|
|
2494
|
+
type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
|
2495
|
+
id?: UI_MESSAGE['id'];
|
2496
|
+
role?: UI_MESSAGE['role'];
|
2497
|
+
};
|
2498
|
+
type UIDataPartSchemas = Record<string, Validator<any> | StandardSchemaV1<any>>;
|
2499
|
+
type UIDataTypesToSchemas<T extends UIDataTypes> = {
|
2500
|
+
[K in keyof T]: Validator<T[K]> | StandardSchemaV1<T[K]>;
|
2501
|
+
};
|
2502
|
+
type InferUIDataParts<T extends UIDataPartSchemas> = {
|
2503
|
+
[K in keyof T]: T[K] extends Validator<infer U> ? U : T[K] extends StandardSchemaV1<infer U> ? U : unknown;
|
2504
|
+
};
|
2489
2505
|
type ChatRequestOptions = {
|
2490
2506
|
/**
|
2491
2507
|
Additional headers that should be to be passed to the API endpoint.
|
@@ -2498,30 +2514,30 @@ type ChatRequestOptions = {
|
|
2498
2514
|
metadata?: unknown;
|
2499
2515
|
};
|
2500
2516
|
type ChatStatus = 'submitted' | 'streaming' | 'ready' | 'error';
|
2501
|
-
interface ChatState<
|
2517
|
+
interface ChatState<UI_MESSAGE extends UIMessage> {
|
2502
2518
|
status: ChatStatus;
|
2503
2519
|
error: Error | undefined;
|
2504
|
-
messages:
|
2505
|
-
pushMessage: (message:
|
2520
|
+
messages: UI_MESSAGE[];
|
2521
|
+
pushMessage: (message: UI_MESSAGE) => void;
|
2506
2522
|
popMessage: () => void;
|
2507
|
-
replaceMessage: (index: number, message:
|
2523
|
+
replaceMessage: (index: number, message: UI_MESSAGE) => void;
|
2508
2524
|
snapshot: <T>(thing: T) => T;
|
2509
2525
|
}
|
2510
|
-
interface ChatInit<
|
2526
|
+
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
2511
2527
|
/**
|
2512
2528
|
* A unique identifier for the chat. If not provided, a random one will be
|
2513
2529
|
* generated.
|
2514
2530
|
*/
|
2515
2531
|
id?: string;
|
2516
|
-
messageMetadataSchema?: Validator<
|
2517
|
-
dataPartSchemas?:
|
2518
|
-
messages?:
|
2532
|
+
messageMetadataSchema?: Validator<InferUIMessageMetadata<UI_MESSAGE>> | StandardSchemaV1<InferUIMessageMetadata<UI_MESSAGE>>;
|
2533
|
+
dataPartSchemas?: UIDataTypesToSchemas<InferUIMessageData<UI_MESSAGE>>;
|
2534
|
+
messages?: UI_MESSAGE[];
|
2519
2535
|
/**
|
2520
2536
|
* A way to provide a function that is going to be used for ids for messages and the chat.
|
2521
2537
|
* If not provided the default AI SDK `generateId` is used.
|
2522
2538
|
*/
|
2523
2539
|
generateId?: IdGenerator;
|
2524
|
-
transport?: ChatTransport<
|
2540
|
+
transport?: ChatTransport<UI_MESSAGE>;
|
2525
2541
|
maxSteps?: number;
|
2526
2542
|
/**
|
2527
2543
|
* Callback function to be called when an error is encountered.
|
@@ -2543,13 +2559,13 @@ interface ChatInit<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDa
|
|
2543
2559
|
* @param message The message that was streamed.
|
2544
2560
|
*/
|
2545
2561
|
onFinish?: (options: {
|
2546
|
-
message:
|
2562
|
+
message: UI_MESSAGE;
|
2547
2563
|
}) => void;
|
2548
2564
|
}
|
2549
|
-
declare abstract class AbstractChat<
|
2565
|
+
declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
2550
2566
|
readonly id: string;
|
2551
2567
|
readonly generateId: IdGenerator;
|
2552
|
-
protected state: ChatState<
|
2568
|
+
protected state: ChatState<UI_MESSAGE>;
|
2553
2569
|
private messageMetadataSchema;
|
2554
2570
|
private dataPartSchemas;
|
2555
2571
|
private readonly transport;
|
@@ -2559,8 +2575,8 @@ declare abstract class AbstractChat<MESSAGE_METADATA = unknown, UI_DATA_PART_SCH
|
|
2559
2575
|
private onFinish?;
|
2560
2576
|
private activeResponse;
|
2561
2577
|
private jobExecutor;
|
2562
|
-
constructor({ generateId, id, transport, maxSteps, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, }: Omit<ChatInit<
|
2563
|
-
state: ChatState<
|
2578
|
+
constructor({ generateId, id, transport, maxSteps, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
2579
|
+
state: ChatState<UI_MESSAGE>;
|
2564
2580
|
});
|
2565
2581
|
/**
|
2566
2582
|
* Hook status:
|
@@ -2576,25 +2592,25 @@ declare abstract class AbstractChat<MESSAGE_METADATA = unknown, UI_DATA_PART_SCH
|
|
2576
2592
|
error?: Error;
|
2577
2593
|
}): void;
|
2578
2594
|
get error(): Error | undefined;
|
2579
|
-
get messages():
|
2580
|
-
get lastMessage():
|
2581
|
-
set messages(messages:
|
2595
|
+
get messages(): UI_MESSAGE[];
|
2596
|
+
get lastMessage(): UI_MESSAGE | undefined;
|
2597
|
+
set messages(messages: UI_MESSAGE[]);
|
2582
2598
|
removeAssistantResponse: () => void;
|
2583
2599
|
/**
|
2584
2600
|
* Append a user message to the chat list. This triggers the API call to fetch
|
2585
2601
|
* the assistant's response.
|
2586
2602
|
*/
|
2587
|
-
sendMessage: (message: (CreateUIMessage<
|
2603
|
+
sendMessage: (message: (CreateUIMessage<UI_MESSAGE> & {
|
2588
2604
|
text?: never;
|
2589
2605
|
files?: never;
|
2590
2606
|
}) | {
|
2591
2607
|
text: string;
|
2592
2608
|
files?: FileList | FileUIPart[];
|
2593
|
-
metadata?:
|
2609
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2594
2610
|
parts?: never;
|
2595
2611
|
} | {
|
2596
2612
|
files: FileList | FileUIPart[];
|
2597
|
-
metadata?:
|
2613
|
+
metadata?: InferUIMessageMetadata<UI_MESSAGE>;
|
2598
2614
|
parts?: never;
|
2599
2615
|
}, options?: ChatRequestOptions) => Promise<void>;
|
2600
2616
|
/**
|
@@ -2630,9 +2646,9 @@ declare function convertToModelMessages<TOOLS extends ToolSet = never>(messages:
|
|
2630
2646
|
*/
|
2631
2647
|
declare const convertToCoreMessages: typeof convertToModelMessages;
|
2632
2648
|
|
2633
|
-
type PrepareRequest<
|
2649
|
+
type PrepareRequest<UI_MESSAGE extends UIMessage> = (options: {
|
2634
2650
|
id: string;
|
2635
|
-
messages:
|
2651
|
+
messages: UI_MESSAGE[];
|
2636
2652
|
requestMetadata: unknown;
|
2637
2653
|
body: Record<string, any> | undefined;
|
2638
2654
|
credentials: RequestCredentials | undefined;
|
@@ -2643,7 +2659,7 @@ type PrepareRequest<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> = (options
|
|
2643
2659
|
credentials?: RequestCredentials;
|
2644
2660
|
};
|
2645
2661
|
|
2646
|
-
declare class DefaultChatTransport<
|
2662
|
+
declare class DefaultChatTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
2647
2663
|
private api;
|
2648
2664
|
private credentials?;
|
2649
2665
|
private headers?;
|
@@ -2689,14 +2705,12 @@ declare class DefaultChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTy
|
|
2689
2705
|
* @param messages The current messages in the chat.
|
2690
2706
|
* @param requestBody The request body object passed in the chat request.
|
2691
2707
|
*/
|
2692
|
-
prepareRequest?: PrepareRequest<
|
2708
|
+
prepareRequest?: PrepareRequest<UI_MESSAGE>;
|
2693
2709
|
});
|
2694
|
-
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<
|
2710
|
+
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<UI_MESSAGE>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
|
2695
2711
|
}
|
2696
2712
|
|
2697
|
-
declare
|
2698
|
-
|
2699
|
-
declare class TextStreamChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
|
2713
|
+
declare class TextStreamChatTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
|
2700
2714
|
private api;
|
2701
2715
|
private credentials?;
|
2702
2716
|
private headers?;
|
@@ -2742,9 +2756,9 @@ declare class TextStreamChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDat
|
|
2742
2756
|
* @param messages The current messages in the chat.
|
2743
2757
|
* @param requestBody The request body object passed in the chat request.
|
2744
2758
|
*/
|
2745
|
-
prepareRequest?: NoInfer<PrepareRequest<
|
2759
|
+
prepareRequest?: NoInfer<PrepareRequest<UI_MESSAGE>>;
|
2746
2760
|
});
|
2747
|
-
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<
|
2761
|
+
submitMessages({ chatId, messages, abortSignal, metadata, headers, body, requestType, }: Parameters<ChatTransport<UI_MESSAGE>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart<never, never>>>;
|
2748
2762
|
}
|
2749
2763
|
|
2750
2764
|
type CompletionRequestOptions = {
|
@@ -2838,23 +2852,6 @@ declare function cosineSimilarity(vector1: number[], vector2: number[]): number;
|
|
2838
2852
|
*/
|
2839
2853
|
declare function getTextFromDataUrl(dataUrl: string): string;
|
2840
2854
|
|
2841
|
-
/**
|
2842
|
-
Create a type from an object with all keys and nested keys set to optional.
|
2843
|
-
The helper supports normal objects and Zod schemas (which are resolved automatically).
|
2844
|
-
It always recurses into arrays.
|
2845
|
-
|
2846
|
-
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
2847
|
-
*/
|
2848
|
-
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
2849
|
-
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
2850
|
-
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2851
|
-
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
2852
|
-
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2853
|
-
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
2854
|
-
type PartialObject<ObjectType extends object> = {
|
2855
|
-
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
2856
|
-
};
|
2857
|
-
|
2858
2855
|
/**
|
2859
2856
|
* Performs a deep-equal comparison of two parsed JSON objects.
|
2860
2857
|
*
|
@@ -3428,14 +3425,8 @@ type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
|
3428
3425
|
|
3429
3426
|
type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
3430
3427
|
/**
|
3431
|
-
*
|
3432
|
-
*
|
3433
|
-
* if the last original message is not an assistant message
|
3434
|
-
* (in which case that message ID is used).
|
3435
|
-
*/
|
3436
|
-
newMessageId?: string;
|
3437
|
-
/**
|
3438
|
-
* The original messages.
|
3428
|
+
* The original messages. If they are provided, persistence mode is assumed,
|
3429
|
+
* and a message ID is provided for the response message.
|
3439
3430
|
*/
|
3440
3431
|
originalMessages?: UI_MESSAGE[];
|
3441
3432
|
onFinish?: (options: {
|
@@ -3460,13 +3451,11 @@ type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
|
3460
3451
|
* Called on `start` and `finish` events.
|
3461
3452
|
*/
|
3462
3453
|
messageMetadata?: (options: {
|
3463
|
-
part: TextStreamPart<ToolSet
|
3464
|
-
type: 'start' | 'finish' | 'start-step' | 'finish-step';
|
3465
|
-
};
|
3454
|
+
part: TextStreamPart<ToolSet>;
|
3466
3455
|
}) => InferUIMessageMetadata<UI_MESSAGE> | undefined;
|
3467
3456
|
/**
|
3468
3457
|
* Send reasoning parts to the client.
|
3469
|
-
* Default to
|
3458
|
+
* Default to true.
|
3470
3459
|
*/
|
3471
3460
|
sendReasoning?: boolean;
|
3472
3461
|
/**
|
@@ -3781,7 +3770,7 @@ Callback that is set using the `onChunk` option.
|
|
3781
3770
|
*/
|
3782
3771
|
type StreamTextOnChunkCallback<TOOLS extends ToolSet> = (event: {
|
3783
3772
|
chunk: Extract<TextStreamPart<TOOLS>, {
|
3784
|
-
type: 'text' | 'reasoning' | 'source' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result';
|
3773
|
+
type: 'text' | 'reasoning' | 'source' | 'tool-call' | 'tool-call-streaming-start' | 'tool-call-delta' | 'tool-result' | 'raw';
|
3785
3774
|
}>;
|
3786
3775
|
}) => Promise<void> | void;
|
3787
3776
|
/**
|
@@ -4840,4 +4829,4 @@ declare function transcribe({ model, audio, providerOptions, maxRetries: maxRetr
|
|
4840
4829
|
headers?: Record<string, string>;
|
4841
4830
|
}): Promise<TranscriptionResult>;
|
4842
4831
|
|
4843
|
-
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GLOBAL_DEFAULT_PROVIDER, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallOptions, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError,
|
4832
|
+
export { AbstractChat, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, ChatInit, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GLOBAL_DEFAULT_PROVIDER, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, ImagePart, InferUIDataParts, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, ModelMessage, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, SystemModelMessage, TelemetrySettings, TextPart, TextStreamChatTransport, TextStreamPart, TextUIPart, Tool, ToolCallOptions, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, 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, hasToolCall, isDeepEqualData, isToolUIPart, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|