@djangocfg/ui-tools 2.1.341 → 2.1.344
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/ChatRoot-CIOFUESH.cjs +14 -0
- package/dist/{ChatRoot-BT3CLXI4.cjs.map → ChatRoot-CIOFUESH.cjs.map} +1 -1
- package/dist/ChatRoot-OURQVRLD.mjs +5 -0
- package/dist/{ChatRoot-R5YQTOLP.mjs.map → ChatRoot-OURQVRLD.mjs.map} +1 -1
- package/dist/{chunk-5T4K3VUV.cjs → chunk-AK2VHUJV.cjs} +35 -10
- package/dist/chunk-AK2VHUJV.cjs.map +1 -0
- package/dist/{chunk-QE25H6DP.mjs → chunk-D7ISTFUS.mjs} +35 -10
- package/dist/chunk-D7ISTFUS.mjs.map +1 -0
- package/dist/index.cjs +46 -46
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +3 -3
- package/package.json +6 -6
- package/src/tools/Chat/Chat.story.tsx +74 -1
- package/src/tools/Chat/README.md +24 -2
- package/src/tools/Chat/components/ChatRoot.tsx +13 -9
- package/src/tools/Chat/core/reducer.ts +17 -2
- package/src/tools/Chat/hooks/useChat.ts +25 -7
- package/src/tools/Chat/types.ts +1 -0
- package/dist/ChatRoot-BT3CLXI4.cjs +0 -14
- package/dist/ChatRoot-R5YQTOLP.mjs +0 -5
- package/dist/chunk-5T4K3VUV.cjs.map +0 -1
- package/dist/chunk-QE25H6DP.mjs.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkAK2VHUJV_cjs = require('./chunk-AK2VHUJV.cjs');
|
|
4
|
+
require('./chunk-B5AWZOHJ.cjs');
|
|
5
|
+
require('./chunk-OLISEQHS.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "ChatRoot", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkAK2VHUJV_cjs.ChatRoot; }
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=ChatRoot-CIOFUESH.cjs.map
|
|
14
|
+
//# sourceMappingURL=ChatRoot-CIOFUESH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-CIOFUESH.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-OURQVRLD.mjs"}
|
|
@@ -149,6 +149,19 @@ function reducer(state, action) {
|
|
|
149
149
|
}
|
|
150
150
|
return state;
|
|
151
151
|
}
|
|
152
|
+
if (action.continueExisting) {
|
|
153
|
+
const lastAssistantIdx = (() => {
|
|
154
|
+
for (let i = state.messages.length - 1; i >= 0; i--) {
|
|
155
|
+
if (state.messages[i].role === "assistant") return i;
|
|
156
|
+
}
|
|
157
|
+
return -1;
|
|
158
|
+
})();
|
|
159
|
+
if (lastAssistantIdx !== -1) {
|
|
160
|
+
const msgs = state.messages.slice();
|
|
161
|
+
msgs[lastAssistantIdx] = { ...msgs[lastAssistantIdx], isStreaming: true };
|
|
162
|
+
return { ...state, isStreaming: true, messages: msgs };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
152
165
|
const placeholder = {
|
|
153
166
|
id: action.id,
|
|
154
167
|
role: "assistant",
|
|
@@ -470,9 +483,25 @@ function useChat(config) {
|
|
|
470
483
|
abortRef.current = ctrl;
|
|
471
484
|
const assistantId = createId("a");
|
|
472
485
|
streamingMsgIdRef.current = assistantId;
|
|
473
|
-
|
|
486
|
+
const iterator = transport.stream(sessionId, content, {
|
|
487
|
+
signal: ctrl.signal,
|
|
488
|
+
attachments,
|
|
489
|
+
metadata: config.metadata
|
|
490
|
+
});
|
|
491
|
+
let continueExisting = false;
|
|
492
|
+
let peekedEvent = null;
|
|
493
|
+
const firstResult = await iterator.next();
|
|
494
|
+
if (!firstResult.done) {
|
|
495
|
+
const ev = firstResult.value;
|
|
496
|
+
if (ev.type === "resume_start") {
|
|
497
|
+
continueExisting = true;
|
|
498
|
+
} else {
|
|
499
|
+
peekedEvent = ev;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
dispatch({ type: "STREAM_START", id: assistantId, continueExisting });
|
|
474
503
|
config.onStreamStart?.(assistantId);
|
|
475
|
-
log.stream.info("start", { sessionId, assistantId, chars: content.length });
|
|
504
|
+
log.stream.info("start", { sessionId, assistantId, chars: content.length, continueExisting });
|
|
476
505
|
const tokenBuffer = createTokenBuffer(
|
|
477
506
|
(delta) => dispatch({ type: "STREAM_CHUNK", delta })
|
|
478
507
|
);
|
|
@@ -480,11 +509,7 @@ function useChat(config) {
|
|
|
480
509
|
let charsReceived = 0;
|
|
481
510
|
const t0 = performance.now();
|
|
482
511
|
try {
|
|
483
|
-
|
|
484
|
-
signal: ctrl.signal,
|
|
485
|
-
attachments,
|
|
486
|
-
metadata: config.metadata
|
|
487
|
-
});
|
|
512
|
+
if (peekedEvent) handleEvent(peekedEvent);
|
|
488
513
|
for await (const ev of iterator) {
|
|
489
514
|
if (ctrl.signal.aborted) break;
|
|
490
515
|
handleEvent(ev);
|
|
@@ -2312,7 +2337,7 @@ function ChatRootShell({ className, slots }) {
|
|
|
2312
2337
|
}
|
|
2313
2338
|
) })
|
|
2314
2339
|
] }),
|
|
2315
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2340
|
+
!slots.hideComposer && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2316
2341
|
Composer,
|
|
2317
2342
|
{
|
|
2318
2343
|
composer,
|
|
@@ -2374,5 +2399,5 @@ exports.useChatContextOptional = useChatContextOptional;
|
|
|
2374
2399
|
exports.useChatHistory = useChatHistory;
|
|
2375
2400
|
exports.useChatLayout = useChatLayout;
|
|
2376
2401
|
exports.useChatScroll = useChatScroll;
|
|
2377
|
-
//# sourceMappingURL=chunk-
|
|
2378
|
-
//# sourceMappingURL=chunk-
|
|
2402
|
+
//# sourceMappingURL=chunk-AK2VHUJV.cjs.map
|
|
2403
|
+
//# sourceMappingURL=chunk-AK2VHUJV.cjs.map
|