ai 6.0.0-beta.95 → 6.0.0-beta.97
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 +14 -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 +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.0-beta.97
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [32d8dbb]
|
|
8
|
+
- @ai-sdk/provider-utils@4.0.0-beta.32
|
|
9
|
+
- @ai-sdk/gateway@2.0.0-beta.51
|
|
10
|
+
|
|
11
|
+
## 6.0.0-beta.96
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- a322efa: Added finishReason on useChat onFinish callbck
|
|
16
|
+
|
|
3
17
|
## 6.0.0-beta.95
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2004,6 +2004,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
2004
2004
|
messageMetadata?: unknown;
|
|
2005
2005
|
} | {
|
|
2006
2006
|
type: "finish";
|
|
2007
|
+
finishReason?: "unknown" | "length" | "error" | "stop" | "content-filter" | "tool-calls" | "other" | undefined;
|
|
2007
2008
|
messageMetadata?: unknown;
|
|
2008
2009
|
} | {
|
|
2009
2010
|
type: "abort";
|
|
@@ -2126,6 +2127,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
2126
2127
|
messageMetadata?: METADATA;
|
|
2127
2128
|
} | {
|
|
2128
2129
|
type: 'finish';
|
|
2130
|
+
finishReason?: FinishReason;
|
|
2129
2131
|
messageMetadata?: METADATA;
|
|
2130
2132
|
} | {
|
|
2131
2133
|
type: 'abort';
|
|
@@ -2154,6 +2156,10 @@ type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage> = (event: {
|
|
|
2154
2156
|
* (including the original message if it was extended).
|
|
2155
2157
|
*/
|
|
2156
2158
|
responseMessage: UI_MESSAGE;
|
|
2159
|
+
/**
|
|
2160
|
+
* The reason why the generation finished.
|
|
2161
|
+
*/
|
|
2162
|
+
finishReason?: FinishReason;
|
|
2157
2163
|
}) => PromiseLike<void> | void;
|
|
2158
2164
|
|
|
2159
2165
|
type UIMessageStreamResponseInit = ResponseInit & {
|
|
@@ -2895,6 +2901,7 @@ type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<In
|
|
|
2895
2901
|
* @param isAbort Indicates whether the request has been aborted.
|
|
2896
2902
|
* @param isDisconnect Indicates whether the request has been ended by a network error.
|
|
2897
2903
|
* @param isError Indicates whether the request has been ended by an error.
|
|
2904
|
+
* @param finishReason The reason why the generation finished.
|
|
2898
2905
|
*/
|
|
2899
2906
|
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
2900
2907
|
message: UI_MESSAGE;
|
|
@@ -2902,6 +2909,7 @@ type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
|
2902
2909
|
isAbort: boolean;
|
|
2903
2910
|
isDisconnect: boolean;
|
|
2904
2911
|
isError: boolean;
|
|
2912
|
+
finishReason?: FinishReason;
|
|
2905
2913
|
}) => void;
|
|
2906
2914
|
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
2907
2915
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2004,6 +2004,7 @@ declare const uiMessageChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
2004
2004
|
messageMetadata?: unknown;
|
|
2005
2005
|
} | {
|
|
2006
2006
|
type: "finish";
|
|
2007
|
+
finishReason?: "unknown" | "length" | "error" | "stop" | "content-filter" | "tool-calls" | "other" | undefined;
|
|
2007
2008
|
messageMetadata?: unknown;
|
|
2008
2009
|
} | {
|
|
2009
2010
|
type: "abort";
|
|
@@ -2126,6 +2127,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
2126
2127
|
messageMetadata?: METADATA;
|
|
2127
2128
|
} | {
|
|
2128
2129
|
type: 'finish';
|
|
2130
|
+
finishReason?: FinishReason;
|
|
2129
2131
|
messageMetadata?: METADATA;
|
|
2130
2132
|
} | {
|
|
2131
2133
|
type: 'abort';
|
|
@@ -2154,6 +2156,10 @@ type UIMessageStreamOnFinishCallback<UI_MESSAGE extends UIMessage> = (event: {
|
|
|
2154
2156
|
* (including the original message if it was extended).
|
|
2155
2157
|
*/
|
|
2156
2158
|
responseMessage: UI_MESSAGE;
|
|
2159
|
+
/**
|
|
2160
|
+
* The reason why the generation finished.
|
|
2161
|
+
*/
|
|
2162
|
+
finishReason?: FinishReason;
|
|
2157
2163
|
}) => PromiseLike<void> | void;
|
|
2158
2164
|
|
|
2159
2165
|
type UIMessageStreamResponseInit = ResponseInit & {
|
|
@@ -2895,6 +2901,7 @@ type ChatOnDataCallback<UI_MESSAGE extends UIMessage> = (dataPart: DataUIPart<In
|
|
|
2895
2901
|
* @param isAbort Indicates whether the request has been aborted.
|
|
2896
2902
|
* @param isDisconnect Indicates whether the request has been ended by a network error.
|
|
2897
2903
|
* @param isError Indicates whether the request has been ended by an error.
|
|
2904
|
+
* @param finishReason The reason why the generation finished.
|
|
2898
2905
|
*/
|
|
2899
2906
|
type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
2900
2907
|
message: UI_MESSAGE;
|
|
@@ -2902,6 +2909,7 @@ type ChatOnFinishCallback<UI_MESSAGE extends UIMessage> = (options: {
|
|
|
2902
2909
|
isAbort: boolean;
|
|
2903
2910
|
isDisconnect: boolean;
|
|
2904
2911
|
isError: boolean;
|
|
2912
|
+
finishReason?: FinishReason;
|
|
2905
2913
|
}) => void;
|
|
2906
2914
|
interface ChatInit<UI_MESSAGE extends UIMessage> {
|
|
2907
2915
|
/**
|
package/dist/index.js
CHANGED
|
@@ -858,7 +858,7 @@ function detectMediaType({
|
|
|
858
858
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
859
859
|
|
|
860
860
|
// src/version.ts
|
|
861
|
-
var VERSION = true ? "6.0.0-beta.
|
|
861
|
+
var VERSION = true ? "6.0.0-beta.97" : "0.0.0-test";
|
|
862
862
|
|
|
863
863
|
// src/util/download/download.ts
|
|
864
864
|
var download = async ({ url }) => {
|
|
@@ -4135,6 +4135,15 @@ var uiMessageChunkSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
4135
4135
|
}),
|
|
4136
4136
|
import_v47.z.strictObject({
|
|
4137
4137
|
type: import_v47.z.literal("finish"),
|
|
4138
|
+
finishReason: import_v47.z.enum([
|
|
4139
|
+
"stop",
|
|
4140
|
+
"length",
|
|
4141
|
+
"content-filter",
|
|
4142
|
+
"tool-calls",
|
|
4143
|
+
"error",
|
|
4144
|
+
"other",
|
|
4145
|
+
"unknown"
|
|
4146
|
+
]).optional(),
|
|
4138
4147
|
messageMetadata: import_v47.z.unknown().optional()
|
|
4139
4148
|
}),
|
|
4140
4149
|
import_v47.z.strictObject({
|
|
@@ -4633,6 +4642,9 @@ function processUIMessageStream({
|
|
|
4633
4642
|
break;
|
|
4634
4643
|
}
|
|
4635
4644
|
case "finish": {
|
|
4645
|
+
if (chunk.finishReason != null) {
|
|
4646
|
+
state.finishReason = chunk.finishReason;
|
|
4647
|
+
}
|
|
4636
4648
|
await updateMessageMetadata(chunk.messageMetadata);
|
|
4637
4649
|
if (chunk.messageMetadata != null) {
|
|
4638
4650
|
write();
|
|
@@ -4740,7 +4752,8 @@ function handleUIMessageStreamFinish({
|
|
|
4740
4752
|
messages: [
|
|
4741
4753
|
...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
|
|
4742
4754
|
state.message
|
|
4743
|
-
]
|
|
4755
|
+
],
|
|
4756
|
+
finishReason: state.finishReason
|
|
4744
4757
|
});
|
|
4745
4758
|
};
|
|
4746
4759
|
return processUIMessageStream({
|
|
@@ -6542,6 +6555,7 @@ var DefaultStreamTextResult = class {
|
|
|
6542
6555
|
if (sendFinish) {
|
|
6543
6556
|
controller.enqueue({
|
|
6544
6557
|
type: "finish",
|
|
6558
|
+
finishReason: part.finishReason,
|
|
6545
6559
|
...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {}
|
|
6546
6560
|
});
|
|
6547
6561
|
}
|
|
@@ -11010,7 +11024,7 @@ var AbstractChat = class {
|
|
|
11010
11024
|
body,
|
|
11011
11025
|
messageId
|
|
11012
11026
|
}) {
|
|
11013
|
-
var _a15, _b, _c;
|
|
11027
|
+
var _a15, _b, _c, _d;
|
|
11014
11028
|
this.setStatus({ status: "submitted", error: void 0 });
|
|
11015
11029
|
const lastMessage = this.lastMessage;
|
|
11016
11030
|
let isAbort = false;
|
|
@@ -11107,22 +11121,23 @@ var AbstractChat = class {
|
|
|
11107
11121
|
this.setStatus({ status: "error", error: err });
|
|
11108
11122
|
} finally {
|
|
11109
11123
|
try {
|
|
11110
|
-
(
|
|
11124
|
+
(_b = this.onFinish) == null ? void 0 : _b.call(this, {
|
|
11111
11125
|
message: this.activeResponse.state.message,
|
|
11112
11126
|
messages: this.state.messages,
|
|
11113
11127
|
isAbort,
|
|
11114
11128
|
isDisconnect,
|
|
11115
|
-
isError
|
|
11129
|
+
isError,
|
|
11130
|
+
finishReason: (_a15 = this.activeResponse) == null ? void 0 : _a15.state.finishReason
|
|
11116
11131
|
});
|
|
11117
11132
|
} catch (err) {
|
|
11118
11133
|
console.error(err);
|
|
11119
11134
|
}
|
|
11120
11135
|
this.activeResponse = void 0;
|
|
11121
11136
|
}
|
|
11122
|
-
if (((
|
|
11137
|
+
if (((_c = this.sendAutomaticallyWhen) == null ? void 0 : _c.call(this, { messages: this.state.messages })) && !isError) {
|
|
11123
11138
|
await this.makeRequest({
|
|
11124
11139
|
trigger: "submit-message",
|
|
11125
|
-
messageId: (
|
|
11140
|
+
messageId: (_d = this.lastMessage) == null ? void 0 : _d.id,
|
|
11126
11141
|
metadata,
|
|
11127
11142
|
headers,
|
|
11128
11143
|
body
|