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/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 5.0.0-beta.5
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 4f3e637: fix (ui): avoid caching globalThis.fetch in case it is patched by other libraries
|
8
|
+
|
9
|
+
## 5.0.0-beta.4
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 09f41ac: fix (ui): add message metadata in Chat.sendMessage
|
14
|
+
|
3
15
|
## 5.0.0-beta.3
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -1446,7 +1446,7 @@ declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> implement
|
|
1446
1446
|
protected credentials?: RequestCredentials;
|
1447
1447
|
protected headers?: Record<string, string> | Headers;
|
1448
1448
|
protected body?: object;
|
1449
|
-
protected fetch
|
1449
|
+
protected fetch?: FetchFunction;
|
1450
1450
|
protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
1451
1451
|
protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
1452
1452
|
constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
|
package/dist/index.d.ts
CHANGED
@@ -1446,7 +1446,7 @@ declare abstract class HttpChatTransport<UI_MESSAGE extends UIMessage> implement
|
|
1446
1446
|
protected credentials?: RequestCredentials;
|
1447
1447
|
protected headers?: Record<string, string> | Headers;
|
1448
1448
|
protected body?: object;
|
1449
|
-
protected fetch
|
1449
|
+
protected fetch?: FetchFunction;
|
1450
1450
|
protected prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
|
1451
1451
|
protected prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
|
1452
1452
|
constructor({ api, credentials, headers, body, fetch, prepareSendMessagesRequest, prepareReconnectToStreamRequest, }: HttpChatTransportInitOptions<UI_MESSAGE>);
|
package/dist/index.js
CHANGED
@@ -850,14 +850,13 @@ async function convertFileListToFileUIParts(files) {
|
|
850
850
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
851
851
|
|
852
852
|
// src/ui/http-chat-transport.ts
|
853
|
-
var getOriginalFetch2 = () => fetch;
|
854
853
|
var HttpChatTransport = class {
|
855
854
|
constructor({
|
856
855
|
api = "/api/chat",
|
857
856
|
credentials,
|
858
857
|
headers,
|
859
858
|
body,
|
860
|
-
fetch: fetch2
|
859
|
+
fetch: fetch2,
|
861
860
|
prepareSendMessagesRequest,
|
862
861
|
prepareReconnectToStreamRequest
|
863
862
|
}) {
|
@@ -873,7 +872,7 @@ var HttpChatTransport = class {
|
|
873
872
|
abortSignal,
|
874
873
|
...options
|
875
874
|
}) {
|
876
|
-
var _a16, _b, _c, _d;
|
875
|
+
var _a16, _b, _c, _d, _e;
|
877
876
|
const preparedRequest = await ((_a16 = this.prepareSendMessagesRequest) == null ? void 0 : _a16.call(this, {
|
878
877
|
api: this.api,
|
879
878
|
id: options.chatId,
|
@@ -896,7 +895,8 @@ var HttpChatTransport = class {
|
|
896
895
|
messageId: options.messageId
|
897
896
|
};
|
898
897
|
const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
|
899
|
-
const
|
898
|
+
const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
|
899
|
+
const response = await fetch2(api, {
|
900
900
|
method: "POST",
|
901
901
|
headers: {
|
902
902
|
"Content-Type": "application/json",
|
@@ -908,7 +908,7 @@ var HttpChatTransport = class {
|
|
908
908
|
});
|
909
909
|
if (!response.ok) {
|
910
910
|
throw new Error(
|
911
|
-
(
|
911
|
+
(_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
|
912
912
|
);
|
913
913
|
}
|
914
914
|
if (!response.body) {
|
@@ -917,7 +917,7 @@ var HttpChatTransport = class {
|
|
917
917
|
return this.processResponseStream(response.body);
|
918
918
|
}
|
919
919
|
async reconnectToStream(options) {
|
920
|
-
var _a16, _b, _c, _d;
|
920
|
+
var _a16, _b, _c, _d, _e;
|
921
921
|
const preparedRequest = await ((_a16 = this.prepareReconnectToStreamRequest) == null ? void 0 : _a16.call(this, {
|
922
922
|
api: this.api,
|
923
923
|
id: options.chatId,
|
@@ -929,7 +929,8 @@ var HttpChatTransport = class {
|
|
929
929
|
const api = (_b = preparedRequest == null ? void 0 : preparedRequest.api) != null ? _b : `${this.api}/${options.chatId}/stream`;
|
930
930
|
const headers = (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...options.headers };
|
931
931
|
const credentials = (_c = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _c : this.credentials;
|
932
|
-
const
|
932
|
+
const fetch2 = (_d = this.fetch) != null ? _d : globalThis.fetch;
|
933
|
+
const response = await fetch2(api, {
|
933
934
|
method: "GET",
|
934
935
|
headers,
|
935
936
|
credentials
|
@@ -939,7 +940,7 @@ var HttpChatTransport = class {
|
|
939
940
|
}
|
940
941
|
if (!response.ok) {
|
941
942
|
throw new Error(
|
942
|
-
(
|
943
|
+
(_e = await response.text()) != null ? _e : "Failed to fetch the chat response."
|
943
944
|
);
|
944
945
|
}
|
945
946
|
if (!response.body) {
|
@@ -1761,13 +1762,15 @@ var AbstractChat = class {
|
|
1761
1762
|
this.state.replaceMessage(messageIndex, {
|
1762
1763
|
...uiMessage,
|
1763
1764
|
id: message.messageId,
|
1764
|
-
role: (_a16 = uiMessage.role) != null ? _a16 : "user"
|
1765
|
+
role: (_a16 = uiMessage.role) != null ? _a16 : "user",
|
1766
|
+
metadata: message.metadata
|
1765
1767
|
});
|
1766
1768
|
} else {
|
1767
1769
|
this.state.pushMessage({
|
1768
1770
|
...uiMessage,
|
1769
1771
|
id: (_b = uiMessage.id) != null ? _b : this.generateId(),
|
1770
|
-
role: (_c = uiMessage.role) != null ? _c : "user"
|
1772
|
+
role: (_c = uiMessage.role) != null ? _c : "user",
|
1773
|
+
metadata: message.metadata
|
1771
1774
|
});
|
1772
1775
|
}
|
1773
1776
|
await this.makeRequest({
|