ai 5.0.0-beta.3 → 5.0.0-beta.5
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 +12 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -766,14 +766,13 @@ async function convertFileListToFileUIParts(files) {
|
|
766
766
|
import { parseJsonEventStream as parseJsonEventStream2 } from "@ai-sdk/provider-utils";
|
767
767
|
|
768
768
|
// src/ui/http-chat-transport.ts
|
769
|
-
var getOriginalFetch2 = () => fetch;
|
770
769
|
var HttpChatTransport = class {
|
771
770
|
constructor({
|
772
771
|
api = "/api/chat",
|
773
772
|
credentials,
|
774
773
|
headers,
|
775
774
|
body,
|
776
|
-
fetch: fetch2
|
775
|
+
fetch: fetch2,
|
777
776
|
prepareSendMessagesRequest,
|
778
777
|
prepareReconnectToStreamRequest
|
779
778
|
}) {
|
@@ -789,7 +788,7 @@ var HttpChatTransport = class {
|
|
789
788
|
abortSignal,
|
790
789
|
...options
|
791
790
|
}) {
|
792
|
-
var _a16, _b, _c, _d;
|
791
|
+
var _a16, _b, _c, _d, _e;
|
793
792
|
const preparedRequest = await ((_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {
|
794
793
|
api: this.api,
|
795
794
|
id: options.chatId,
|
@@ -812,7 +811,8 @@ var HttpChatTransport = class {
|
|
812
811
|
messageId: options.messageId
|
813
812
|
};
|
814
813
|
const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
|
815
|
-
const
|
814
|
+
const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
|
815
|
+
const response = await fetch2(api, {
|
816
816
|
method: "POST",
|
817
817
|
headers: {
|
818
818
|
"Content-Type": "application/json",
|
@@ -824,7 +824,7 @@ var HttpChatTransport = class {
|
|
824
824
|
});
|
825
825
|
if (!response.ok) {
|
826
826
|
throw new Error(
|
827
|
-
(
|
827
|
+
(_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
|
828
828
|
);
|
829
829
|
}
|
830
830
|
if (!response.body) {
|
@@ -833,7 +833,7 @@ var HttpChatTransport = class {
|
|
833
833
|
return this.processResponseStream(response.body);
|
834
834
|
}
|
835
835
|
async reconnectToStream(options) {
|
836
|
-
var _a16, _b, _c, _d;
|
836
|
+
var _a16, _b, _c, _d, _e;
|
837
837
|
const preparedRequest = await ((_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {
|
838
838
|
api: this.api,
|
839
839
|
id: options.chatId,
|
@@ -845,7 +845,8 @@ var HttpChatTransport = class {
|
|
845
845
|
const api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : `${this.api}/${options.chatId}/stream`;
|
846
846
|
const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...options.headers };
|
847
847
|
const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
|
848
|
-
const
|
848
|
+
const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
|
849
|
+
const response = await fetch2(api, {
|
849
850
|
method: "GET",
|
850
851
|
headers,
|
851
852
|
credentials
|
@@ -855,7 +856,7 @@ var HttpChatTransport = class {
|
|
855
856
|
}
|
856
857
|
if (!response.ok) {
|
857
858
|
throw new Error(
|
858
|
-
(
|
859
|
+
(_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
|
859
860
|
);
|
860
861
|
}
|
861
862
|
if (!response.body) {
|
@@ -1679,13 +1680,15 @@ var AbstractChat = class {
|
|
1679
1680
|
this.state.replaceMessage(messageIndex, {
|
1680
1681
|
...uiMessage,
|
1681
1682
|
id: message.messageId,
|
1682
|
-
role: (_a16 = uiMessage.role) != null ? _a16 : "user"
|
1683
|
+
role: (_a16 = uiMessage.role) != null ? _a16 : "user",
|
1684
|
+
metadata: message.metadata
|
1683
1685
|
});
|
1684
1686
|
} else {
|
1685
1687
|
this.state.pushMessage({
|
1686
1688
|
...uiMessage,
|
1687
1689
|
id: (_b = uiMessage.id) != null ? _b : this.generateId(),
|
1688
|
-
role: (_c = uiMessage.role) != null ? _c : "user"
|
1690
|
+
role: (_c = uiMessage.role) != null ? _c : "user",
|
1691
|
+
metadata: message.metadata
|
1689
1692
|
});
|
1690
1693
|
}
|
1691
1694
|
await this.makeRequest({
|