@blueking/chat-helper 0.0.1-beta.22 → 0.0.1-beta.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.
|
@@ -589,7 +589,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
589
589
|
isInfoLoading: import("vue").Ref<boolean, boolean>;
|
|
590
590
|
isChatting: import("vue").Ref<boolean, boolean>;
|
|
591
591
|
chat: (userInput: IUserMessage["content"], sessionCode: string, url?: string, config?: IRequestConfig, property?: IMessageProperty) => Promise<void>;
|
|
592
|
-
handleRole: (data: IAgentInfo) => void;
|
|
592
|
+
handleRole: (data: IAgentInfo, sessionCode: string) => void;
|
|
593
593
|
resendMessage: (messageId: string, sessionCode: string, newContent?: IUserMessage["content"], url?: string, config?: IRequestConfig) => Promise<void>;
|
|
594
594
|
resumeStreamingChat: (sessionCode: string, url?: string, config?: IRequestConfig) => void;
|
|
595
595
|
abortChat: () => void;
|
|
@@ -102,7 +102,7 @@ import { MessageRole, MessageStatus } from '../message/index.ts.js';
|
|
|
102
102
|
});
|
|
103
103
|
};
|
|
104
104
|
// 处理角色消息
|
|
105
|
-
const handleRole = (data)=>{
|
|
105
|
+
const handleRole = (data, sessionCode)=>{
|
|
106
106
|
var _data_promptSetting_content, _data_promptSetting;
|
|
107
107
|
const lastRoleMessage = (_data_promptSetting = data.promptSetting) === null || _data_promptSetting === void 0 ? void 0 : (_data_promptSetting_content = _data_promptSetting.content) === null || _data_promptSetting_content === void 0 ? void 0 : _data_promptSetting_content.at(-1);
|
|
108
108
|
if ((lastRoleMessage === null || lastRoleMessage === void 0 ? void 0 : lastRoleMessage.role) === MessageRole.Pause) {
|
|
@@ -110,7 +110,8 @@ import { MessageRole, MessageStatus } from '../message/index.ts.js';
|
|
|
110
110
|
(_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.createAndPlusMessage({
|
|
111
111
|
role: MessageRole.Assistant,
|
|
112
112
|
content: lastRoleMessage.content,
|
|
113
|
-
status: MessageStatus.Complete
|
|
113
|
+
status: MessageStatus.Complete,
|
|
114
|
+
sessionCode
|
|
114
115
|
});
|
|
115
116
|
}
|
|
116
117
|
};
|
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}`;
|
package/dist/index.d.ts
CHANGED
|
@@ -591,7 +591,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
591
591
|
isInfoLoading: import("vue").Ref<boolean, boolean>;
|
|
592
592
|
isChatting: import("vue").Ref<boolean, boolean>;
|
|
593
593
|
chat: (userInput: import("./message").IUserMessage["content"], sessionCode: string, url?: string, config?: import("./http").IRequestConfig, property?: import("./message").IMessageProperty) => Promise<void>;
|
|
594
|
-
handleRole: (data: import("./agent").IAgentInfo) => void;
|
|
594
|
+
handleRole: (data: import("./agent").IAgentInfo, sessionCode: string) => void;
|
|
595
595
|
resendMessage: (messageId: string, sessionCode: string, newContent?: import("./message").IUserMessage["content"], url?: string, config?: import("./http").IRequestConfig) => Promise<void>;
|
|
596
596
|
resumeStreamingChat: (sessionCode: string, url?: string, config?: import("./http").IRequestConfig) => void;
|
|
597
597
|
abortChat: () => void;
|