ai 5.0.0-alpha.6 → 5.0.0-alpha.8
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 +44 -0
- package/dist/index.d.mts +282 -437
- package/dist/index.d.ts +282 -437
- package/dist/index.js +957 -1047
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +935 -1015
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +3 -2
- package/dist/internal/index.d.ts +3 -2
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator,
|
1
|
+
import { ToolResultContent, Schema, ToolCall, ToolResult, IdGenerator, InferSchema, Validator, StandardSchemaV1, FetchFunction } 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';
|
5
|
-
import
|
5
|
+
import * as z3 from 'zod/v3';
|
6
|
+
import * as z4 from 'zod/v4/core';
|
6
7
|
import { z } from 'zod';
|
7
8
|
import { ServerResponse } from 'node:http';
|
8
9
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
@@ -383,7 +384,7 @@ type JSONValue = JSONValue$1;
|
|
383
384
|
/**
|
384
385
|
Language model that is used by the AI SDK Core functions.
|
385
386
|
*/
|
386
|
-
type LanguageModel =
|
387
|
+
type LanguageModel = string | LanguageModelV2;
|
387
388
|
/**
|
388
389
|
Reason why a language model finished generating a response.
|
389
390
|
|
@@ -879,7 +880,7 @@ type MCPTransportConfig = {
|
|
879
880
|
headers?: Record<string, string>;
|
880
881
|
};
|
881
882
|
|
882
|
-
type ToolParameters<T = JSONObject> =
|
883
|
+
type ToolParameters<T = JSONObject> = z4.$ZodType<T> | z3.Schema<T> | Schema<T>;
|
883
884
|
interface ToolExecutionOptions {
|
884
885
|
/**
|
885
886
|
* The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.
|
@@ -961,7 +962,7 @@ type ToolSchemas = Record<string, {
|
|
961
962
|
parameters: ToolParameters<JSONObject | unknown>;
|
962
963
|
}> | 'automatic' | undefined;
|
963
964
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
964
|
-
parameters: ToolParameters<
|
965
|
+
parameters: ToolParameters<unknown>;
|
965
966
|
}> ? {
|
966
967
|
[K in keyof TOOL_SCHEMAS]: MappedTool<TOOL_SCHEMAS[K], CallToolResult> & Required<Pick<MappedTool<TOOL_SCHEMAS[K], CallToolResult>, 'execute'>>;
|
967
968
|
} : McpToolSet<Record<string, {
|
@@ -1901,6 +1902,8 @@ type Prompt = {
|
|
1901
1902
|
messages?: Array<ModelMessage>;
|
1902
1903
|
};
|
1903
1904
|
|
1905
|
+
declare const GLOBAL_DEFAULT_PROVIDER: unique symbol;
|
1906
|
+
|
1904
1907
|
/**
|
1905
1908
|
* A function that attempts to repair a tool call that failed to parse.
|
1906
1909
|
*
|
@@ -2115,13 +2118,10 @@ It is optional for backwards compatibility.
|
|
2115
2118
|
*/
|
2116
2119
|
type ToolInvocation = ({
|
2117
2120
|
state: 'partial-call';
|
2118
|
-
step?: number;
|
2119
2121
|
} & ToolCall<string, any>) | ({
|
2120
2122
|
state: 'call';
|
2121
|
-
step?: number;
|
2122
2123
|
} & ToolCall<string, any>) | ({
|
2123
2124
|
state: 'result';
|
2124
|
-
step?: number;
|
2125
2125
|
} & ToolResult<string, any, any>);
|
2126
2126
|
/**
|
2127
2127
|
The data types that can be used in the UI message for the UI message data parts.
|
@@ -2289,15 +2289,31 @@ declare function pipeTextStreamToResponse({ response, status, statusText, header
|
|
2289
2289
|
textStream: ReadableStream<string>;
|
2290
2290
|
} & ResponseInit): void;
|
2291
2291
|
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2292
|
+
declare const getOriginalFetch: () => typeof fetch;
|
2293
|
+
declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
|
2294
|
+
api: string;
|
2295
|
+
prompt: string;
|
2296
|
+
credentials: RequestCredentials | undefined;
|
2297
|
+
headers: HeadersInit | undefined;
|
2298
|
+
body: Record<string, any>;
|
2299
|
+
streamProtocol: 'data' | 'text' | undefined;
|
2300
|
+
setCompletion: (completion: string) => void;
|
2301
|
+
setLoading: (loading: boolean) => void;
|
2302
|
+
setError: (error: Error | undefined) => void;
|
2303
|
+
setAbortController: (abortController: AbortController | null) => void;
|
2304
|
+
onFinish: ((prompt: string, completion: string) => void) | undefined;
|
2305
|
+
onError: ((error: Error) => void) | undefined;
|
2306
|
+
fetch: ReturnType<typeof getOriginalFetch> | undefined;
|
2307
|
+
}): Promise<string | null | undefined>;
|
2308
|
+
|
2309
|
+
type Job = () => Promise<void>;
|
2310
|
+
|
2311
|
+
declare class SerialJobExecutor {
|
2312
|
+
private queue;
|
2313
|
+
private isProcessing;
|
2314
|
+
private processQueue;
|
2315
|
+
run(job: Job): Promise<void>;
|
2316
|
+
}
|
2301
2317
|
|
2302
2318
|
/**
|
2303
2319
|
The result of an `embed` call.
|
@@ -2653,7 +2669,7 @@ It always recurses into arrays.
|
|
2653
2669
|
|
2654
2670
|
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
2655
2671
|
*/
|
2656
|
-
type DeepPartial<T> = T extends
|
2672
|
+
type DeepPartial<T> = T extends z3.ZodTypeAny ? DeepPartialInternal<z3.infer<T>> : T extends z4.$ZodType ? DeepPartialInternal<z4.infer<T>> : DeepPartialInternal<T>;
|
2657
2673
|
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;
|
2658
2674
|
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
2659
2675
|
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
@@ -2663,7 +2679,7 @@ type PartialObject<ObjectType extends object> = {
|
|
2663
2679
|
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
2664
2680
|
};
|
2665
2681
|
|
2666
|
-
interface Output
|
2682
|
+
interface Output<OUTPUT, PARTIAL> {
|
2667
2683
|
readonly type: 'object' | 'text';
|
2668
2684
|
responseFormat: LanguageModelV2CallOptions['responseFormat'];
|
2669
2685
|
parsePartial(options: {
|
@@ -2679,16 +2695,17 @@ interface Output$1<OUTPUT, PARTIAL> {
|
|
2679
2695
|
finishReason: FinishReason;
|
2680
2696
|
}): Promise<OUTPUT>;
|
2681
2697
|
}
|
2682
|
-
declare const text: () => Output
|
2698
|
+
declare const text: () => Output<string, string>;
|
2683
2699
|
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
2684
|
-
schema:
|
2685
|
-
}) => Output
|
2700
|
+
schema: z4.$ZodType<OUTPUT, any> | z3.Schema<OUTPUT, z3.ZodTypeDef, any> | Schema<OUTPUT>;
|
2701
|
+
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
2686
2702
|
|
2703
|
+
type output_Output<OUTPUT, PARTIAL> = Output<OUTPUT, PARTIAL>;
|
2687
2704
|
declare const output_object: typeof object;
|
2688
2705
|
declare const output_text: typeof text;
|
2689
2706
|
declare namespace output {
|
2690
2707
|
export {
|
2691
|
-
|
2708
|
+
output_Output as Output,
|
2692
2709
|
output_object as object,
|
2693
2710
|
output_text as text,
|
2694
2711
|
};
|
@@ -2817,7 +2834,7 @@ changing the tool call and result types in the result.
|
|
2817
2834
|
/**
|
2818
2835
|
Optional specification for parsing structured outputs from the LLM response.
|
2819
2836
|
*/
|
2820
|
-
experimental_output?: Output
|
2837
|
+
experimental_output?: Output<OUTPUT, OUTPUT_PARTIAL>;
|
2821
2838
|
/**
|
2822
2839
|
* @deprecated Use `prepareStep` instead.
|
2823
2840
|
*/
|
@@ -3305,7 +3322,7 @@ functionality that can be fully encapsulated in the provider.
|
|
3305
3322
|
/**
|
3306
3323
|
Optional specification for parsing structured outputs from the LLM response.
|
3307
3324
|
*/
|
3308
|
-
experimental_output?: Output
|
3325
|
+
experimental_output?: Output<OUTPUT, PARTIAL_OUTPUT>;
|
3309
3326
|
/**
|
3310
3327
|
Optional function that you can use to provide different settings for a step.
|
3311
3328
|
|
@@ -3594,14 +3611,14 @@ functionality that can be fully encapsulated in the provider.
|
|
3594
3611
|
@returns
|
3595
3612
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
3596
3613
|
*/
|
3597
|
-
declare function generateObject<
|
3614
|
+
declare function generateObject<SCHEMA extends z3.Schema | z4.$ZodType | Schema = z4.$ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
3598
3615
|
/**
|
3599
3616
|
The enum values that the model should use.
|
3600
3617
|
*/
|
3601
3618
|
enum: Array<RESULT>;
|
3602
3619
|
mode?: 'json';
|
3603
3620
|
output: 'enum';
|
3604
|
-
} :
|
3621
|
+
} : OUTPUT extends 'no-schema' ? {} : {
|
3605
3622
|
/**
|
3606
3623
|
The schema of the object that the model should generate.
|
3607
3624
|
*/
|
@@ -3633,7 +3650,7 @@ Default and recommended: 'auto' (best mode for the model).
|
|
3633
3650
|
*/
|
3634
3651
|
mode?: 'auto' | 'json' | 'tool';
|
3635
3652
|
}) & {
|
3636
|
-
output?:
|
3653
|
+
output?: OUTPUT;
|
3637
3654
|
/**
|
3638
3655
|
The language model to use.
|
3639
3656
|
*/
|
@@ -3695,15 +3712,6 @@ declare function parsePartialJson(jsonText: string | undefined): Promise<{
|
|
3695
3712
|
state: 'undefined-input' | 'successful-parse' | 'repaired-parse' | 'failed-parse';
|
3696
3713
|
}>;
|
3697
3714
|
|
3698
|
-
type Job = () => Promise<void>;
|
3699
|
-
|
3700
|
-
declare class SerialJobExecutor {
|
3701
|
-
private queue;
|
3702
|
-
private isProcessing;
|
3703
|
-
private processQueue;
|
3704
|
-
run(job: Job): Promise<void>;
|
3705
|
-
}
|
3706
|
-
|
3707
3715
|
/**
|
3708
3716
|
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
3709
3717
|
*
|
@@ -3911,14 +3919,14 @@ functionality that can be fully encapsulated in the provider.
|
|
3911
3919
|
@returns
|
3912
3920
|
A result object for accessing the partial object stream and additional information.
|
3913
3921
|
*/
|
3914
|
-
declare function streamObject<
|
3922
|
+
declare function streamObject<SCHEMA extends z3.Schema | z4.$ZodType | Schema = z4.$ZodType<JSONValue$1>, OUTPUT extends 'object' | 'array' | 'enum' | 'no-schema' = InferSchema<SCHEMA> extends string ? 'enum' : 'object', RESULT = OUTPUT extends 'array' ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(options: Omit<CallSettings, 'stopSequences'> & Prompt & (OUTPUT extends 'enum' ? {
|
3915
3923
|
/**
|
3916
3924
|
The enum values that the model should use.
|
3917
3925
|
*/
|
3918
3926
|
enum: Array<RESULT>;
|
3919
3927
|
mode?: 'json';
|
3920
3928
|
output: 'enum';
|
3921
|
-
} :
|
3929
|
+
} : OUTPUT extends 'no-schema' ? {} : {
|
3922
3930
|
/**
|
3923
3931
|
The schema of the object that the model should generate.
|
3924
3932
|
*/
|
@@ -3950,7 +3958,7 @@ Default and recommended: 'auto' (best mode for the model).
|
|
3950
3958
|
*/
|
3951
3959
|
mode?: 'auto' | 'json' | 'tool';
|
3952
3960
|
}) & {
|
3953
|
-
output?:
|
3961
|
+
output?: OUTPUT;
|
3954
3962
|
/**
|
3955
3963
|
The language model to use.
|
3956
3964
|
*/
|
@@ -3983,7 +3991,7 @@ Callback that is called when the LLM response and the final object validation ar
|
|
3983
3991
|
currentDate?: () => Date;
|
3984
3992
|
now?: () => number;
|
3985
3993
|
};
|
3986
|
-
}): StreamObjectResult<
|
3994
|
+
}): StreamObjectResult<OUTPUT extends 'enum' ? string : OUTPUT extends 'array' ? RESULT : DeepPartial<RESULT>, OUTPUT extends 'array' ? RESULT : RESULT, OUTPUT extends 'array' ? RESULT extends Array<infer U> ? AsyncIterableStream<U> : never : never>;
|
3987
3995
|
|
3988
3996
|
/**
|
3989
3997
|
* A generated audio file.
|
@@ -4448,114 +4456,72 @@ interface ChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> {
|
|
4448
4456
|
requestType: 'generate' | 'resume';
|
4449
4457
|
}) => Promise<ReadableStream<UIMessageStreamPart>>;
|
4450
4458
|
}
|
4451
|
-
|
4452
|
-
|
4453
|
-
|
4454
|
-
|
4455
|
-
|
4456
|
-
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4464
|
-
|
4465
|
-
|
4466
|
-
|
4467
|
-
|
4468
|
-
|
4469
|
-
|
4470
|
-
|
4471
|
-
|
4472
|
-
|
4473
|
-
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4487
|
-
|
4488
|
-
|
4489
|
-
|
4490
|
-
|
4491
|
-
|
4492
|
-
|
4493
|
-
|
4494
|
-
|
4495
|
-
|
4496
|
-
|
4497
|
-
|
4498
|
-
|
4499
|
-
|
4500
|
-
|
4501
|
-
|
4502
|
-
|
4503
|
-
|
4504
|
-
|
4505
|
-
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4509
|
-
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4514
|
-
|
4515
|
-
|
4516
|
-
|
4517
|
-
* Defaults to 'same-origin'.
|
4518
|
-
*/
|
4519
|
-
credentials?: RequestCredentials;
|
4520
|
-
/**
|
4521
|
-
* HTTP headers to be sent with the API request.
|
4522
|
-
*/
|
4523
|
-
headers?: Record<string, string> | Headers;
|
4524
|
-
/**
|
4525
|
-
* Extra body object to be sent with the API request.
|
4526
|
-
* @example
|
4527
|
-
* Send a `sessionId` to the API along with the messages.
|
4528
|
-
* ```js
|
4529
|
-
* useChat({
|
4530
|
-
* body: {
|
4531
|
-
* sessionId: '123',
|
4532
|
-
* }
|
4533
|
-
* })
|
4534
|
-
* ```
|
4535
|
-
*/
|
4536
|
-
body?: object;
|
4537
|
-
/**
|
4538
|
-
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
4539
|
-
or to provide a custom fetch implementation for e.g. testing.
|
4540
|
-
*/
|
4541
|
-
fetch?: FetchFunction;
|
4542
|
-
/**
|
4543
|
-
* When a function is provided, it will be used
|
4544
|
-
* to prepare the request body for the chat API. This can be useful for
|
4545
|
-
* customizing the request body based on the messages and data in the chat.
|
4546
|
-
*
|
4547
|
-
* @param id The id of the chat.
|
4548
|
-
* @param messages The current messages in the chat.
|
4549
|
-
* @param requestBody The request body object passed in the chat request.
|
4550
|
-
*/
|
4551
|
-
prepareRequestBody?: (options: {
|
4552
|
-
chatId: string;
|
4553
|
-
messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
|
4554
|
-
requestBody?: object;
|
4555
|
-
}) => unknown;
|
4556
|
-
});
|
4557
|
-
submitMessages({ chatId, messages, abortController, body, headers, requestType, }: Parameters<ChatTransport<MESSAGE_METADATA, DATA_TYPES>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
|
4558
|
-
}
|
4459
|
+
|
4460
|
+
type ChatRequestOptions = {
|
4461
|
+
/**
|
4462
|
+
Additional headers that should be to be passed to the API endpoint.
|
4463
|
+
*/
|
4464
|
+
headers?: Record<string, string> | Headers;
|
4465
|
+
/**
|
4466
|
+
Additional body JSON properties that should be sent to the API endpoint.
|
4467
|
+
*/
|
4468
|
+
body?: object;
|
4469
|
+
};
|
4470
|
+
type UseChatOptions<MESSAGE_METADATA = unknown, DATA_TYPE_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = {
|
4471
|
+
/**
|
4472
|
+
* A unique identifier for the chat. If not provided, a random one will be
|
4473
|
+
* generated. When provided, the `useChat` hook with the same `id` will
|
4474
|
+
* have shared states across components.
|
4475
|
+
*/
|
4476
|
+
chatId?: string;
|
4477
|
+
/**
|
4478
|
+
* Initial input of the chat.
|
4479
|
+
*/
|
4480
|
+
initialInput?: string;
|
4481
|
+
/**
|
4482
|
+
Optional callback function that is invoked when a tool call is received.
|
4483
|
+
Intended for automatic client-side tool execution.
|
4484
|
+
|
4485
|
+
You can optionally return a result for the tool call,
|
4486
|
+
either synchronously or asynchronously.
|
4487
|
+
*/
|
4488
|
+
onToolCall?: ({ toolCall, }: {
|
4489
|
+
toolCall: ToolCall<string, unknown>;
|
4490
|
+
}) => void | Promise<unknown> | unknown;
|
4491
|
+
/**
|
4492
|
+
* Optional callback function that is called when the assistant message is finished streaming.
|
4493
|
+
*
|
4494
|
+
* @param message The message that was streamed.
|
4495
|
+
*/
|
4496
|
+
onFinish?: (options: {
|
4497
|
+
message: UIMessage<MESSAGE_METADATA, InferUIDataParts<DATA_TYPE_SCHEMAS>>;
|
4498
|
+
}) => void;
|
4499
|
+
/**
|
4500
|
+
* Callback function to be called when an error is encountered.
|
4501
|
+
*/
|
4502
|
+
onError?: (error: Error) => void;
|
4503
|
+
/**
|
4504
|
+
* A way to provide a function that is going to be used for ids for messages and the chat.
|
4505
|
+
* If not provided the default AI SDK `generateId` is used.
|
4506
|
+
*/
|
4507
|
+
generateId?: IdGenerator;
|
4508
|
+
/**
|
4509
|
+
* Chat store that should be used.
|
4510
|
+
* It must not change during the component lifecycle.
|
4511
|
+
*
|
4512
|
+
* When a ChatStore is provided, it will be used as is.
|
4513
|
+
* It should be stable and the stability is guaranteed by the user.
|
4514
|
+
*
|
4515
|
+
* When a function is provided, it will be called to create a new chat store.
|
4516
|
+
* The function will be called when the hook is mounted and the chat store will be
|
4517
|
+
* created.
|
4518
|
+
* The function will be called with the same arguments as the hook is called with.
|
4519
|
+
* The function should return a ChatStoreOptions object.
|
4520
|
+
*
|
4521
|
+
* When no value is provided, a default chat store will be created.
|
4522
|
+
*/
|
4523
|
+
chatStore?: ChatStore<MESSAGE_METADATA, DATA_TYPE_SCHEMAS> | (() => ChatStoreOptions<MESSAGE_METADATA, DATA_TYPE_SCHEMAS>);
|
4524
|
+
};
|
4559
4525
|
|
4560
4526
|
type StreamingUIMessageState<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = {
|
4561
4527
|
message: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>;
|
@@ -4563,11 +4529,9 @@ type StreamingUIMessageState<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS ex
|
|
4563
4529
|
activeReasoningPart: ReasoningUIPart | undefined;
|
4564
4530
|
partialToolCalls: Record<string, {
|
4565
4531
|
text: string;
|
4566
|
-
step: number;
|
4567
4532
|
index: number;
|
4568
4533
|
toolName: string;
|
4569
4534
|
}>;
|
4570
|
-
step: number;
|
4571
4535
|
};
|
4572
4536
|
|
4573
4537
|
interface ChatStoreSubscriber {
|
@@ -4699,127 +4663,46 @@ declare class ChatStore<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends
|
|
4699
4663
|
chatId: string;
|
4700
4664
|
}): Promise<void>;
|
4701
4665
|
private emit;
|
4702
|
-
private
|
4666
|
+
private getChat;
|
4703
4667
|
private triggerRequest;
|
4704
4668
|
}
|
4705
4669
|
|
4706
|
-
|
4670
|
+
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
4671
|
+
|
4672
|
+
/**
|
4673
|
+
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
4674
|
+
with the AI core functions (e.g. `streamText`).
|
4675
|
+
*/
|
4676
|
+
declare function convertToModelMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
4677
|
+
tools?: TOOLS;
|
4678
|
+
}): ModelMessage[];
|
4679
|
+
/**
|
4680
|
+
@deprecated Use `convertToModelMessages` instead.
|
4681
|
+
*/
|
4682
|
+
declare const convertToCoreMessages: typeof convertToModelMessages;
|
4683
|
+
|
4684
|
+
interface DefaultChatStoreOptions<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> {
|
4707
4685
|
/**
|
4708
|
-
|
4686
|
+
* Schema for the message metadata. Validates the message metadata.
|
4687
|
+
* Message metadata can be undefined or must match the schema.
|
4709
4688
|
*/
|
4710
|
-
|
4689
|
+
messageMetadataSchema?: Validator<MESSAGE_METADATA> | StandardSchemaV1<MESSAGE_METADATA>;
|
4711
4690
|
/**
|
4712
|
-
|
4691
|
+
* Schema for the data types. Validates the data types.
|
4713
4692
|
*/
|
4714
|
-
|
4715
|
-
};
|
4716
|
-
type UseChatOptions<MESSAGE_METADATA = unknown, DATA_TYPE_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas> = {
|
4693
|
+
dataPartSchemas?: UI_DATA_PART_SCHEMAS;
|
4717
4694
|
/**
|
4718
|
-
*
|
4719
|
-
*
|
4720
|
-
*
|
4695
|
+
* The API endpoint that accepts a `{ messages: Message[] }` object and returns
|
4696
|
+
* a stream of tokens of the AI chat response.
|
4697
|
+
*
|
4698
|
+
* Defaults to `/api/chat`
|
4721
4699
|
*/
|
4722
|
-
|
4700
|
+
api?: string;
|
4723
4701
|
/**
|
4724
|
-
*
|
4702
|
+
* A way to provide a function that is going to be used for ids for messages and the chat.
|
4703
|
+
* If not provided the default AI SDK `generateId` is used.
|
4725
4704
|
*/
|
4726
|
-
|
4727
|
-
/**
|
4728
|
-
Optional callback function that is invoked when a tool call is received.
|
4729
|
-
Intended for automatic client-side tool execution.
|
4730
|
-
|
4731
|
-
You can optionally return a result for the tool call,
|
4732
|
-
either synchronously or asynchronously.
|
4733
|
-
*/
|
4734
|
-
onToolCall?: ({ toolCall, }: {
|
4735
|
-
toolCall: ToolCall<string, unknown>;
|
4736
|
-
}) => void | Promise<unknown> | unknown;
|
4737
|
-
/**
|
4738
|
-
* Optional callback function that is called when the assistant message is finished streaming.
|
4739
|
-
*
|
4740
|
-
* @param message The message that was streamed.
|
4741
|
-
*/
|
4742
|
-
onFinish?: (options: {
|
4743
|
-
message: UIMessage<MESSAGE_METADATA, InferUIDataParts<DATA_TYPE_SCHEMAS>>;
|
4744
|
-
}) => void;
|
4745
|
-
/**
|
4746
|
-
* Callback function to be called when an error is encountered.
|
4747
|
-
*/
|
4748
|
-
onError?: (error: Error) => void;
|
4749
|
-
/**
|
4750
|
-
* A way to provide a function that is going to be used for ids for messages and the chat.
|
4751
|
-
* If not provided the default AI SDK `generateId` is used.
|
4752
|
-
*/
|
4753
|
-
generateId?: IdGenerator;
|
4754
|
-
/**
|
4755
|
-
* Chat store that should be used.
|
4756
|
-
* It must not change during the component lifecycle.
|
4757
|
-
*
|
4758
|
-
* When a ChatStore is provided, it will be used as is.
|
4759
|
-
* It should be stable and the stability is guaranteed by the user.
|
4760
|
-
*
|
4761
|
-
* When a function is provided, it will be called to create a new chat store.
|
4762
|
-
* The function will be called when the hook is mounted and the chat store will be
|
4763
|
-
* created.
|
4764
|
-
* The function will be called with the same arguments as the hook is called with.
|
4765
|
-
* The function should return a ChatStoreOptions object.
|
4766
|
-
*
|
4767
|
-
* When no value is provided, a default chat store will be created.
|
4768
|
-
*/
|
4769
|
-
chatStore?: ChatStore<MESSAGE_METADATA, DATA_TYPE_SCHEMAS> | (() => ChatStoreOptions<MESSAGE_METADATA, DATA_TYPE_SCHEMAS>);
|
4770
|
-
};
|
4771
|
-
type OriginalUseChatOptions<MESSAGE_METADATA = unknown> = {
|
4772
|
-
/**
|
4773
|
-
* Schema for the message metadata. Validates the message metadata.
|
4774
|
-
* Message metadata can be undefined or must match the schema.
|
4775
|
-
*/
|
4776
|
-
messageMetadataSchema?: Schema<MESSAGE_METADATA>;
|
4777
|
-
/**
|
4778
|
-
* The API endpoint that accepts a `{ messages: Message[] }` object and returns
|
4779
|
-
* a stream of tokens of the AI chat response. Defaults to `/api/chat`.
|
4780
|
-
*/
|
4781
|
-
api?: string;
|
4782
|
-
/**
|
4783
|
-
* A unique identifier for the chat. If not provided, a random one will be
|
4784
|
-
* generated. When provided, the `useChat` hook with the same `id` will
|
4785
|
-
* have shared states across components.
|
4786
|
-
*/
|
4787
|
-
chatId?: string;
|
4788
|
-
/**
|
4789
|
-
* Initial messages of the chat. Useful to load an existing chat history.
|
4790
|
-
*/
|
4791
|
-
initialMessages?: UIMessage<NoInfer<MESSAGE_METADATA>>[];
|
4792
|
-
/**
|
4793
|
-
* Initial input of the chat.
|
4794
|
-
*/
|
4795
|
-
initialInput?: string;
|
4796
|
-
/**
|
4797
|
-
Optional callback function that is invoked when a tool call is received.
|
4798
|
-
Intended for automatic client-side tool execution.
|
4799
|
-
|
4800
|
-
You can optionally return a result for the tool call,
|
4801
|
-
either synchronously or asynchronously.
|
4802
|
-
*/
|
4803
|
-
onToolCall?: ({ toolCall, }: {
|
4804
|
-
toolCall: ToolCall<string, unknown>;
|
4805
|
-
}) => void | Promise<unknown> | unknown;
|
4806
|
-
/**
|
4807
|
-
* Optional callback function that is called when the assistant message is finished streaming.
|
4808
|
-
*
|
4809
|
-
* @param message The message that was streamed.
|
4810
|
-
*/
|
4811
|
-
onFinish?: (options: {
|
4812
|
-
message: UIMessage<NoInfer<MESSAGE_METADATA>>;
|
4813
|
-
}) => void;
|
4814
|
-
/**
|
4815
|
-
* Callback function to be called when an error is encountered.
|
4816
|
-
*/
|
4817
|
-
onError?: (error: Error) => void;
|
4818
|
-
/**
|
4819
|
-
* A way to provide a function that is going to be used for ids for messages and the chat.
|
4820
|
-
* If not provided the default AI SDK `generateId` is used.
|
4821
|
-
*/
|
4822
|
-
generateId?: IdGenerator;
|
4705
|
+
generateId?: IdGenerator;
|
4823
4706
|
/**
|
4824
4707
|
* The credentials mode to be used for the fetch request.
|
4825
4708
|
* Possible values are: 'omit', 'same-origin', 'include'.
|
@@ -4844,109 +4727,152 @@ type OriginalUseChatOptions<MESSAGE_METADATA = unknown> = {
|
|
4844
4727
|
*/
|
4845
4728
|
body?: object;
|
4846
4729
|
/**
|
4847
|
-
|
4848
|
-
|
4849
|
-
|
4850
|
-
/**
|
4851
|
-
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
4852
|
-
or to provide a custom fetch implementation for e.g. testing.
|
4853
|
-
*/
|
4730
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
4731
|
+
or to provide a custom fetch implementation for e.g. testing.
|
4732
|
+
*/
|
4854
4733
|
fetch?: FetchFunction;
|
4855
4734
|
/**
|
4856
|
-
|
4857
|
-
|
4735
|
+
Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
|
4736
|
+
Must be at least 1.
|
4858
4737
|
|
4859
|
-
|
4738
|
+
A maximum number is required to prevent infinite loops in the case of misconfigured tools.
|
4860
4739
|
|
4861
|
-
|
4862
|
-
|
4740
|
+
By default, it's set to 1, which means that only a single LLM call is made.
|
4741
|
+
*/
|
4863
4742
|
maxSteps?: number;
|
4864
|
-
|
4865
|
-
|
4866
|
-
|
4867
|
-
|
4868
|
-
|
4869
|
-
|
4870
|
-
|
4871
|
-
|
4872
|
-
|
4873
|
-
|
4874
|
-
|
4875
|
-
|
4876
|
-
|
4877
|
-
|
4878
|
-
|
4879
|
-
|
4880
|
-
|
4881
|
-
|
4882
|
-
|
4883
|
-
|
4884
|
-
}):
|
4885
|
-
|
4886
|
-
declare const getOriginalFetch: () => typeof fetch;
|
4887
|
-
declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
|
4888
|
-
api: string;
|
4889
|
-
prompt: string;
|
4890
|
-
credentials: RequestCredentials | undefined;
|
4891
|
-
headers: HeadersInit | undefined;
|
4892
|
-
body: Record<string, any>;
|
4893
|
-
streamProtocol: 'data' | 'text' | undefined;
|
4894
|
-
setCompletion: (completion: string) => void;
|
4895
|
-
setLoading: (loading: boolean) => void;
|
4896
|
-
setError: (error: Error | undefined) => void;
|
4897
|
-
setAbortController: (abortController: AbortController | null) => void;
|
4898
|
-
onFinish: ((prompt: string, completion: string) => void) | undefined;
|
4899
|
-
onError: ((error: Error) => void) | undefined;
|
4900
|
-
fetch: ReturnType<typeof getOriginalFetch> | undefined;
|
4901
|
-
}): Promise<string | null | undefined>;
|
4902
|
-
|
4903
|
-
declare function convertFileListToFileUIParts(files: FileList | undefined): Promise<Array<FileUIPart>>;
|
4904
|
-
|
4905
|
-
/**
|
4906
|
-
Converts an array of messages from useChat into an array of CoreMessages that can be used
|
4907
|
-
with the AI core functions (e.g. `streamText`).
|
4908
|
-
*/
|
4909
|
-
declare function convertToModelMessages<TOOLS extends ToolSet = never>(messages: Array<Omit<UIMessage, 'id'>>, options?: {
|
4910
|
-
tools?: TOOLS;
|
4911
|
-
}): ModelMessage[];
|
4912
|
-
/**
|
4913
|
-
@deprecated Use `convertToModelMessages` instead.
|
4914
|
-
*/
|
4915
|
-
declare const convertToCoreMessages: typeof convertToModelMessages;
|
4743
|
+
/**
|
4744
|
+
* When a function is provided, it will be used
|
4745
|
+
* to prepare the request body for the chat API. This can be useful for
|
4746
|
+
* customizing the request body based on the messages and data in the chat.
|
4747
|
+
*
|
4748
|
+
* @param chatId The id of the chat.
|
4749
|
+
* @param messages The current messages in the chat.
|
4750
|
+
* @param requestBody The request body object passed in the chat request.
|
4751
|
+
*/
|
4752
|
+
prepareRequestBody?: (options: {
|
4753
|
+
chatId: string;
|
4754
|
+
messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
|
4755
|
+
requestBody?: object;
|
4756
|
+
}) => unknown;
|
4757
|
+
chats?: {
|
4758
|
+
[id: string]: {
|
4759
|
+
messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
|
4760
|
+
};
|
4761
|
+
};
|
4762
|
+
}
|
4763
|
+
declare function defaultChatStoreOptions<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas>({ api, fetch, credentials, headers, body, prepareRequestBody, generateId, messageMetadataSchema, maxSteps, dataPartSchemas, chats, }: DefaultChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>): () => ChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>;
|
4916
4764
|
|
4917
|
-
declare
|
4765
|
+
declare class DefaultChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
|
4766
|
+
private api;
|
4767
|
+
private credentials?;
|
4768
|
+
private headers?;
|
4769
|
+
private body?;
|
4770
|
+
private fetch?;
|
4771
|
+
private prepareRequestBody?;
|
4772
|
+
constructor({ api, credentials, headers, body, fetch, prepareRequestBody, }: {
|
4773
|
+
api: string;
|
4774
|
+
/**
|
4775
|
+
* The credentials mode to be used for the fetch request.
|
4776
|
+
* Possible values are: 'omit', 'same-origin', 'include'.
|
4777
|
+
* Defaults to 'same-origin'.
|
4778
|
+
*/
|
4779
|
+
credentials?: RequestCredentials;
|
4780
|
+
/**
|
4781
|
+
* HTTP headers to be sent with the API request.
|
4782
|
+
*/
|
4783
|
+
headers?: Record<string, string> | Headers;
|
4784
|
+
/**
|
4785
|
+
* Extra body object to be sent with the API request.
|
4786
|
+
* @example
|
4787
|
+
* Send a `sessionId` to the API along with the messages.
|
4788
|
+
* ```js
|
4789
|
+
* useChat({
|
4790
|
+
* body: {
|
4791
|
+
* sessionId: '123',
|
4792
|
+
* }
|
4793
|
+
* })
|
4794
|
+
* ```
|
4795
|
+
*/
|
4796
|
+
body?: object;
|
4797
|
+
/**
|
4798
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
4799
|
+
or to provide a custom fetch implementation for e.g. testing.
|
4800
|
+
*/
|
4801
|
+
fetch?: FetchFunction;
|
4802
|
+
/**
|
4803
|
+
* When a function is provided, it will be used
|
4804
|
+
* to prepare the request body for the chat API. This can be useful for
|
4805
|
+
* customizing the request body based on the messages and data in the chat.
|
4806
|
+
*
|
4807
|
+
* @param id The id of the chat.
|
4808
|
+
* @param messages The current messages in the chat.
|
4809
|
+
* @param requestBody The request body object passed in the chat request.
|
4810
|
+
*/
|
4811
|
+
prepareRequestBody?: (options: {
|
4812
|
+
chatId: string;
|
4813
|
+
messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
|
4814
|
+
requestBody?: object;
|
4815
|
+
}) => unknown;
|
4816
|
+
});
|
4817
|
+
submitMessages({ chatId, messages, abortController, body, headers, requestType, }: Parameters<ChatTransport<MESSAGE_METADATA, DATA_TYPES>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
|
4818
|
+
}
|
4918
4819
|
|
4919
4820
|
declare function getToolInvocations(message: UIMessage): ToolInvocation[];
|
4920
4821
|
|
4921
|
-
declare
|
4922
|
-
|
4923
|
-
|
4924
|
-
|
4925
|
-
|
4926
|
-
|
4927
|
-
|
4928
|
-
|
4929
|
-
|
4930
|
-
|
4931
|
-
|
4932
|
-
|
4933
|
-
|
4934
|
-
|
4935
|
-
|
4936
|
-
/**
|
4937
|
-
|
4938
|
-
|
4939
|
-
|
4940
|
-
|
4941
|
-
|
4942
|
-
|
4943
|
-
|
4944
|
-
|
4945
|
-
|
4946
|
-
|
4947
|
-
|
4948
|
-
|
4949
|
-
})
|
4822
|
+
declare class TextStreamChatTransport<MESSAGE_METADATA, DATA_TYPES extends UIDataTypes> implements ChatTransport<MESSAGE_METADATA, DATA_TYPES> {
|
4823
|
+
private api;
|
4824
|
+
private credentials?;
|
4825
|
+
private headers?;
|
4826
|
+
private body?;
|
4827
|
+
private fetch?;
|
4828
|
+
private prepareRequestBody?;
|
4829
|
+
constructor({ api, credentials, headers, body, fetch, prepareRequestBody, }: {
|
4830
|
+
api: string;
|
4831
|
+
/**
|
4832
|
+
* The credentials mode to be used for the fetch request.
|
4833
|
+
* Possible values are: 'omit', 'same-origin', 'include'.
|
4834
|
+
* Defaults to 'same-origin'.
|
4835
|
+
*/
|
4836
|
+
credentials?: RequestCredentials;
|
4837
|
+
/**
|
4838
|
+
* HTTP headers to be sent with the API request.
|
4839
|
+
*/
|
4840
|
+
headers?: Record<string, string> | Headers;
|
4841
|
+
/**
|
4842
|
+
* Extra body object to be sent with the API request.
|
4843
|
+
* @example
|
4844
|
+
* Send a `sessionId` to the API along with the messages.
|
4845
|
+
* ```js
|
4846
|
+
* useChat({
|
4847
|
+
* body: {
|
4848
|
+
* sessionId: '123',
|
4849
|
+
* }
|
4850
|
+
* })
|
4851
|
+
* ```
|
4852
|
+
*/
|
4853
|
+
body?: object;
|
4854
|
+
/**
|
4855
|
+
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
4856
|
+
or to provide a custom fetch implementation for e.g. testing.
|
4857
|
+
*/
|
4858
|
+
fetch?: FetchFunction;
|
4859
|
+
/**
|
4860
|
+
* When a function is provided, it will be used
|
4861
|
+
* to prepare the request body for the chat API. This can be useful for
|
4862
|
+
* customizing the request body based on the messages and data in the chat.
|
4863
|
+
*
|
4864
|
+
* @param id The id of the chat.
|
4865
|
+
* @param messages The current messages in the chat.
|
4866
|
+
* @param requestBody The request body object passed in the chat request.
|
4867
|
+
*/
|
4868
|
+
prepareRequestBody?: (options: {
|
4869
|
+
chatId: string;
|
4870
|
+
messages: UIMessage<MESSAGE_METADATA, DATA_TYPES>[];
|
4871
|
+
requestBody?: object;
|
4872
|
+
}) => unknown;
|
4873
|
+
});
|
4874
|
+
submitMessages({ chatId, messages, abortController, body, headers, requestType, }: Parameters<ChatTransport<MESSAGE_METADATA, DATA_TYPES>['submitMessages']>[0]): Promise<ReadableStream<UIMessageStreamPart>>;
|
4875
|
+
}
|
4950
4876
|
|
4951
4877
|
type CompletionRequestOptions = {
|
4952
4878
|
/**
|
@@ -5020,85 +4946,4 @@ type UseCompletionOptions = {
|
|
5020
4946
|
fetch?: FetchFunction;
|
5021
4947
|
};
|
5022
4948
|
|
5023
|
-
|
5024
|
-
/**
|
5025
|
-
* Schema for the message metadata. Validates the message metadata.
|
5026
|
-
* Message metadata can be undefined or must match the schema.
|
5027
|
-
*/
|
5028
|
-
messageMetadataSchema?: Validator<MESSAGE_METADATA> | StandardSchemaV1<MESSAGE_METADATA>;
|
5029
|
-
/**
|
5030
|
-
* Schema for the data types. Validates the data types.
|
5031
|
-
*/
|
5032
|
-
dataPartSchemas?: UI_DATA_PART_SCHEMAS;
|
5033
|
-
/**
|
5034
|
-
* The API endpoint that accepts a `{ messages: Message[] }` object and returns
|
5035
|
-
* a stream of tokens of the AI chat response.
|
5036
|
-
*
|
5037
|
-
* Defaults to `/api/chat`
|
5038
|
-
*/
|
5039
|
-
api?: string;
|
5040
|
-
/**
|
5041
|
-
* A way to provide a function that is going to be used for ids for messages and the chat.
|
5042
|
-
* If not provided the default AI SDK `generateId` is used.
|
5043
|
-
*/
|
5044
|
-
generateId?: IdGenerator;
|
5045
|
-
/**
|
5046
|
-
* The credentials mode to be used for the fetch request.
|
5047
|
-
* Possible values are: 'omit', 'same-origin', 'include'.
|
5048
|
-
* Defaults to 'same-origin'.
|
5049
|
-
*/
|
5050
|
-
credentials?: RequestCredentials;
|
5051
|
-
/**
|
5052
|
-
* HTTP headers to be sent with the API request.
|
5053
|
-
*/
|
5054
|
-
headers?: Record<string, string> | Headers;
|
5055
|
-
/**
|
5056
|
-
* Extra body object to be sent with the API request.
|
5057
|
-
* @example
|
5058
|
-
* Send a `sessionId` to the API along with the messages.
|
5059
|
-
* ```js
|
5060
|
-
* useChat({
|
5061
|
-
* body: {
|
5062
|
-
* sessionId: '123',
|
5063
|
-
* }
|
5064
|
-
* })
|
5065
|
-
* ```
|
5066
|
-
*/
|
5067
|
-
body?: object;
|
5068
|
-
/**
|
5069
|
-
Custom fetch implementation. You can use it as a middleware to intercept requests,
|
5070
|
-
or to provide a custom fetch implementation for e.g. testing.
|
5071
|
-
*/
|
5072
|
-
fetch?: FetchFunction;
|
5073
|
-
/**
|
5074
|
-
Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
|
5075
|
-
Must be at least 1.
|
5076
|
-
|
5077
|
-
A maximum number is required to prevent infinite loops in the case of misconfigured tools.
|
5078
|
-
|
5079
|
-
By default, it's set to 1, which means that only a single LLM call is made.
|
5080
|
-
*/
|
5081
|
-
maxSteps?: number;
|
5082
|
-
/**
|
5083
|
-
* When a function is provided, it will be used
|
5084
|
-
* to prepare the request body for the chat API. This can be useful for
|
5085
|
-
* customizing the request body based on the messages and data in the chat.
|
5086
|
-
*
|
5087
|
-
* @param chatId The id of the chat.
|
5088
|
-
* @param messages The current messages in the chat.
|
5089
|
-
* @param requestBody The request body object passed in the chat request.
|
5090
|
-
*/
|
5091
|
-
prepareRequestBody?: (options: {
|
5092
|
-
chatId: string;
|
5093
|
-
messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
|
5094
|
-
requestBody?: object;
|
5095
|
-
}) => unknown;
|
5096
|
-
chats?: {
|
5097
|
-
[id: string]: {
|
5098
|
-
messages: UIMessage<MESSAGE_METADATA, InferUIDataParts<UI_DATA_PART_SCHEMAS>>[];
|
5099
|
-
};
|
5100
|
-
};
|
5101
|
-
}
|
5102
|
-
declare function defaultChatStoreOptions<MESSAGE_METADATA = unknown, UI_DATA_PART_SCHEMAS extends UIDataPartSchemas = UIDataPartSchemas>({ api, fetch, credentials, headers, body, prepareRequestBody, generateId, messageMetadataSchema, maxSteps, dataPartSchemas, chats, }: DefaultChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>): () => ChatStoreOptions<MESSAGE_METADATA, UI_DATA_PART_SCHEMAS>;
|
5103
|
-
|
5104
|
-
export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, 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, 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, OriginalUseChatOptions, 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, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, appendClientMessage, assistantModelMessageSchema, callChatApi, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractMaxToolInvocationStep, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolInvocations, hasToolCall, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, shouldResubmitMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, updateToolCallResult, userModelMessageSchema, wrapLanguageModel };
|
4949
|
+
export { ActiveResponse, AssistantContent, AssistantModelMessage, CallSettings, CallWarning, Chat, ChatRequestOptions, ChatStatus, ChatStore, ChatStoreEvent, ChatStoreFactory, ChatStoreOptions, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataContent, DataUIPart, DeepPartial, DefaultChatStoreOptions, 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, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolModelMessage, ToolResultPart, ToolResultUnion, ToolSet, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessagePart, UIMessageStreamOptions, UIMessageStreamPart, UIMessageStreamWriter, UseChatOptions, UseCompletionOptions, UserContent, UserModelMessage, assistantModelMessageSchema, callCompletionApi, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultChatStoreOptions, 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, getToolInvocations, hasToolCall, isDeepEqualData, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, tool, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel };
|