@fe-free/ai 6.0.23 → 6.0.24
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 +9 -0
- package/package.json +4 -4
- package/src/stream/index.ts +7 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/ai",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"lodash-es": "^4.17.21",
|
|
18
18
|
"uuid": "^13.0.0",
|
|
19
19
|
"zustand": "^4.5.7",
|
|
20
|
-
"@fe-free/core": "6.0.
|
|
20
|
+
"@fe-free/core": "6.0.24"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"antd": "^6.2.1",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"i18next-icu": "^2.4.1",
|
|
28
28
|
"react": "^19.2.0",
|
|
29
29
|
"react-i18next": "^16.4.0",
|
|
30
|
-
"@fe-free/icons": "6.0.
|
|
31
|
-
"@fe-free/tool": "6.0.
|
|
30
|
+
"@fe-free/icons": "6.0.24",
|
|
31
|
+
"@fe-free/tool": "6.0.24"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "echo \"Error: no test specified\" && exit 1",
|
package/src/stream/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { XRequest } from '@ant-design/x-sdk';
|
|
2
2
|
|
|
3
|
+
type StreamMessage = { event: string; data: string };
|
|
4
|
+
|
|
3
5
|
async function fetchStream(
|
|
4
6
|
url: string,
|
|
5
7
|
{
|
|
@@ -11,12 +13,13 @@ async function fetchStream(
|
|
|
11
13
|
params?: Record<string, any>;
|
|
12
14
|
headers?: Record<string, string>;
|
|
13
15
|
callbacks?: {
|
|
14
|
-
onUpdate?: ({ event, data }:
|
|
16
|
+
onUpdate?: ({ event, data }: StreamMessage, headers: Headers) => void;
|
|
17
|
+
onSuccess?: (chunks: StreamMessage[], headers: Headers) => void;
|
|
15
18
|
onError?: (error: Error, errorInfo?: any) => void;
|
|
16
19
|
};
|
|
17
20
|
},
|
|
18
21
|
) {
|
|
19
|
-
await XRequest<any,
|
|
22
|
+
await XRequest<any, StreamMessage>(url, {
|
|
20
23
|
...rest,
|
|
21
24
|
params: params,
|
|
22
25
|
headers: headers,
|
|
@@ -27,8 +30,8 @@ async function fetchStream(
|
|
|
27
30
|
callbacks?.onUpdate?.(message, headers);
|
|
28
31
|
}
|
|
29
32
|
},
|
|
30
|
-
onSuccess: () => {
|
|
31
|
-
|
|
33
|
+
onSuccess: (chunks, headers) => {
|
|
34
|
+
callbacks?.onSuccess?.(chunks, headers);
|
|
32
35
|
},
|
|
33
36
|
onError: (error, errorInfo) => {
|
|
34
37
|
console.log('XRequest onError', error);
|