@blueking/chat-helper 0.0.10-beta.5 → 0.0.10-dev.2
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.
|
@@ -1894,6 +1894,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1894
1894
|
getAgentInfo: () => Promise<void>;
|
|
1895
1895
|
reset: (protocol: ISSEProtocol) => void;
|
|
1896
1896
|
pollResumeSession: (sessionCode: string) => void;
|
|
1897
|
+
clearLongPollTimer: () => void;
|
|
1897
1898
|
userOperationStreamRequest: (sessionCode: string, operation: UserOperation, payload: IUserOperationPayload, config?: IRequestConfig) => Promise<void>;
|
|
1898
1899
|
streamRequest: ({ sessionCode, url, config, resume, input, }: {
|
|
1899
1900
|
sessionCode: string;
|
|
@@ -138,7 +138,7 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
138
138
|
};
|
|
139
139
|
const streamRequest = function() {
|
|
140
140
|
var _ref = _async_to_generator(function*({ sessionCode, url, config, resume, input }) {
|
|
141
|
-
var // 发起聊天
|
|
141
|
+
var _mediator_message_list_value_at, _mediator_message, // 发起聊天
|
|
142
142
|
_mediator_http;
|
|
143
143
|
// ag-ui 协议需要注入消息模块
|
|
144
144
|
if (usedProtocol instanceof AGUIProtocol) {
|
|
@@ -146,8 +146,8 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
146
146
|
}
|
|
147
147
|
if (input) {
|
|
148
148
|
var // 列表新增一个用户消息
|
|
149
|
-
|
|
150
|
-
(
|
|
149
|
+
_mediator_message1;
|
|
150
|
+
(_mediator_message1 = mediator.message) === null || _mediator_message1 === void 0 ? void 0 : _mediator_message1.list.value.push({
|
|
151
151
|
role: MessageRole.User,
|
|
152
152
|
content: input,
|
|
153
153
|
status: MessageStatus.Complete,
|
|
@@ -186,6 +186,8 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
186
186
|
isChatting.value = true;
|
|
187
187
|
(_usedProtocol_onStart = usedProtocol.onStart) === null || _usedProtocol_onStart === void 0 ? void 0 : _usedProtocol_onStart.call(usedProtocol);
|
|
188
188
|
};
|
|
189
|
+
// 获取最后一条消息的 id
|
|
190
|
+
const lastMessageId = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : (_mediator_message_list_value_at = _mediator_message.list.value.at(-1)) === null || _mediator_message_list_value_at === void 0 ? void 0 : _mediator_message_list_value_at.id;
|
|
189
191
|
// 创建 AbortController
|
|
190
192
|
abortController = new AbortController();
|
|
191
193
|
(_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.fetchClient.streamRequest(_object_spread({
|
|
@@ -197,6 +199,7 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
197
199
|
execute_kwargs: {
|
|
198
200
|
stream: true,
|
|
199
201
|
persist_input: !!input,
|
|
202
|
+
last_message_id: lastMessageId,
|
|
200
203
|
resume
|
|
201
204
|
}
|
|
202
205
|
},
|
|
@@ -401,6 +404,7 @@ import { SessionStatus } from '../session/type.ts.js';
|
|
|
401
404
|
getAgentInfo,
|
|
402
405
|
reset,
|
|
403
406
|
pollResumeSession,
|
|
407
|
+
clearLongPollTimer,
|
|
404
408
|
userOperationStreamRequest,
|
|
405
409
|
streamRequest
|
|
406
410
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1896,6 +1896,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
1896
1896
|
getAgentInfo: () => Promise<void>;
|
|
1897
1897
|
reset: (protocol: import("./http").ISSEProtocol) => void;
|
|
1898
1898
|
pollResumeSession: (sessionCode: string) => void;
|
|
1899
|
+
clearLongPollTimer: () => void;
|
|
1899
1900
|
userOperationStreamRequest: (sessionCode: string, operation: import("./message").UserOperation, payload: import("./message").IUserOperationPayload, config?: import("./http").IRequestConfig) => Promise<void>;
|
|
1900
1901
|
streamRequest: ({ sessionCode, url, config, resume, input, }: {
|
|
1901
1902
|
sessionCode: string;
|