@blueking/chat-helper 0.0.1-beta.22 → 0.0.1-beta.23
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/dist/event/ag-ui.d.ts
CHANGED
|
@@ -147,7 +147,7 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
147
147
|
handleToolCallStartEvent(event: IToolCallStartEvent): void;
|
|
148
148
|
injectMessageModule(message: IMessageModule): void;
|
|
149
149
|
onDone(): void;
|
|
150
|
-
onError(error:
|
|
150
|
+
onError(error: Error): void;
|
|
151
151
|
onMessage(message: unknown): void;
|
|
152
152
|
onStart(): void;
|
|
153
153
|
}
|
package/dist/event/ag-ui.ts.js
CHANGED
|
@@ -334,12 +334,12 @@ import { CustomEventName, EventType } from './type.ts.js';
|
|
|
334
334
|
(_this_onDoneCallback = (_this = this).onDoneCallback) === null || _this_onDoneCallback === void 0 ? void 0 : _this_onDoneCallback.call(_this);
|
|
335
335
|
}
|
|
336
336
|
onError(error) {
|
|
337
|
-
var
|
|
337
|
+
var // 回调给上层
|
|
338
338
|
_this_onErrorCallback, _this;
|
|
339
339
|
// 创建一个错误消息
|
|
340
340
|
this.messageModule.plusMessage({
|
|
341
341
|
role: MessageRole.Assistant,
|
|
342
|
-
content:
|
|
342
|
+
content: error.message,
|
|
343
343
|
status: MessageStatus.Error
|
|
344
344
|
});
|
|
345
345
|
(_this_onErrorCallback = (_this = this).onErrorCallback) === null || _this_onErrorCallback === void 0 ? void 0 : _this_onErrorCallback.call(_this, error);
|
|
@@ -36,7 +36,7 @@ export interface ISSEConfig extends ISSEProtocol, Omit<IRequestConfig, 'response
|
|
|
36
36
|
}
|
|
37
37
|
export interface ISSEProtocol {
|
|
38
38
|
onDone?: () => void;
|
|
39
|
-
onError?: (error:
|
|
39
|
+
onError?: (error: Error) => void;
|
|
40
40
|
onMessage?: (event: unknown) => void;
|
|
41
41
|
onStart?: () => void;
|
|
42
42
|
}
|
|
@@ -309,8 +309,8 @@ export class FetchClient {
|
|
|
309
309
|
// 验证状态码
|
|
310
310
|
const validateStatus = requestConfig.validateStatus || _this.defaults.validateStatus;
|
|
311
311
|
if (!validateStatus(fetchResponse.status)) {
|
|
312
|
-
var _response_data;
|
|
313
|
-
const message = ((_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.message) || `Request failed with status code ${fetchResponse.status}`;
|
|
312
|
+
var _response_data_error, _response_data;
|
|
313
|
+
const message = ((_response_data = response.data) === null || _response_data === void 0 ? void 0 : (_response_data_error = _response_data.error) === null || _response_data_error === void 0 ? void 0 : _response_data_error.message) || `Request failed with status code ${fetchResponse.status}`;
|
|
314
314
|
throw createError(message, requestConfig, `ERR_BAD_RESPONSE`, response);
|
|
315
315
|
}
|
|
316
316
|
// 应用响应拦截器
|
|
@@ -379,9 +379,10 @@ export class FetchClient {
|
|
|
379
379
|
var _config_onError;
|
|
380
380
|
let message = `Request failed with status code ${fetchResponse.status}`;
|
|
381
381
|
try {
|
|
382
|
+
var _errorData_error;
|
|
382
383
|
const errorData = yield fetchResponse.json();
|
|
383
|
-
if (errorData === null || errorData === void 0 ? void 0 : errorData.message) {
|
|
384
|
-
message = errorData.message;
|
|
384
|
+
if (errorData === null || errorData === void 0 ? void 0 : (_errorData_error = errorData.error) === null || _errorData_error === void 0 ? void 0 : _errorData_error.message) {
|
|
385
|
+
message = errorData.error.message;
|
|
385
386
|
}
|
|
386
387
|
} catch (_error) {
|
|
387
388
|
message = `Request failed with status code ${fetchResponse.status}`;
|