@tdesign-react/chat 1.1.0-alpha.17 → 1.1.0-alpha.18
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/es/_chunks/dep-5d7a98b7.js +169 -0
- package/es/_chunks/dep-5d7a98b7.js.map +1 -0
- package/es/_chunks/dep-907337f3.js +1247 -0
- package/es/_chunks/dep-907337f3.js.map +1 -0
- package/es/_chunks/dep-ee7a509c.js +438 -0
- package/es/_chunks/dep-ee7a509c.js.map +1 -0
- package/es/_util/reactify.js +1 -1
- package/es/_util/useDynamicStyle.js +1 -1
- package/es/attachments/index.js +1 -1
- package/es/chat-actionbar/index.js +1 -1
- package/es/chat-engine/components/activity/index.js +2 -2
- package/es/chat-engine/components/activity/registry.js +1 -1
- package/es/chat-engine/components/activity/render.js +2 -2
- package/es/chat-engine/components/activity/types.js +1 -1
- package/es/chat-engine/components/index.js +5 -4
- package/es/chat-engine/components/index.js.map +1 -1
- package/es/chat-engine/components/json-render/catalog/atomic/button.js +1 -1
- package/es/chat-engine/components/json-render/catalog/atomic/card.js +1 -1
- package/es/chat-engine/components/json-render/catalog/atomic/input.js +5 -4
- package/es/chat-engine/components/json-render/catalog/atomic/input.js.map +1 -1
- package/es/chat-engine/components/json-render/catalog/atomic/layout.js +1 -1
- package/es/chat-engine/components/json-render/catalog/atomic/text.js +1 -1
- package/es/chat-engine/components/json-render/catalog/catalog-to-prompt.js +1 -1
- package/es/chat-engine/components/json-render/contexts/actions.js +2 -2
- package/es/chat-engine/components/json-render/contexts/data.js +2 -2
- package/es/chat-engine/components/json-render/contexts/index.js +2 -2
- package/es/chat-engine/components/json-render/contexts/store.js +1 -1
- package/es/chat-engine/components/json-render/contexts/tree.js +1 -1
- package/es/chat-engine/components/json-render/contexts/validation.js +2 -2
- package/es/chat-engine/components/json-render/contexts/visibility.js +2 -2
- package/es/chat-engine/components/json-render/index.js +5 -4
- package/es/chat-engine/components/json-render/index.js.map +1 -1
- package/es/chat-engine/components/json-render/registry/a2ui-binding.js +5 -4
- package/es/chat-engine/components/json-render/registry/a2ui-binding.js.map +1 -1
- package/es/chat-engine/components/json-render/registry/a2ui-registry.js +5 -4
- package/es/chat-engine/components/json-render/registry/a2ui-registry.js.map +1 -1
- package/es/chat-engine/components/json-render/registry/config.js +5 -4
- package/es/chat-engine/components/json-render/registry/config.js.map +1 -1
- package/es/chat-engine/components/json-render/registry/index.js +5 -4
- package/es/chat-engine/components/json-render/registry/index.js.map +1 -1
- package/es/chat-engine/components/json-render/renderer/A2UIJsonRenderActivityRenderer.js +4 -3
- package/es/chat-engine/components/json-render/renderer/A2UIJsonRenderActivityRenderer.js.map +1 -1
- package/es/chat-engine/components/json-render/renderer/JsonRenderActivityRenderer.js +3 -3
- package/es/chat-engine/components/json-render/renderer/JsonUIRenderer.js +2 -2
- package/es/chat-engine/components/json-render/renderer/_index.js +2 -2
- package/es/chat-engine/components/json-render/types.js +1 -1
- package/es/chat-engine/components/provider/agent-state.js +3 -2
- package/es/chat-engine/components/provider/agent-state.js.map +1 -1
- package/es/chat-engine/components/shared/ComponentErrorBoundary.js +1 -1
- package/es/chat-engine/components/shared/createRegistry.js +1 -1
- package/es/chat-engine/components/shared/index.js +1 -1
- package/es/chat-engine/components/shared/useRegistrationListener.js +1 -1
- package/es/chat-engine/components/toolcall/index.js +3 -2
- package/es/chat-engine/components/toolcall/index.js.map +1 -1
- package/es/chat-engine/components/toolcall/registry.js +1 -1
- package/es/chat-engine/components/toolcall/render.js +3 -2
- package/es/chat-engine/components/toolcall/render.js.map +1 -1
- package/es/chat-engine/components/toolcall/types.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/index.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/processor/A2uiMessageProcessor.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/processor/ComponentTree.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/processor/DataStore.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/processor/PathResolver.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/types/index.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/types/types.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/utils/binding.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/utils/index.js +1 -1
- package/es/chat-engine/core/adapters/a2ui/utils/validation.js +1 -1
- package/es/chat-engine/core/adapters/agui/ActivityManager.js +1 -1
- package/es/chat-engine/core/adapters/agui/StateManager.js +1 -1
- package/es/chat-engine/core/adapters/agui/event-mapper.js +1 -1
- package/es/chat-engine/core/adapters/agui/index.js +16 -2
- package/es/chat-engine/core/adapters/agui/index.js.map +1 -1
- package/es/chat-engine/core/adapters/agui/types/events.js +1 -1
- package/es/chat-engine/core/adapters/agui/types/index.js +1 -1
- package/es/chat-engine/core/adapters/agui/utils.js +1 -1
- package/es/chat-engine/core/adapters/index.js +2 -1
- package/es/chat-engine/core/adapters/index.js.map +1 -1
- package/es/chat-engine/core/adapters/json-render/SurfaceStateManager.js +1 -1
- package/es/chat-engine/core/adapters/json-render/a2ui-to-jsonrender.js +1 -1
- package/es/chat-engine/core/adapters/json-render/engine.js +1 -1
- package/es/chat-engine/core/adapters/json-render/index.js +1 -1
- package/es/chat-engine/core/adapters/json-render/types/a2ui.js +1 -1
- package/es/chat-engine/core/adapters/json-render/types/core.js +1 -1
- package/es/chat-engine/core/adapters/json-render/types/index.js +1 -1
- package/es/chat-engine/core/adapters/openclaw/device-key-manager.d.ts +65 -0
- package/es/chat-engine/core/adapters/openclaw/device-key-manager.js +375 -0
- package/es/chat-engine/core/adapters/openclaw/device-key-manager.js.map +1 -0
- package/es/chat-engine/core/adapters/openclaw/event-mapper.js +2 -1
- package/es/chat-engine/core/adapters/openclaw/event-mapper.js.map +1 -1
- package/es/chat-engine/core/adapters/openclaw/history-converter.js +1 -1
- package/es/chat-engine/core/adapters/openclaw/index.d.ts +11 -0
- package/es/chat-engine/core/adapters/openclaw/index.js +70 -17
- package/es/chat-engine/core/adapters/openclaw/index.js.map +1 -1
- package/es/chat-engine/core/adapters/openclaw/rpc-handler.js +1 -1
- package/es/chat-engine/core/adapters/openclaw/types/config.d.ts +21 -0
- package/es/chat-engine/core/adapters/openclaw/types/config.js +8 -4
- package/es/chat-engine/core/adapters/openclaw/types/config.js.map +1 -1
- package/es/chat-engine/core/adapters/openclaw/types/events.d.ts +3 -1
- package/es/chat-engine/core/adapters/openclaw/types/events.js +2 -1
- package/es/chat-engine/core/adapters/openclaw/types/events.js.map +1 -1
- package/es/chat-engine/core/adapters/openclaw/types/index.js +1 -1
- package/es/chat-engine/core/adapters/openclaw/types/messages.d.ts +13 -0
- package/es/chat-engine/core/adapters/openclaw/types/messages.js +1 -1
- package/es/chat-engine/core/adapters/openclaw/types/messages.js.map +1 -1
- package/es/chat-engine/core/adapters/openclaw/utils.js +1 -1
- package/es/chat-engine/core/adapters/shared/activity-manager.js +1 -1
- package/es/chat-engine/core/adapters/shared/content-factory.js +1 -1
- package/es/chat-engine/core/adapters/shared/index.js +1 -1
- package/es/chat-engine/core/adapters/shared/merge-utils.js +1 -1
- package/es/chat-engine/core/event-bus/ChatEventBus.js +1 -1
- package/es/chat-engine/core/event-bus/index.js +1 -1
- package/es/chat-engine/core/event-bus/types.js +1 -1
- package/es/chat-engine/core/index.d.ts +3 -1
- package/es/chat-engine/core/index.js +150 -111
- package/es/chat-engine/core/index.js.map +1 -1
- package/es/chat-engine/core/processor/index.js +1 -1
- package/es/chat-engine/core/server/batch-client.js +1 -1
- package/es/chat-engine/core/server/connection-manager.js +1 -1
- package/es/chat-engine/core/server/errors.js +1 -1
- package/es/chat-engine/core/server/index.js +1 -1
- package/es/chat-engine/core/server/llm-service.js +1 -1
- package/es/chat-engine/core/server/sse-client.js +1 -1
- package/es/chat-engine/core/server/sse-parser.js +1 -1
- package/es/chat-engine/core/server/types.js +1 -1
- package/es/chat-engine/core/server/websocket-client.d.ts +2 -0
- package/es/chat-engine/core/server/websocket-client.js +19 -3
- package/es/chat-engine/core/server/websocket-client.js.map +1 -1
- package/es/chat-engine/core/store/message.js +2 -2
- package/es/chat-engine/core/store/model.js +2 -2
- package/es/chat-engine/core/store/reactiveState.js +2 -2
- package/es/chat-engine/core/stream-handlers/agui-stream-handler.js +1 -1
- package/es/chat-engine/core/stream-handlers/default-stream-handler.js +1 -1
- package/es/chat-engine/core/stream-handlers/index.js +4 -3
- package/es/chat-engine/core/stream-handlers/index.js.map +1 -1
- package/es/chat-engine/core/stream-handlers/openclaw-stream-handler.d.ts +8 -0
- package/es/chat-engine/core/stream-handlers/openclaw-stream-handler.js +73 -22
- package/es/chat-engine/core/stream-handlers/openclaw-stream-handler.js.map +1 -1
- package/es/chat-engine/core/stream-handlers/types.d.ts +1 -1
- package/es/chat-engine/core/stream-handlers/types.js +1 -1
- package/es/chat-engine/core/type.js +1 -1
- package/es/chat-engine/core/utils/eventEmitter.js +1 -1
- package/es/chat-engine/core/utils/immutable-patch.js +1 -1
- package/es/chat-engine/core/utils/index.js +1 -1
- package/es/chat-engine/core/utils/json-patch/helpers.js +1 -1
- package/es/chat-engine/core/utils/json-patch/index.js +1 -1
- package/es/chat-engine/core/utils/logger.js +1 -1
- package/es/chat-engine/core/utils/performance.js +1 -1
- package/es/chat-engine/hooks/index.js +3 -2
- package/es/chat-engine/hooks/index.js.map +1 -1
- package/es/chat-engine/hooks/useAgentActivity.js +1 -1
- package/es/chat-engine/hooks/useAgentState.js +3 -2
- package/es/chat-engine/hooks/useAgentState.js.map +1 -1
- package/es/chat-engine/hooks/useAgentToolcall.js +1 -1
- package/es/chat-engine/hooks/useChat.js +34 -10
- package/es/chat-engine/hooks/useChat.js.map +1 -1
- package/es/chat-engine/index.js +7 -6
- package/es/chat-engine/index.js.map +1 -1
- package/es/chat-filecard/index.js +1 -1
- package/es/chat-loading/index.js +1 -1
- package/es/chat-markdown/index.js +1 -1
- package/es/chat-message/index.js +1 -1
- package/es/chat-sender/index.js +1 -1
- package/es/chat-thinking/index.js +1 -1
- package/es/chatbot/index.js +1 -1
- package/es/index.js +5 -4
- package/es/index.js.map +1 -1
- package/es/style/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tdesign v1.1.0-alpha.
|
|
2
|
+
* tdesign v1.1.0-alpha.17
|
|
3
3
|
* (c) 2026 tdesign
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -37,6 +37,7 @@ export { SurfaceStateManager, surfaceStateManager } from './adapters/json-render
|
|
|
37
37
|
export { applyA2UIDataUpdate, applyA2UIUpdates, convertA2UIMessagesToJsonRender } from './adapters/json-render/a2ui-to-jsonrender.js';
|
|
38
38
|
export { OpenClawEventMapper } from './adapters/openclaw/event-mapper.js';
|
|
39
39
|
export { OpenClawRPCHandler, RPCError } from './adapters/openclaw/rpc-handler.js';
|
|
40
|
+
export { DeviceKeyManager } from './adapters/openclaw/device-key-manager.js';
|
|
40
41
|
export { convertOpenClawHistory, convertOpenClawHistoryResponse } from './adapters/openclaw/history-converter.js';
|
|
41
42
|
export { DEFAULT_OPENCLAW_CONFIG, mergeOpenClawConfig } from './adapters/openclaw/types/config.js';
|
|
42
43
|
export { AgentDataType, AgentStreamType, ChatEventState, OpenClawConnectionState, OpenClawEventType, OpenClawMethod } from './adapters/openclaw/types/events.js';
|
|
@@ -56,7 +57,7 @@ import './utils/immutable-patch.js';
|
|
|
56
57
|
import '@babel/runtime/helpers/toArray';
|
|
57
58
|
import '@babel/runtime/helpers/get';
|
|
58
59
|
import './store/reactiveState.js';
|
|
59
|
-
import '../../_chunks/dep-
|
|
60
|
+
import '../../_chunks/dep-907337f3.js';
|
|
60
61
|
import './server/types.js';
|
|
61
62
|
import './server/errors.js';
|
|
62
63
|
import './server/connection-manager.js';
|
|
@@ -85,6 +86,7 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
85
86
|
_classCallCheck(this, ChatEngine);
|
|
86
87
|
_defineProperty(this, "stopReceive", false);
|
|
87
88
|
_defineProperty(this, "aguiAdapter", null);
|
|
89
|
+
_defineProperty(this, "initialized", false);
|
|
88
90
|
this.messageProcessor = new MessageProcessor();
|
|
89
91
|
this.messageStore = new MessageStore();
|
|
90
92
|
this.eventBus = new ChatEventBus(eventBusOptions);
|
|
@@ -116,36 +118,73 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
116
118
|
}
|
|
117
119
|
}, {
|
|
118
120
|
key: "init",
|
|
119
|
-
value: function
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
121
|
+
value: function () {
|
|
122
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(configSetter, initialMessages) {
|
|
123
|
+
var _this = this;
|
|
124
|
+
var _t;
|
|
125
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
126
|
+
while (1) switch (_context.prev = _context.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
if (!this.initialized) {
|
|
129
|
+
_context.next = 1;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
return _context.abrupt("return");
|
|
133
|
+
case 1:
|
|
134
|
+
this.initialized = true;
|
|
135
|
+
if (!this.streamHandler) {
|
|
136
|
+
_context.next = 5;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
_context.prev = 2;
|
|
140
|
+
_context.next = 3;
|
|
141
|
+
return this.streamHandler.destroy();
|
|
142
|
+
case 3:
|
|
143
|
+
_context.next = 5;
|
|
144
|
+
break;
|
|
145
|
+
case 4:
|
|
146
|
+
_context.prev = 4;
|
|
147
|
+
_t = _context["catch"](2);
|
|
148
|
+
case 5:
|
|
149
|
+
this.aguiAdapter = null;
|
|
150
|
+
this.messageStore.initialize(this.convertMessages(initialMessages));
|
|
151
|
+
this.config = typeof configSetter === "function" ? configSetter() : configSetter || {};
|
|
152
|
+
this.llmService = new LLMService();
|
|
153
|
+
if (this.config.protocol === "agui") {
|
|
154
|
+
this.aguiAdapter = new AGUIAdapter();
|
|
155
|
+
}
|
|
156
|
+
this.streamHandler = createStreamHandler({
|
|
157
|
+
protocol: this.config.protocol,
|
|
158
|
+
llmService: this.llmService,
|
|
159
|
+
aguiAdapter: this.aguiAdapter
|
|
160
|
+
});
|
|
161
|
+
if (this.config.protocol === "openclaw" && this.config.endpoint && this.streamHandler instanceof OpenClawStreamHandler) {
|
|
162
|
+
this.streamHandler.initConnection(this.config, function (historyMessages) {
|
|
163
|
+
if (historyMessages && historyMessages.length > 0) {
|
|
164
|
+
var _this$config$onHistor, _this$config;
|
|
165
|
+
_this.messageStore.setMessages(historyMessages, "replace");
|
|
166
|
+
(_this$config$onHistor = (_this$config = _this.config).onHistoryLoaded) === null || _this$config$onHistor === void 0 || _this$config$onHistor.call(_this$config, historyMessages);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
this.eventBus.emit(ChatEngineEventType.ENGINE_INIT, {
|
|
171
|
+
timestamp: Date.now()
|
|
172
|
+
});
|
|
173
|
+
case 6:
|
|
174
|
+
case "end":
|
|
175
|
+
return _context.stop();
|
|
138
176
|
}
|
|
139
|
-
});
|
|
177
|
+
}, _callee, this, [[2, 4]]);
|
|
178
|
+
}));
|
|
179
|
+
function init(_x, _x2) {
|
|
180
|
+
return _init.apply(this, arguments);
|
|
140
181
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
}
|
|
182
|
+
return init;
|
|
183
|
+
}()
|
|
145
184
|
}, {
|
|
146
185
|
key: "sendUserMessage",
|
|
147
186
|
value: function () {
|
|
148
|
-
var _sendUserMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
187
|
+
var _sendUserMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(requestParams) {
|
|
149
188
|
var sendRequest,
|
|
150
189
|
prompt,
|
|
151
190
|
attachments,
|
|
@@ -155,20 +194,20 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
155
194
|
userMessage,
|
|
156
195
|
aiMessage,
|
|
157
196
|
params,
|
|
158
|
-
|
|
159
|
-
return _regeneratorRuntime.wrap(function (
|
|
160
|
-
while (1) switch (
|
|
197
|
+
_args2 = arguments;
|
|
198
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
199
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
161
200
|
case 0:
|
|
162
|
-
sendRequest =
|
|
201
|
+
sendRequest = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
|
|
163
202
|
prompt = requestParams.prompt, attachments = requestParams.attachments, customParams = _objectWithoutProperties(requestParams, _excluded);
|
|
164
203
|
hasValidPrompt = prompt && prompt.trim() !== "";
|
|
165
204
|
hasValidAttachments = Array.isArray(attachments) && attachments.length > 0;
|
|
166
205
|
if (!(!hasValidPrompt && !hasValidAttachments)) {
|
|
167
|
-
|
|
206
|
+
_context2.next = 1;
|
|
168
207
|
break;
|
|
169
208
|
}
|
|
170
209
|
console.warn("[ChatEngine] sendUserMessage: \u5FC5\u987B\u63D0\u4F9B\u6709\u6548\u7684prompt\u6216attachments");
|
|
171
|
-
return
|
|
210
|
+
return _context2.abrupt("return");
|
|
172
211
|
case 1:
|
|
173
212
|
userMessage = this.messageProcessor.createUserMessage(prompt, attachments);
|
|
174
213
|
aiMessage = this.messageProcessor.createAssistantMessage();
|
|
@@ -185,11 +224,11 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
185
224
|
}
|
|
186
225
|
case 2:
|
|
187
226
|
case "end":
|
|
188
|
-
return
|
|
227
|
+
return _context2.stop();
|
|
189
228
|
}
|
|
190
|
-
},
|
|
229
|
+
}, _callee2, this);
|
|
191
230
|
}));
|
|
192
|
-
function sendUserMessage(
|
|
231
|
+
function sendUserMessage(_x3) {
|
|
193
232
|
return _sendUserMessage.apply(this, arguments);
|
|
194
233
|
}
|
|
195
234
|
return sendUserMessage;
|
|
@@ -197,10 +236,10 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
197
236
|
}, {
|
|
198
237
|
key: "sendSystemMessage",
|
|
199
238
|
value: function () {
|
|
200
|
-
var _sendSystemMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
239
|
+
var _sendSystemMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(msg) {
|
|
201
240
|
var systemMessage;
|
|
202
|
-
return _regeneratorRuntime.wrap(function (
|
|
203
|
-
while (1) switch (
|
|
241
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
242
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
204
243
|
case 0:
|
|
205
244
|
systemMessage = {
|
|
206
245
|
role: "system",
|
|
@@ -216,11 +255,11 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
216
255
|
});
|
|
217
256
|
case 1:
|
|
218
257
|
case "end":
|
|
219
|
-
return
|
|
258
|
+
return _context3.stop();
|
|
220
259
|
}
|
|
221
|
-
},
|
|
260
|
+
}, _callee3, this);
|
|
222
261
|
}));
|
|
223
|
-
function sendSystemMessage(
|
|
262
|
+
function sendSystemMessage(_x4) {
|
|
224
263
|
return _sendSystemMessage.apply(this, arguments);
|
|
225
264
|
}
|
|
226
265
|
return sendSystemMessage;
|
|
@@ -228,7 +267,7 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
228
267
|
}, {
|
|
229
268
|
key: "sendAIMessage",
|
|
230
269
|
value: function () {
|
|
231
|
-
var _sendAIMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
270
|
+
var _sendAIMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
232
271
|
var options,
|
|
233
272
|
_options$params,
|
|
234
273
|
params,
|
|
@@ -236,11 +275,11 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
236
275
|
_options$sendRequest,
|
|
237
276
|
sendRequest,
|
|
238
277
|
newAIMessage,
|
|
239
|
-
|
|
240
|
-
return _regeneratorRuntime.wrap(function (
|
|
241
|
-
while (1) switch (
|
|
278
|
+
_args4 = arguments;
|
|
279
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
280
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
242
281
|
case 0:
|
|
243
|
-
options =
|
|
282
|
+
options = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
244
283
|
_options$params = options.params, params = _options$params === void 0 ? {} : _options$params, content = options.content, _options$sendRequest = options.sendRequest, sendRequest = _options$sendRequest === void 0 ? true : _options$sendRequest;
|
|
245
284
|
newAIMessage = this.messageProcessor.createAssistantMessage({
|
|
246
285
|
content: content,
|
|
@@ -252,17 +291,17 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
252
291
|
messages: this.messages
|
|
253
292
|
});
|
|
254
293
|
if (!sendRequest) {
|
|
255
|
-
|
|
294
|
+
_context4.next = 1;
|
|
256
295
|
break;
|
|
257
296
|
}
|
|
258
297
|
params.messageID = newAIMessage.id;
|
|
259
|
-
|
|
298
|
+
_context4.next = 1;
|
|
260
299
|
return this.sendRequest(params);
|
|
261
300
|
case 1:
|
|
262
301
|
case "end":
|
|
263
|
-
return
|
|
302
|
+
return _context4.stop();
|
|
264
303
|
}
|
|
265
|
-
},
|
|
304
|
+
}, _callee4, this);
|
|
266
305
|
}));
|
|
267
306
|
function sendAIMessage() {
|
|
268
307
|
return _sendAIMessage.apply(this, arguments);
|
|
@@ -272,14 +311,14 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
272
311
|
}, {
|
|
273
312
|
key: "resumeRun",
|
|
274
313
|
value: function () {
|
|
275
|
-
var _resumeRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
314
|
+
var _resumeRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
276
315
|
var params,
|
|
277
316
|
newAIMessage,
|
|
278
|
-
|
|
279
|
-
return _regeneratorRuntime.wrap(function (
|
|
280
|
-
while (1) switch (
|
|
317
|
+
_args5 = arguments;
|
|
318
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
319
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
281
320
|
case 0:
|
|
282
|
-
params =
|
|
321
|
+
params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
|
283
322
|
newAIMessage = this.messageProcessor.createAssistantMessage({
|
|
284
323
|
content: [],
|
|
285
324
|
status: "pending"
|
|
@@ -290,15 +329,15 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
290
329
|
messages: this.messages
|
|
291
330
|
});
|
|
292
331
|
params.messageID = newAIMessage.id;
|
|
293
|
-
|
|
332
|
+
_context5.next = 1;
|
|
294
333
|
return this.sendRequest(params);
|
|
295
334
|
case 1:
|
|
296
|
-
return
|
|
335
|
+
return _context5.abrupt("return", newAIMessage.id);
|
|
297
336
|
case 2:
|
|
298
337
|
case "end":
|
|
299
|
-
return
|
|
338
|
+
return _context5.stop();
|
|
300
339
|
}
|
|
301
|
-
},
|
|
340
|
+
}, _callee5, this);
|
|
302
341
|
}));
|
|
303
342
|
function resumeRun() {
|
|
304
343
|
return _resumeRun.apply(this, arguments);
|
|
@@ -308,18 +347,18 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
308
347
|
}, {
|
|
309
348
|
key: "abortChat",
|
|
310
349
|
value: function () {
|
|
311
|
-
var _abortChat = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
350
|
+
var _abortChat = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
312
351
|
var _this$config2;
|
|
313
352
|
var _this$messageStore$la, messageId;
|
|
314
|
-
return _regeneratorRuntime.wrap(function (
|
|
315
|
-
while (1) switch (
|
|
353
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
354
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
316
355
|
case 0:
|
|
317
356
|
this.stopReceive = true;
|
|
318
357
|
if (!((_this$config2 = this.config) !== null && _this$config2 !== void 0 && _this$config2.onAbort)) {
|
|
319
|
-
|
|
358
|
+
_context6.next = 1;
|
|
320
359
|
break;
|
|
321
360
|
}
|
|
322
|
-
|
|
361
|
+
_context6.next = 1;
|
|
323
362
|
return this.config.onAbort();
|
|
324
363
|
case 1:
|
|
325
364
|
try {
|
|
@@ -342,9 +381,9 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
342
381
|
}
|
|
343
382
|
case 2:
|
|
344
383
|
case "end":
|
|
345
|
-
return
|
|
384
|
+
return _context6.stop();
|
|
346
385
|
}
|
|
347
|
-
},
|
|
386
|
+
}, _callee6, this);
|
|
348
387
|
}));
|
|
349
388
|
function abortChat() {
|
|
350
389
|
return _abortChat.apply(this, arguments);
|
|
@@ -373,23 +412,23 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
373
412
|
}, {
|
|
374
413
|
key: "regenerateAIMessage",
|
|
375
414
|
value: function () {
|
|
376
|
-
var _regenerateAIMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
415
|
+
var _regenerateAIMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
377
416
|
var _this$lastRequestPara, _this$lastRequestPara2;
|
|
378
417
|
var keepVersion,
|
|
379
418
|
lastAIMessage,
|
|
380
419
|
newAIMessage,
|
|
381
420
|
params,
|
|
382
|
-
|
|
383
|
-
return _regeneratorRuntime.wrap(function (
|
|
384
|
-
while (1) switch (
|
|
421
|
+
_args7 = arguments;
|
|
422
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
423
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
385
424
|
case 0:
|
|
386
|
-
keepVersion =
|
|
425
|
+
keepVersion = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : false;
|
|
387
426
|
lastAIMessage = this.messageStore.lastAIMessage;
|
|
388
427
|
if (lastAIMessage) {
|
|
389
|
-
|
|
428
|
+
_context7.next = 1;
|
|
390
429
|
break;
|
|
391
430
|
}
|
|
392
|
-
return
|
|
431
|
+
return _context7.abrupt("return");
|
|
393
432
|
case 1:
|
|
394
433
|
if (!keepVersion) {
|
|
395
434
|
this.messageStore.removeMessage(lastAIMessage.id);
|
|
@@ -402,13 +441,13 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
402
441
|
messageID: newAIMessage.id,
|
|
403
442
|
prompt: (_this$lastRequestPara = (_this$lastRequestPara2 = this.lastRequestParams) === null || _this$lastRequestPara2 === void 0 ? void 0 : _this$lastRequestPara2.prompt) !== null && _this$lastRequestPara !== void 0 ? _this$lastRequestPara : ""
|
|
404
443
|
});
|
|
405
|
-
|
|
444
|
+
_context7.next = 2;
|
|
406
445
|
return this.sendRequest(params);
|
|
407
446
|
case 2:
|
|
408
447
|
case "end":
|
|
409
|
-
return
|
|
448
|
+
return _context7.stop();
|
|
410
449
|
}
|
|
411
|
-
},
|
|
450
|
+
}, _callee7, this);
|
|
412
451
|
}));
|
|
413
452
|
function regenerateAIMessage() {
|
|
414
453
|
return _regenerateAIMessage.apply(this, arguments);
|
|
@@ -418,51 +457,51 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
418
457
|
}, {
|
|
419
458
|
key: "sendRequest",
|
|
420
459
|
value: function () {
|
|
421
|
-
var _sendRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
422
|
-
var id,
|
|
423
|
-
return _regeneratorRuntime.wrap(function (
|
|
424
|
-
while (1) switch (
|
|
460
|
+
var _sendRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params) {
|
|
461
|
+
var id, _t2;
|
|
462
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
463
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
425
464
|
case 0:
|
|
426
465
|
id = params.messageID;
|
|
427
466
|
this.eventBus.emit(ChatEngineEventType.REQUEST_START, {
|
|
428
467
|
params: params,
|
|
429
468
|
messageId: id
|
|
430
469
|
});
|
|
431
|
-
|
|
470
|
+
_context8.prev = 1;
|
|
432
471
|
if (!this.config.stream) {
|
|
433
|
-
|
|
472
|
+
_context8.next = 3;
|
|
434
473
|
break;
|
|
435
474
|
}
|
|
436
475
|
this.stopReceive = false;
|
|
437
|
-
|
|
476
|
+
_context8.next = 2;
|
|
438
477
|
return this.handleStreamRequest(params);
|
|
439
478
|
case 2:
|
|
440
|
-
|
|
479
|
+
_context8.next = 4;
|
|
441
480
|
break;
|
|
442
481
|
case 3:
|
|
443
|
-
|
|
482
|
+
_context8.next = 4;
|
|
444
483
|
return this.handleBatchRequest(params);
|
|
445
484
|
case 4:
|
|
446
485
|
this.lastRequestParams = params;
|
|
447
|
-
|
|
486
|
+
_context8.next = 6;
|
|
448
487
|
break;
|
|
449
488
|
case 5:
|
|
450
|
-
|
|
451
|
-
|
|
489
|
+
_context8.prev = 5;
|
|
490
|
+
_t2 = _context8["catch"](1);
|
|
452
491
|
this.setMessageStatus(id, "error");
|
|
453
492
|
this.eventBus.emit(ChatEngineEventType.REQUEST_ERROR, {
|
|
454
493
|
messageId: id,
|
|
455
|
-
error:
|
|
494
|
+
error: _t2,
|
|
456
495
|
params: params
|
|
457
496
|
});
|
|
458
|
-
throw
|
|
497
|
+
throw _t2;
|
|
459
498
|
case 6:
|
|
460
499
|
case "end":
|
|
461
|
-
return
|
|
500
|
+
return _context8.stop();
|
|
462
501
|
}
|
|
463
|
-
},
|
|
502
|
+
}, _callee8, this, [[1, 5]]);
|
|
464
503
|
}));
|
|
465
|
-
function sendRequest(
|
|
504
|
+
function sendRequest(_x5) {
|
|
466
505
|
return _sendRequest.apply(this, arguments);
|
|
467
506
|
}
|
|
468
507
|
return sendRequest;
|
|
@@ -476,23 +515,23 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
476
515
|
}, {
|
|
477
516
|
key: "handleBatchRequest",
|
|
478
517
|
value: function () {
|
|
479
|
-
var _handleBatchRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
518
|
+
var _handleBatchRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(params) {
|
|
480
519
|
var id, result, message;
|
|
481
|
-
return _regeneratorRuntime.wrap(function (
|
|
482
|
-
while (1) switch (
|
|
520
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
521
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
483
522
|
case 0:
|
|
484
523
|
id = params.messageID;
|
|
485
524
|
if (id) {
|
|
486
|
-
|
|
525
|
+
_context9.next = 1;
|
|
487
526
|
break;
|
|
488
527
|
}
|
|
489
|
-
return
|
|
528
|
+
return _context9.abrupt("return");
|
|
490
529
|
case 1:
|
|
491
530
|
this.setMessageStatus(id, "pending");
|
|
492
|
-
|
|
531
|
+
_context9.next = 2;
|
|
493
532
|
return this.llmService.handleBatchRequest(params, this.config);
|
|
494
533
|
case 2:
|
|
495
|
-
result =
|
|
534
|
+
result = _context9.sent;
|
|
496
535
|
if (result) {
|
|
497
536
|
this.processMessageResult(id, result);
|
|
498
537
|
this.setMessageStatus(id, "complete");
|
|
@@ -514,11 +553,11 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
514
553
|
}
|
|
515
554
|
case 3:
|
|
516
555
|
case "end":
|
|
517
|
-
return
|
|
556
|
+
return _context9.stop();
|
|
518
557
|
}
|
|
519
|
-
},
|
|
558
|
+
}, _callee9, this);
|
|
520
559
|
}));
|
|
521
|
-
function handleBatchRequest(
|
|
560
|
+
function handleBatchRequest(_x6) {
|
|
522
561
|
return _handleBatchRequest.apply(this, arguments);
|
|
523
562
|
}
|
|
524
563
|
return handleBatchRequest;
|
|
@@ -566,25 +605,25 @@ var ChatEngine = /*#__PURE__*/function () {
|
|
|
566
605
|
}, {
|
|
567
606
|
key: "handleStreamRequest",
|
|
568
607
|
value: function () {
|
|
569
|
-
var _handleStreamRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
608
|
+
var _handleStreamRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(params) {
|
|
570
609
|
var id, context;
|
|
571
|
-
return _regeneratorRuntime.wrap(function (
|
|
572
|
-
while (1) switch (
|
|
610
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
611
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
573
612
|
case 0:
|
|
574
613
|
id = params.messageID;
|
|
575
614
|
if (id) {
|
|
576
615
|
this.setMessageStatus(id, "streaming");
|
|
577
616
|
}
|
|
578
617
|
context = this.buildStreamContext(id);
|
|
579
|
-
|
|
618
|
+
_context0.next = 1;
|
|
580
619
|
return this.streamHandler.handleStream(params, context);
|
|
581
620
|
case 1:
|
|
582
621
|
case "end":
|
|
583
|
-
return
|
|
622
|
+
return _context0.stop();
|
|
584
623
|
}
|
|
585
|
-
},
|
|
624
|
+
}, _callee0, this);
|
|
586
625
|
}));
|
|
587
|
-
function handleStreamRequest(
|
|
626
|
+
function handleStreamRequest(_x7) {
|
|
588
627
|
return _handleStreamRequest.apply(this, arguments);
|
|
589
628
|
}
|
|
590
629
|
return handleStreamRequest;
|