ai 5.0.91 → 5.0.92
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 +6 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +22 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1751,6 +1751,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
1751
1751
|
messageMetadata?: unknown;
|
|
1752
1752
|
} | {
|
|
1753
1753
|
type: "finish";
|
|
1754
|
+
finishReason?: "other" | "length" | "unknown" | "error" | "stop" | "content-filter" | "tool-calls" | undefined;
|
|
1754
1755
|
messageMetadata?: unknown;
|
|
1755
1756
|
} | {
|
|
1756
1757
|
type: "abort";
|
|
@@ -1863,6 +1864,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
1863
1864
|
messageMetadata?: METADATA;
|
|
1864
1865
|
} | {
|
|
1865
1866
|
type: 'finish';
|
|
1867
|
+
finishReason?: FinishReason;
|
|
1866
1868
|
messageMetadata?: METADATA;
|
|
1867
1869
|
} | {
|
|
1868
1870
|
type: 'abort';
|
|
@@ -1891,6 +1893,10 @@ type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage> = (event: {
|
|
|
1891
1893
|
* (including the original message if it was extended).
|
|
1892
1894
|
*/
|
|
1893
1895
|
responseMessage: UI_MESSAGE;
|
|
1896
|
+
/**
|
|
1897
|
+
* The reason why the generation finished.
|
|
1898
|
+
*/
|
|
1899
|
+
finishReason?: FinishReason;
|
|
1894
1900
|
}) => PromiseLike<void> | void;
|
|
1895
1901
|
|
|
1896
1902
|
type UIMessageStreamResponseInit = ResponseInit & {
|
|
@@ -4071,6 +4077,7 @@ type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<In
|
|
|
4071
4077
|
* @param isAbort Indicates whether the request has been aborted.
|
|
4072
4078
|
* @param isDisconnect Indicates whether the request has been ended by a network error.
|
|
4073
4079
|
* @param isError Indicates whether the request has been ended by an error.
|
|
4080
|
+
* @param finishReason The reason why the generation finished.
|
|
4074
4081
|
*/
|
|
4075
4082
|
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
4076
4083
|
message: UI_MESSAGE;
|
|
@@ -4078,6 +4085,7 @@ type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
|
4078
4085
|
isAbort: boolean;
|
|
4079
4086
|
isDisconnect: boolean;
|
|
4080
4087
|
isError: boolean;
|
|
4088
|
+
finishReason?: FinishReason;
|
|
4081
4089
|
}) => void;
|
|
4082
4090
|
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
4083
4091
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1751,6 +1751,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
1751
1751
|
messageMetadata?: unknown;
|
|
1752
1752
|
} | {
|
|
1753
1753
|
type: "finish";
|
|
1754
|
+
finishReason?: "other" | "length" | "unknown" | "error" | "stop" | "content-filter" | "tool-calls" | undefined;
|
|
1754
1755
|
messageMetadata?: unknown;
|
|
1755
1756
|
} | {
|
|
1756
1757
|
type: "abort";
|
|
@@ -1863,6 +1864,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
1863
1864
|
messageMetadata?: METADATA;
|
|
1864
1865
|
} | {
|
|
1865
1866
|
type: 'finish';
|
|
1867
|
+
finishReason?: FinishReason;
|
|
1866
1868
|
messageMetadata?: METADATA;
|
|
1867
1869
|
} | {
|
|
1868
1870
|
type: 'abort';
|
|
@@ -1891,6 +1893,10 @@ type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage> = (event: {
|
|
|
1891
1893
|
* (including the original message if it was extended).
|
|
1892
1894
|
*/
|
|
1893
1895
|
responseMessage: UI_MESSAGE;
|
|
1896
|
+
/**
|
|
1897
|
+
* The reason why the generation finished.
|
|
1898
|
+
*/
|
|
1899
|
+
finishReason?: FinishReason;
|
|
1894
1900
|
}) => PromiseLike<void> | void;
|
|
1895
1901
|
|
|
1896
1902
|
type UIMessageStreamResponseInit = ResponseInit & {
|
|
@@ -4071,6 +4077,7 @@ type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<In
|
|
|
4071
4077
|
* @param isAbort Indicates whether the request has been aborted.
|
|
4072
4078
|
* @param isDisconnect Indicates whether the request has been ended by a network error.
|
|
4073
4079
|
* @param isError Indicates whether the request has been ended by an error.
|
|
4080
|
+
* @param finishReason The reason why the generation finished.
|
|
4074
4081
|
*/
|
|
4075
4082
|
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
4076
4083
|
message: UI_MESSAGE;
|
|
@@ -4078,6 +4085,7 @@ type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
|
4078
4085
|
isAbort: boolean;
|
|
4079
4086
|
isDisconnect: boolean;
|
|
4080
4087
|
isError: boolean;
|
|
4088
|
+
finishReason?: FinishReason;
|
|
4081
4089
|
}) => void;
|
|
4082
4090
|
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
4083
4091
|
/**
|
package/dist/index.js
CHANGED
|
@@ -764,7 +764,7 @@ function detectMediaType({
|
|
|
764
764
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
765
765
|
|
|
766
766
|
// src/version.ts
|
|
767
|
-
var VERSION = true ? "5.0.
|
|
767
|
+
var VERSION = true ? "5.0.92" : "0.0.0-test";
|
|
768
768
|
|
|
769
769
|
// src/util/download/download.ts
|
|
770
770
|
var download = async ({ url }) => {
|
|
@@ -3057,6 +3057,15 @@ var uiMessageChunkSchema = (0, import_provider_utils11.lazyValidator)(
|
|
|
3057
3057
|
}),
|
|
3058
3058
|
import_v47.z.strictObject({
|
|
3059
3059
|
type: import_v47.z.literal("finish"),
|
|
3060
|
+
finishReason: import_v47.z.enum([
|
|
3061
|
+
"stop",
|
|
3062
|
+
"length",
|
|
3063
|
+
"content-filter",
|
|
3064
|
+
"tool-calls",
|
|
3065
|
+
"error",
|
|
3066
|
+
"other",
|
|
3067
|
+
"unknown"
|
|
3068
|
+
]).optional(),
|
|
3060
3069
|
messageMetadata: import_v47.z.unknown().optional()
|
|
3061
3070
|
}),
|
|
3062
3071
|
import_v47.z.strictObject({
|
|
@@ -3877,6 +3886,9 @@ function processUIMessageStream({
|
|
|
3877
3886
|
break;
|
|
3878
3887
|
}
|
|
3879
3888
|
case "finish": {
|
|
3889
|
+
if (chunk.finishReason != null) {
|
|
3890
|
+
state.finishReason = chunk.finishReason;
|
|
3891
|
+
}
|
|
3880
3892
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
3881
3893
|
if (chunk.messageMetadata != null) {
|
|
3882
3894
|
write();
|
|
@@ -3984,7 +3996,8 @@ function handleUIMessageStreamFinish({
|
|
|
3984
3996
|
messages: [
|
|
3985
3997
|
...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
|
|
3986
3998
|
state.message
|
|
3987
|
-
]
|
|
3999
|
+
],
|
|
4000
|
+
finishReason: state.finishReason
|
|
3988
4001
|
});
|
|
3989
4002
|
};
|
|
3990
4003
|
return processUIMessageStream({
|
|
@@ -5716,6 +5729,7 @@ var DefaultStreamTextResult = class {
|
|
|
5716
5729
|
if (sendFinish) {
|
|
5717
5730
|
controller.enqueue({
|
|
5718
5731
|
type: "finish",
|
|
5732
|
+
finishReason: part.finishReason,
|
|
5719
5733
|
...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {}
|
|
5720
5734
|
});
|
|
5721
5735
|
}
|
|
@@ -9364,7 +9378,7 @@ var AbstractChat = class {
|
|
|
9364
9378
|
body,
|
|
9365
9379
|
messageId
|
|
9366
9380
|
}) {
|
|
9367
|
-
var _a16, _b, _c;
|
|
9381
|
+
var _a16, _b, _c, _d;
|
|
9368
9382
|
this.setStatus({ status: "submitted", error: void 0 });
|
|
9369
9383
|
const lastMessage = this.lastMessage;
|
|
9370
9384
|
let isAbort = false;
|
|
@@ -9461,22 +9475,23 @@ var AbstractChat = class {
|
|
|
9461
9475
|
this.setStatus({ status: "error", error: err });
|
|
9462
9476
|
} finally {
|
|
9463
9477
|
try {
|
|
9464
|
-
(
|
|
9478
|
+
(_b = this.onFinish) == null ? void 0 : _b.call(this, {
|
|
9465
9479
|
message: this.activeResponse.state.message,
|
|
9466
9480
|
messages: this.state.messages,
|
|
9467
9481
|
isAbort,
|
|
9468
9482
|
isDisconnect,
|
|
9469
|
-
isError
|
|
9483
|
+
isError,
|
|
9484
|
+
finishReason: (_a16 = this.activeResponse) == null ? void 0 : _a16.state.finishReason
|
|
9470
9485
|
});
|
|
9471
9486
|
} catch (err) {
|
|
9472
9487
|
console.error(err);
|
|
9473
9488
|
}
|
|
9474
9489
|
this.activeResponse = void 0;
|
|
9475
9490
|
}
|
|
9476
|
-
if (((
|
|
9491
|
+
if (((_c = this.sendAutomaticallyWhen) == null ? void 0 : _c.call(this, { messages: this.state.messages })) && !isError) {
|
|
9477
9492
|
await this.makeRequest({
|
|
9478
9493
|
trigger: "submit-message",
|
|
9479
|
-
messageId: (
|
|
9494
|
+
messageId: (_d = this.lastMessage) == null ? void 0 : _d.id,
|
|
9480
9495
|
metadata,
|
|
9481
9496
|
headers,
|
|
9482
9497
|
body
|