ai 5.0.0-beta.24 → 5.0.0-beta.26
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 +21 -0
- package/dist/bin/ai.min.js +74 -12
- package/dist/index.d.mts +33 -17
- package/dist/index.d.ts +33 -17
- package/dist/index.js +85 -119
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -119
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/bin/ai.js +0 -4736
- package/dist/bin/ai.js.map +0 -1
package/dist/index.d.mts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, Schema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, InferSchema, FlexibleSchema, DataContent, Validator, StandardSchemaV1,
|
1
|
+
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';
|
2
2
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, generateId, jsonSchema, tool } from '@ai-sdk/provider-utils';
|
3
3
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
4
4
|
import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV2Usage, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
@@ -1018,7 +1018,7 @@ Callback that is set using the `onChunk` option.
|
|
1018
1018
|
*/
|
1019
1019
|
type StreamTextOnChunkCallback<TOOLS extends ToolSet> = (event: {
|
1020
1020
|
chunk: Extract<TextStreamPart<TOOLS>, {
|
1021
|
-
type: 'text' | 'reasoning' | 'source' | 'tool-call' | 'tool-input-start' | 'tool-input-delta' | 'tool-result' | 'raw';
|
1021
|
+
type: 'text-delta' | 'reasoning-delta' | 'source' | 'tool-call' | 'tool-input-start' | 'tool-input-delta' | 'tool-result' | 'raw';
|
1022
1022
|
}>;
|
1023
1023
|
}) => PromiseLike<void> | void;
|
1024
1024
|
/**
|
@@ -1383,6 +1383,12 @@ declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataT
|
|
1383
1383
|
declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): keyof TOOLS;
|
1384
1384
|
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA> ? METADATA : unknown;
|
1385
1385
|
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
1386
|
+
type InferUIMessageTools<T extends UIMessage> = T extends UIMessage<unknown, UIDataTypes, infer TOOLS> ? TOOLS : UITools;
|
1387
|
+
type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
|
1388
|
+
[NAME in keyof InferUIMessageTools<UI_MESSAGE>]: ToolCall<NAME & string, InferUIMessageTools<UI_MESSAGE>[NAME] extends {
|
1389
|
+
input: infer INPUT;
|
1390
|
+
} ? INPUT : never>;
|
1391
|
+
}>;
|
1386
1392
|
|
1387
1393
|
type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
1388
1394
|
[NAME in keyof DATA_TYPES & string]: {
|
@@ -1767,7 +1773,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
1767
1773
|
id: string;
|
1768
1774
|
providerMetadata?: ProviderMetadata;
|
1769
1775
|
} | {
|
1770
|
-
type: 'text';
|
1776
|
+
type: 'text-delta';
|
1771
1777
|
id: string;
|
1772
1778
|
providerMetadata?: ProviderMetadata;
|
1773
1779
|
text: string;
|
@@ -1780,7 +1786,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
1780
1786
|
id: string;
|
1781
1787
|
providerMetadata?: ProviderMetadata;
|
1782
1788
|
} | {
|
1783
|
-
type: 'reasoning';
|
1789
|
+
type: 'reasoning-delta';
|
1784
1790
|
providerMetadata?: ProviderMetadata;
|
1785
1791
|
id: string;
|
1786
1792
|
text: string;
|
@@ -3647,13 +3653,17 @@ declare function pipeUIMessageStreamToResponse({ response, status, statusText, h
|
|
3647
3653
|
*
|
3648
3654
|
* @param options.message - The last assistant message to use as a starting point when the conversation is resumed. Otherwise undefined.
|
3649
3655
|
* @param options.stream - The stream of `UIMessageChunk`s to read.
|
3656
|
+
* @param options.terminateOnError - Whether to terminate the stream if an error occurs.
|
3657
|
+
* @param options.onError - A function that is called when an error occurs.
|
3650
3658
|
*
|
3651
3659
|
* @returns An `AsyncIterableStream` of `UIMessage`s. Each stream part is a different state of the same message
|
3652
3660
|
* as it is being completed.
|
3653
3661
|
*/
|
3654
|
-
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({ message, stream, }: {
|
3662
|
+
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({ message, stream, onError, terminateOnError, }: {
|
3655
3663
|
message?: UI_MESSAGE;
|
3656
3664
|
stream: ReadableStream<UIMessageChunk>;
|
3665
|
+
onError?: (error: unknown) => void;
|
3666
|
+
terminateOnError?: boolean;
|
3657
3667
|
}): AsyncIterableStream<UI_MESSAGE>;
|
3658
3668
|
|
3659
3669
|
declare const UI_MESSAGE_STREAM_HEADERS: {
|
@@ -3670,7 +3680,7 @@ interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
|
3670
3680
|
messages: UI_MESSAGE[];
|
3671
3681
|
abortSignal: AbortSignal | undefined;
|
3672
3682
|
} & {
|
3673
|
-
trigger: 'submit-
|
3683
|
+
trigger: 'submit-message' | 'regenerate-message';
|
3674
3684
|
messageId: string | undefined;
|
3675
3685
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
3676
3686
|
reconnectToStream: (options: {
|
@@ -3711,9 +3721,9 @@ interface ChatState<UI_MESSAGE extends UIMessage> {
|
|
3711
3721
|
snapshot: <T>(thing: T) => T;
|
3712
3722
|
}
|
3713
3723
|
type ChatOnErrorCallback = (error: Error) => void;
|
3714
|
-
type ChatOnToolCallCallback =
|
3715
|
-
toolCall:
|
3716
|
-
}) => void |
|
3724
|
+
type ChatOnToolCallCallback<UI_MESSAGE extends UIMessage = UIMessage> = (options: {
|
3725
|
+
toolCall: InferUIMessageToolCall<UI_MESSAGE>;
|
3726
|
+
}) => void | PromiseLike<void>;
|
3717
3727
|
type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<InferUIMessageData<UI_MESSAGE>>) => void;
|
3718
3728
|
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
3719
3729
|
message: UI_MESSAGE;
|
@@ -3733,7 +3743,6 @@ interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
3733
3743
|
*/
|
3734
3744
|
generateId?: IdGenerator;
|
3735
3745
|
transport?: ChatTransport<UI_MESSAGE>;
|
3736
|
-
maxSteps?: number;
|
3737
3746
|
/**
|
3738
3747
|
* Callback function to be called when an error is encountered.
|
3739
3748
|
*/
|
@@ -3745,7 +3754,7 @@ interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
3745
3754
|
You can optionally return a result for the tool call,
|
3746
3755
|
either synchronously or asynchronously.
|
3747
3756
|
*/
|
3748
|
-
onToolCall?: ChatOnToolCallCallback
|
3757
|
+
onToolCall?: ChatOnToolCallCallback<UI_MESSAGE>;
|
3749
3758
|
/**
|
3750
3759
|
* Optional callback function that is called when the assistant message is finished streaming.
|
3751
3760
|
*
|
@@ -3766,14 +3775,13 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3766
3775
|
private messageMetadataSchema;
|
3767
3776
|
private dataPartSchemas;
|
3768
3777
|
private readonly transport;
|
3769
|
-
private maxSteps;
|
3770
3778
|
private onError?;
|
3771
3779
|
private onToolCall?;
|
3772
3780
|
private onFinish?;
|
3773
3781
|
private onData?;
|
3774
3782
|
private activeResponse;
|
3775
3783
|
private jobExecutor;
|
3776
|
-
constructor({ generateId, id, transport,
|
3784
|
+
constructor({ generateId, id, transport, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, onData, }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
3777
3785
|
state: ChatState<UI_MESSAGE>;
|
3778
3786
|
});
|
3779
3787
|
/**
|
@@ -3799,7 +3807,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3799
3807
|
*
|
3800
3808
|
* If a messageId is provided, the message will be replaced.
|
3801
3809
|
*/
|
3802
|
-
sendMessage: (message
|
3810
|
+
sendMessage: (message?: (CreateUIMessage<UI_MESSAGE> & {
|
3803
3811
|
text?: never;
|
3804
3812
|
files?: never;
|
3805
3813
|
messageId?: string;
|
@@ -3826,10 +3834,18 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3826
3834
|
* Attempt to resume an ongoing streaming response.
|
3827
3835
|
*/
|
3828
3836
|
resumeStream: (options?: ChatRequestOptions) => Promise<void>;
|
3829
|
-
addToolResult: ({ toolCallId, output, }: {
|
3837
|
+
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ tool, toolCallId, output, }: {
|
3838
|
+
tool: TOOL;
|
3830
3839
|
toolCallId: string;
|
3831
|
-
output:
|
3840
|
+
output: InferUIMessageTools<UI_MESSAGE>[TOOL]["output"];
|
3832
3841
|
}) => Promise<void>;
|
3842
|
+
/**
|
3843
|
+
* Checks if the assistant message can be submitted, i.e. if it
|
3844
|
+
* has tool calls and all tool calls have results.
|
3845
|
+
*
|
3846
|
+
* @returns {boolean} True if the assistant message can be submitted, false otherwise.
|
3847
|
+
*/
|
3848
|
+
canAssistantMessageBeSubmitted: () => boolean;
|
3833
3849
|
/**
|
3834
3850
|
* Abort the current request immediately, keep the generated tokens if any.
|
3835
3851
|
*/
|
@@ -3865,7 +3881,7 @@ type PrepareSendMessagesRequest<UI_MESSAGE extends UIMessage> = (options: {
|
|
3865
3881
|
headers: HeadersInit | undefined;
|
3866
3882
|
api: string;
|
3867
3883
|
} & {
|
3868
|
-
trigger: 'submit-
|
3884
|
+
trigger: 'submit-message' | 'regenerate-message';
|
3869
3885
|
messageId: string | undefined;
|
3870
3886
|
}) => {
|
3871
3887
|
body: object;
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, Schema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, InferSchema, FlexibleSchema, DataContent, Validator, StandardSchemaV1,
|
1
|
+
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';
|
2
2
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, generateId, jsonSchema, tool } from '@ai-sdk/provider-utils';
|
3
3
|
import { AttributeValue, Tracer } from '@opentelemetry/api';
|
4
4
|
import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV2Usage, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
|
@@ -1018,7 +1018,7 @@ Callback that is set using the `onChunk` option.
|
|
1018
1018
|
*/
|
1019
1019
|
type StreamTextOnChunkCallback<TOOLS extends ToolSet> = (event: {
|
1020
1020
|
chunk: Extract<TextStreamPart<TOOLS>, {
|
1021
|
-
type: 'text' | 'reasoning' | 'source' | 'tool-call' | 'tool-input-start' | 'tool-input-delta' | 'tool-result' | 'raw';
|
1021
|
+
type: 'text-delta' | 'reasoning-delta' | 'source' | 'tool-call' | 'tool-input-start' | 'tool-input-delta' | 'tool-result' | 'raw';
|
1022
1022
|
}>;
|
1023
1023
|
}) => PromiseLike<void> | void;
|
1024
1024
|
/**
|
@@ -1383,6 +1383,12 @@ declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataT
|
|
1383
1383
|
declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): keyof TOOLS;
|
1384
1384
|
type InferUIMessageMetadata<T extends UIMessage> = T extends UIMessage<infer METADATA> ? METADATA : unknown;
|
1385
1385
|
type InferUIMessageData<T extends UIMessage> = T extends UIMessage<unknown, infer DATA_TYPES> ? DATA_TYPES : UIDataTypes;
|
1386
|
+
type InferUIMessageTools<T extends UIMessage> = T extends UIMessage<unknown, UIDataTypes, infer TOOLS> ? TOOLS : UITools;
|
1387
|
+
type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
|
1388
|
+
[NAME in keyof InferUIMessageTools<UI_MESSAGE>]: ToolCall<NAME & string, InferUIMessageTools<UI_MESSAGE>[NAME] extends {
|
1389
|
+
input: infer INPUT;
|
1390
|
+
} ? INPUT : never>;
|
1391
|
+
}>;
|
1386
1392
|
|
1387
1393
|
type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
|
1388
1394
|
[NAME in keyof DATA_TYPES & string]: {
|
@@ -1767,7 +1773,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
1767
1773
|
id: string;
|
1768
1774
|
providerMetadata?: ProviderMetadata;
|
1769
1775
|
} | {
|
1770
|
-
type: 'text';
|
1776
|
+
type: 'text-delta';
|
1771
1777
|
id: string;
|
1772
1778
|
providerMetadata?: ProviderMetadata;
|
1773
1779
|
text: string;
|
@@ -1780,7 +1786,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
|
|
1780
1786
|
id: string;
|
1781
1787
|
providerMetadata?: ProviderMetadata;
|
1782
1788
|
} | {
|
1783
|
-
type: 'reasoning';
|
1789
|
+
type: 'reasoning-delta';
|
1784
1790
|
providerMetadata?: ProviderMetadata;
|
1785
1791
|
id: string;
|
1786
1792
|
text: string;
|
@@ -3647,13 +3653,17 @@ declare function pipeUIMessageStreamToResponse({ response, status, statusText, h
|
|
3647
3653
|
*
|
3648
3654
|
* @param options.message - The last assistant message to use as a starting point when the conversation is resumed. Otherwise undefined.
|
3649
3655
|
* @param options.stream - The stream of `UIMessageChunk`s to read.
|
3656
|
+
* @param options.terminateOnError - Whether to terminate the stream if an error occurs.
|
3657
|
+
* @param options.onError - A function that is called when an error occurs.
|
3650
3658
|
*
|
3651
3659
|
* @returns An `AsyncIterableStream` of `UIMessage`s. Each stream part is a different state of the same message
|
3652
3660
|
* as it is being completed.
|
3653
3661
|
*/
|
3654
|
-
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({ message, stream, }: {
|
3662
|
+
declare function readUIMessageStream<UI_MESSAGE extends UIMessage>({ message, stream, onError, terminateOnError, }: {
|
3655
3663
|
message?: UI_MESSAGE;
|
3656
3664
|
stream: ReadableStream<UIMessageChunk>;
|
3665
|
+
onError?: (error: unknown) => void;
|
3666
|
+
terminateOnError?: boolean;
|
3657
3667
|
}): AsyncIterableStream<UI_MESSAGE>;
|
3658
3668
|
|
3659
3669
|
declare const UI_MESSAGE_STREAM_HEADERS: {
|
@@ -3670,7 +3680,7 @@ interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
|
3670
3680
|
messages: UI_MESSAGE[];
|
3671
3681
|
abortSignal: AbortSignal | undefined;
|
3672
3682
|
} & {
|
3673
|
-
trigger: 'submit-
|
3683
|
+
trigger: 'submit-message' | 'regenerate-message';
|
3674
3684
|
messageId: string | undefined;
|
3675
3685
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
3676
3686
|
reconnectToStream: (options: {
|
@@ -3711,9 +3721,9 @@ interface ChatState<UI_MESSAGE extends UIMessage> {
|
|
3711
3721
|
snapshot: <T>(thing: T) => T;
|
3712
3722
|
}
|
3713
3723
|
type ChatOnErrorCallback = (error: Error) => void;
|
3714
|
-
type ChatOnToolCallCallback =
|
3715
|
-
toolCall:
|
3716
|
-
}) => void |
|
3724
|
+
type ChatOnToolCallCallback<UI_MESSAGE extends UIMessage = UIMessage> = (options: {
|
3725
|
+
toolCall: InferUIMessageToolCall<UI_MESSAGE>;
|
3726
|
+
}) => void | PromiseLike<void>;
|
3717
3727
|
type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<InferUIMessageData<UI_MESSAGE>>) => void;
|
3718
3728
|
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
3719
3729
|
message: UI_MESSAGE;
|
@@ -3733,7 +3743,6 @@ interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
3733
3743
|
*/
|
3734
3744
|
generateId?: IdGenerator;
|
3735
3745
|
transport?: ChatTransport<UI_MESSAGE>;
|
3736
|
-
maxSteps?: number;
|
3737
3746
|
/**
|
3738
3747
|
* Callback function to be called when an error is encountered.
|
3739
3748
|
*/
|
@@ -3745,7 +3754,7 @@ interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
3745
3754
|
You can optionally return a result for the tool call,
|
3746
3755
|
either synchronously or asynchronously.
|
3747
3756
|
*/
|
3748
|
-
onToolCall?: ChatOnToolCallCallback
|
3757
|
+
onToolCall?: ChatOnToolCallCallback<UI_MESSAGE>;
|
3749
3758
|
/**
|
3750
3759
|
* Optional callback function that is called when the assistant message is finished streaming.
|
3751
3760
|
*
|
@@ -3766,14 +3775,13 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3766
3775
|
private messageMetadataSchema;
|
3767
3776
|
private dataPartSchemas;
|
3768
3777
|
private readonly transport;
|
3769
|
-
private maxSteps;
|
3770
3778
|
private onError?;
|
3771
3779
|
private onToolCall?;
|
3772
3780
|
private onFinish?;
|
3773
3781
|
private onData?;
|
3774
3782
|
private activeResponse;
|
3775
3783
|
private jobExecutor;
|
3776
|
-
constructor({ generateId, id, transport,
|
3784
|
+
constructor({ generateId, id, transport, messageMetadataSchema, dataPartSchemas, state, onError, onToolCall, onFinish, onData, }: Omit<ChatInit<UI_MESSAGE>, 'messages'> & {
|
3777
3785
|
state: ChatState<UI_MESSAGE>;
|
3778
3786
|
});
|
3779
3787
|
/**
|
@@ -3799,7 +3807,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3799
3807
|
*
|
3800
3808
|
* If a messageId is provided, the message will be replaced.
|
3801
3809
|
*/
|
3802
|
-
sendMessage: (message
|
3810
|
+
sendMessage: (message?: (CreateUIMessage<UI_MESSAGE> & {
|
3803
3811
|
text?: never;
|
3804
3812
|
files?: never;
|
3805
3813
|
messageId?: string;
|
@@ -3826,10 +3834,18 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3826
3834
|
* Attempt to resume an ongoing streaming response.
|
3827
3835
|
*/
|
3828
3836
|
resumeStream: (options?: ChatRequestOptions) => Promise<void>;
|
3829
|
-
addToolResult: ({ toolCallId, output, }: {
|
3837
|
+
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ tool, toolCallId, output, }: {
|
3838
|
+
tool: TOOL;
|
3830
3839
|
toolCallId: string;
|
3831
|
-
output:
|
3840
|
+
output: InferUIMessageTools<UI_MESSAGE>[TOOL]["output"];
|
3832
3841
|
}) => Promise<void>;
|
3842
|
+
/**
|
3843
|
+
* Checks if the assistant message can be submitted, i.e. if it
|
3844
|
+
* has tool calls and all tool calls have results.
|
3845
|
+
*
|
3846
|
+
* @returns {boolean} True if the assistant message can be submitted, false otherwise.
|
3847
|
+
*/
|
3848
|
+
canAssistantMessageBeSubmitted: () => boolean;
|
3833
3849
|
/**
|
3834
3850
|
* Abort the current request immediately, keep the generated tokens if any.
|
3835
3851
|
*/
|
@@ -3865,7 +3881,7 @@ type PrepareSendMessagesRequest<UI_MESSAGE extends UIMessage> = (options: {
|
|
3865
3881
|
headers: HeadersInit | undefined;
|
3866
3882
|
api: string;
|
3867
3883
|
} & {
|
3868
|
-
trigger: 'submit-
|
3884
|
+
trigger: 'submit-message' | 'regenerate-message';
|
3869
3885
|
messageId: string | undefined;
|
3870
3886
|
}) => {
|
3871
3887
|
body: object;
|