ai 7.0.27 → 7.0.28
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.js +26 -20
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/package.json +1 -1
- package/src/ui/chat.ts +24 -17
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1089,7 +1089,7 @@ import {
|
|
|
1089
1089
|
} from "@ai-sdk/provider-utils";
|
|
1090
1090
|
|
|
1091
1091
|
// src/version.ts
|
|
1092
|
-
var VERSION = true ? "7.0.
|
|
1092
|
+
var VERSION = true ? "7.0.28" : "0.0.0-test";
|
|
1093
1093
|
|
|
1094
1094
|
// src/util/download/download.ts
|
|
1095
1095
|
var download = async ({
|
|
@@ -16732,7 +16732,7 @@ var AbstractChat = class {
|
|
|
16732
16732
|
body,
|
|
16733
16733
|
messageId
|
|
16734
16734
|
}) {
|
|
16735
|
-
var _a22, _b
|
|
16735
|
+
var _a22, _b;
|
|
16736
16736
|
let resumeStream;
|
|
16737
16737
|
if (trigger === "resume-stream") {
|
|
16738
16738
|
try {
|
|
@@ -16759,18 +16759,20 @@ var AbstractChat = class {
|
|
|
16759
16759
|
let isAbort = false;
|
|
16760
16760
|
let isDisconnect = false;
|
|
16761
16761
|
let isError = false;
|
|
16762
|
+
let activeResponse;
|
|
16762
16763
|
try {
|
|
16763
|
-
const
|
|
16764
|
+
const response = {
|
|
16764
16765
|
state: createStreamingUIMessageState({
|
|
16765
16766
|
lastMessage: this.state.snapshot(lastMessage),
|
|
16766
16767
|
messageId: this.generateId()
|
|
16767
16768
|
}),
|
|
16768
16769
|
abortController: new AbortController()
|
|
16769
16770
|
};
|
|
16770
|
-
activeResponse
|
|
16771
|
+
activeResponse = response;
|
|
16772
|
+
response.abortController.signal.addEventListener("abort", () => {
|
|
16771
16773
|
isAbort = true;
|
|
16772
16774
|
});
|
|
16773
|
-
this.activeResponse =
|
|
16775
|
+
this.activeResponse = response;
|
|
16774
16776
|
let stream;
|
|
16775
16777
|
if (trigger === "resume-stream") {
|
|
16776
16778
|
stream = resumeStream;
|
|
@@ -16778,7 +16780,7 @@ var AbstractChat = class {
|
|
|
16778
16780
|
stream = await this.transport.sendMessages({
|
|
16779
16781
|
chatId: this.id,
|
|
16780
16782
|
messages: this.state.messages,
|
|
16781
|
-
abortSignal:
|
|
16783
|
+
abortSignal: response.abortController.signal,
|
|
16782
16784
|
metadata,
|
|
16783
16785
|
headers,
|
|
16784
16786
|
body,
|
|
@@ -16790,18 +16792,18 @@ var AbstractChat = class {
|
|
|
16790
16792
|
// serialize the job execution to avoid race conditions:
|
|
16791
16793
|
this.jobExecutor.run(
|
|
16792
16794
|
() => job({
|
|
16793
|
-
state:
|
|
16795
|
+
state: response.state,
|
|
16794
16796
|
write: () => {
|
|
16795
16797
|
var _a23;
|
|
16796
16798
|
this.setStatus({ status: "streaming" });
|
|
16797
|
-
const replaceLastMessage =
|
|
16799
|
+
const replaceLastMessage = response.state.message.id === ((_a23 = this.lastMessage) == null ? void 0 : _a23.id);
|
|
16798
16800
|
if (replaceLastMessage) {
|
|
16799
16801
|
this.state.replaceMessage(
|
|
16800
16802
|
this.state.messages.length - 1,
|
|
16801
|
-
|
|
16803
|
+
response.state.message
|
|
16802
16804
|
);
|
|
16803
16805
|
} else {
|
|
16804
|
-
this.state.pushMessage(
|
|
16806
|
+
this.state.pushMessage(response.state.message);
|
|
16805
16807
|
}
|
|
16806
16808
|
}
|
|
16807
16809
|
})
|
|
@@ -16840,23 +16842,27 @@ var AbstractChat = class {
|
|
|
16840
16842
|
this.setStatus({ status: "error", error: err });
|
|
16841
16843
|
} finally {
|
|
16842
16844
|
try {
|
|
16843
|
-
(
|
|
16844
|
-
|
|
16845
|
-
|
|
16846
|
-
|
|
16847
|
-
|
|
16848
|
-
|
|
16849
|
-
|
|
16850
|
-
|
|
16845
|
+
if (activeResponse) {
|
|
16846
|
+
(_a22 = this.onFinish) == null ? void 0 : _a22.call(this, {
|
|
16847
|
+
message: activeResponse.state.message,
|
|
16848
|
+
messages: this.state.messages,
|
|
16849
|
+
isAbort,
|
|
16850
|
+
isDisconnect,
|
|
16851
|
+
isError,
|
|
16852
|
+
finishReason: activeResponse.state.finishReason
|
|
16853
|
+
});
|
|
16854
|
+
}
|
|
16851
16855
|
} catch (err) {
|
|
16852
16856
|
console.error(err);
|
|
16853
16857
|
}
|
|
16854
|
-
this.activeResponse
|
|
16858
|
+
if (this.activeResponse === activeResponse) {
|
|
16859
|
+
this.activeResponse = void 0;
|
|
16860
|
+
}
|
|
16855
16861
|
}
|
|
16856
16862
|
if (!isError && await this.shouldSendAutomatically()) {
|
|
16857
16863
|
await this.makeRequest({
|
|
16858
16864
|
trigger: "submit-message",
|
|
16859
|
-
messageId: (
|
|
16865
|
+
messageId: (_b = this.lastMessage) == null ? void 0 : _b.id,
|
|
16860
16866
|
metadata,
|
|
16861
16867
|
headers,
|
|
16862
16868
|
body
|