@agentscope-ai/chat 1.1.46-beta.1768294051845 → 1.1.46-beta.1768786501052
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/components/AgentScopeRuntimeWebUI/core/Chat/hooks/useChatRequest.tsx +2 -1
- package/components/AgentScopeRuntimeWebUI/core/types/IChatAnywhere.ts +14 -2
- package/lib/AgentScopeRuntimeWebUI/core/Chat/hooks/useChatRequest.js +29 -28
- package/lib/AgentScopeRuntimeWebUI/core/types/IChatAnywhere.d.ts +2 -1
- package/package.json +1 -1
|
@@ -134,7 +134,8 @@ export default function useChatRequest(options: UseChatRequestOptions) {
|
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
const
|
|
137
|
+
const responseParser = apiOptionsRef.current.responseParser || JSON.parse;
|
|
138
|
+
const chunkData = responseParser(chunk.data);
|
|
138
139
|
const res = agentScopeRuntimeResponseBuilder.handle(chunkData);
|
|
139
140
|
|
|
140
141
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { UploadProps } from 'antd';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
IAgentScopeRuntimeMessage,
|
|
4
|
+
IAgentScopeRuntimeResponse,
|
|
5
|
+
IContent,
|
|
6
|
+
} from '../AgentScopeRuntime/types';
|
|
3
7
|
import { IAgentScopeRuntimeWebUISession } from './ISessions';
|
|
4
8
|
|
|
5
9
|
/**
|
|
@@ -23,8 +27,16 @@ export interface IAgentScopeRuntimeWebUIAPIOptions {
|
|
|
23
27
|
* @param data
|
|
24
28
|
* @returns
|
|
25
29
|
*/
|
|
26
|
-
fetch?: (data: {
|
|
30
|
+
fetch?: (data: {
|
|
31
|
+
input: any[];
|
|
32
|
+
biz_params?: IAgentScopeRuntimeWebUIInputData['biz_params'];
|
|
33
|
+
}) => Promise<Response>;
|
|
34
|
+
|
|
27
35
|
enableHistoryMessages?: boolean;
|
|
36
|
+
|
|
37
|
+
responseParser?: (
|
|
38
|
+
response: Response,
|
|
39
|
+
) => IAgentScopeRuntimeResponse | IAgentScopeRuntimeMessage | IContent;
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
/**
|
|
@@ -102,7 +102,7 @@ export default function useChatRequest(options) {
|
|
|
102
102
|
}(), []);
|
|
103
103
|
var request = useCallback( /*#__PURE__*/function () {
|
|
104
104
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(historyMessages, biz_params) {
|
|
105
|
-
var currentApiOptions, _currentApiOptions$en, enableHistoryMessages, response, agentScopeRuntimeResponseBuilder, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, chunk, _currentQARef$current, _res$output, _currentQARef$current2, chunkData, res;
|
|
105
|
+
var currentApiOptions, _currentApiOptions$en, enableHistoryMessages, response, agentScopeRuntimeResponseBuilder, _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, chunk, _currentQARef$current, _res$output, _currentQARef$current2, responseParser, chunkData, res;
|
|
106
106
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
107
107
|
while (1) switch (_context2.prev = _context2.next) {
|
|
108
108
|
case 0:
|
|
@@ -149,7 +149,7 @@ export default function useChatRequest(options) {
|
|
|
149
149
|
_context2.t1 = _context2["catch"](2);
|
|
150
150
|
case 17:
|
|
151
151
|
if (!(response && response.body)) {
|
|
152
|
-
_context2.next =
|
|
152
|
+
_context2.next = 66;
|
|
153
153
|
break;
|
|
154
154
|
}
|
|
155
155
|
agentScopeRuntimeResponseBuilder = new AgentScopeRuntimeResponseBuilder({
|
|
@@ -192,7 +192,7 @@ export default function useChatRequest(options) {
|
|
|
192
192
|
return _iterator2.next();
|
|
193
193
|
case 29:
|
|
194
194
|
if (!(_iteratorAbruptCompletion2 = !(_step2 = _context2.sent).done)) {
|
|
195
|
-
_context2.next =
|
|
195
|
+
_context2.next = 45;
|
|
196
196
|
break;
|
|
197
197
|
}
|
|
198
198
|
chunk = _step2.value;
|
|
@@ -206,16 +206,17 @@ export default function useChatRequest(options) {
|
|
|
206
206
|
data: agentScopeRuntimeResponseBuilder.cancel()
|
|
207
207
|
}];
|
|
208
208
|
updateMessage(currentQARef.current.response);
|
|
209
|
-
return _context2.abrupt("break",
|
|
209
|
+
return _context2.abrupt("break", 45);
|
|
210
210
|
case 36:
|
|
211
|
-
|
|
211
|
+
responseParser = apiOptionsRef.current.responseParser || JSON.parse;
|
|
212
|
+
chunkData = responseParser(chunk.data);
|
|
212
213
|
res = agentScopeRuntimeResponseBuilder.handle(chunkData); // 跳过空内容
|
|
213
214
|
if (!(res.status !== AgentScopeRuntimeRunStatus.Failed && !((_res$output = res.output) !== null && _res$output !== void 0 && (_res$output = _res$output[0]) !== null && _res$output !== void 0 && (_res$output = _res$output.content) !== null && _res$output !== void 0 && _res$output.length))) {
|
|
214
|
-
_context2.next =
|
|
215
|
+
_context2.next = 41;
|
|
215
216
|
break;
|
|
216
217
|
}
|
|
217
|
-
return _context2.abrupt("continue",
|
|
218
|
-
case
|
|
218
|
+
return _context2.abrupt("continue", 42);
|
|
219
|
+
case 41:
|
|
219
220
|
if (currentQARef.current.response) {
|
|
220
221
|
currentQARef.current.response.cards = [{
|
|
221
222
|
code: 'AgentScopeRuntimeResponseCard',
|
|
@@ -227,50 +228,50 @@ export default function useChatRequest(options) {
|
|
|
227
228
|
updateMessage(currentQARef.current.response);
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
|
-
case
|
|
231
|
+
case 42:
|
|
231
232
|
_iteratorAbruptCompletion2 = false;
|
|
232
233
|
_context2.next = 27;
|
|
233
234
|
break;
|
|
234
|
-
case
|
|
235
|
-
_context2.next =
|
|
235
|
+
case 45:
|
|
236
|
+
_context2.next = 51;
|
|
236
237
|
break;
|
|
237
|
-
case
|
|
238
|
-
_context2.prev =
|
|
238
|
+
case 47:
|
|
239
|
+
_context2.prev = 47;
|
|
239
240
|
_context2.t2 = _context2["catch"](25);
|
|
240
241
|
_didIteratorError2 = true;
|
|
241
242
|
_iteratorError2 = _context2.t2;
|
|
242
|
-
case
|
|
243
|
-
_context2.prev = 50;
|
|
243
|
+
case 51:
|
|
244
244
|
_context2.prev = 51;
|
|
245
|
+
_context2.prev = 52;
|
|
245
246
|
if (!(_iteratorAbruptCompletion2 && _iterator2.return != null)) {
|
|
246
|
-
_context2.next =
|
|
247
|
+
_context2.next = 56;
|
|
247
248
|
break;
|
|
248
249
|
}
|
|
249
|
-
_context2.next =
|
|
250
|
+
_context2.next = 56;
|
|
250
251
|
return _iterator2.return();
|
|
251
|
-
case
|
|
252
|
-
_context2.prev =
|
|
252
|
+
case 56:
|
|
253
|
+
_context2.prev = 56;
|
|
253
254
|
if (!_didIteratorError2) {
|
|
254
|
-
_context2.next =
|
|
255
|
+
_context2.next = 59;
|
|
255
256
|
break;
|
|
256
257
|
}
|
|
257
258
|
throw _iteratorError2;
|
|
258
|
-
case 58:
|
|
259
|
-
return _context2.finish(55);
|
|
260
259
|
case 59:
|
|
261
|
-
return _context2.finish(
|
|
260
|
+
return _context2.finish(56);
|
|
262
261
|
case 60:
|
|
263
|
-
_context2.
|
|
262
|
+
return _context2.finish(51);
|
|
263
|
+
case 61:
|
|
264
|
+
_context2.next = 66;
|
|
264
265
|
break;
|
|
265
|
-
case
|
|
266
|
-
_context2.prev =
|
|
266
|
+
case 63:
|
|
267
|
+
_context2.prev = 63;
|
|
267
268
|
_context2.t3 = _context2["catch"](22);
|
|
268
269
|
console.error(_context2.t3);
|
|
269
|
-
case
|
|
270
|
+
case 66:
|
|
270
271
|
case "end":
|
|
271
272
|
return _context2.stop();
|
|
272
273
|
}
|
|
273
|
-
}, _callee2, null, [[2, 15], [22,
|
|
274
|
+
}, _callee2, null, [[2, 15], [22, 63], [25, 47, 51, 61], [52,, 56, 60]]);
|
|
274
275
|
}));
|
|
275
276
|
return function (_x2, _x3) {
|
|
276
277
|
return _ref2.apply(this, arguments);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { UploadProps } from 'antd';
|
|
3
|
-
import { IAgentScopeRuntimeResponse } from '../AgentScopeRuntime/types';
|
|
3
|
+
import { IAgentScopeRuntimeMessage, IAgentScopeRuntimeResponse, IContent } from '../AgentScopeRuntime/types';
|
|
4
4
|
import { IAgentScopeRuntimeWebUISession } from './ISessions';
|
|
5
5
|
/**
|
|
6
6
|
* @description API 配置选项
|
|
@@ -28,6 +28,7 @@ export interface IAgentScopeRuntimeWebUIAPIOptions {
|
|
|
28
28
|
biz_params?: IAgentScopeRuntimeWebUIInputData['biz_params'];
|
|
29
29
|
}) => Promise<Response>;
|
|
30
30
|
enableHistoryMessages?: boolean;
|
|
31
|
+
responseParser?: (response: Response) => IAgentScopeRuntimeResponse | IAgentScopeRuntimeMessage | IContent;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* @description 主题配置选项
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentscope-ai/chat",
|
|
3
|
-
"version": "1.1.46-beta.
|
|
3
|
+
"version": "1.1.46-beta.1768786501052",
|
|
4
4
|
"description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": [
|