@copilotkit/react-ui 1.4.1 → 1.4.2-tyler-reset-chat.1
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/CHANGELOG.md +20 -0
- package/dist/{chunk-63ZKP62F.mjs → chunk-B6A6OMIG.mjs} +6 -2
- package/dist/chunk-B6A6OMIG.mjs.map +1 -0
- package/dist/{chunk-DHGDU64D.mjs → chunk-OI5EKZPO.mjs} +103 -7
- package/dist/chunk-OI5EKZPO.mjs.map +1 -0
- package/dist/{chunk-TKFQ7VQR.mjs → chunk-RQRK6DEW.mjs} +2 -2
- package/dist/{chunk-VYKDFXGS.mjs → chunk-Z2RXDT7O.mjs} +2 -2
- package/dist/components/chat/Chat.d.ts +50 -5
- package/dist/components/chat/Chat.js +101 -6
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +1 -1
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +105 -6
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +2 -2
- package/dist/components/chat/Popup.js +105 -6
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +3 -3
- package/dist/components/chat/Sidebar.js +105 -6
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +3 -3
- package/dist/components/chat/index.js +105 -6
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +4 -4
- package/dist/components/index.js +105 -6
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +4 -4
- package/dist/index.js +107 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +167 -8
- package/src/components/chat/Modal.tsx +4 -0
- package/dist/chunk-63ZKP62F.mjs.map +0 -1
- package/dist/chunk-DHGDU64D.mjs.map +0 -1
- /package/dist/{chunk-TKFQ7VQR.mjs.map → chunk-RQRK6DEW.mjs.map} +0 -0
- /package/dist/{chunk-VYKDFXGS.mjs.map → chunk-Z2RXDT7O.mjs.map} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import "../../chunk-MRFF7GSQ.mjs";
|
|
2
2
|
import {
|
|
3
3
|
CopilotSidebar
|
|
4
|
-
} from "../../chunk-
|
|
4
|
+
} from "../../chunk-RQRK6DEW.mjs";
|
|
5
5
|
import "../../chunk-WB3YULQ4.mjs";
|
|
6
6
|
import {
|
|
7
7
|
CopilotPopup
|
|
8
|
-
} from "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
8
|
+
} from "../../chunk-Z2RXDT7O.mjs";
|
|
9
|
+
import "../../chunk-B6A6OMIG.mjs";
|
|
10
10
|
import "../../chunk-YAGE7RCE.mjs";
|
|
11
11
|
import "../../chunk-VEC45H6Q.mjs";
|
|
12
12
|
import "../../chunk-RQNJNK2W.mjs";
|
|
13
13
|
import {
|
|
14
14
|
CopilotChat
|
|
15
|
-
} from "../../chunk-
|
|
15
|
+
} from "../../chunk-OI5EKZPO.mjs";
|
|
16
16
|
import "../../chunk-6INMITFA.mjs";
|
|
17
17
|
import "../../chunk-RU73BEZM.mjs";
|
|
18
18
|
import "../../chunk-V7W6IM2V.mjs";
|
package/dist/components/index.js
CHANGED
|
@@ -2205,6 +2205,7 @@ function DebugMenuButton({
|
|
|
2205
2205
|
}
|
|
2206
2206
|
|
|
2207
2207
|
// src/components/chat/Chat.tsx
|
|
2208
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2208
2209
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2209
2210
|
function CopilotChat({
|
|
2210
2211
|
instructions,
|
|
@@ -2212,6 +2213,8 @@ function CopilotChat({
|
|
|
2212
2213
|
makeSystemMessage,
|
|
2213
2214
|
showResponseButton = true,
|
|
2214
2215
|
onInProgress,
|
|
2216
|
+
onStopGeneration,
|
|
2217
|
+
onReloadMessages,
|
|
2215
2218
|
Messages: Messages2 = Messages,
|
|
2216
2219
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2217
2220
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2234,7 +2237,13 @@ function CopilotChat({
|
|
|
2234
2237
|
sendMessage,
|
|
2235
2238
|
stopGeneration,
|
|
2236
2239
|
reloadMessages
|
|
2237
|
-
} = useCopilotChatLogic(
|
|
2240
|
+
} = useCopilotChatLogic(
|
|
2241
|
+
makeSystemMessage,
|
|
2242
|
+
onInProgress,
|
|
2243
|
+
onSubmitMessage,
|
|
2244
|
+
onStopGeneration,
|
|
2245
|
+
onReloadMessages
|
|
2246
|
+
);
|
|
2238
2247
|
const chatContext = import_react12.default.useContext(ChatContext);
|
|
2239
2248
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2240
2249
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2290,8 +2299,15 @@ function WrappedCopilotChat({
|
|
|
2290
2299
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
|
|
2291
2300
|
}
|
|
2292
2301
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2293
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2294
|
-
|
|
2302
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2303
|
+
var _a;
|
|
2304
|
+
const {
|
|
2305
|
+
visibleMessages,
|
|
2306
|
+
appendMessage,
|
|
2307
|
+
reloadMessages: defaultReloadMessages,
|
|
2308
|
+
stopGeneration: defaultStopGeneration,
|
|
2309
|
+
isLoading
|
|
2310
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2295
2311
|
id: (0, import_shared3.randomId)(),
|
|
2296
2312
|
makeSystemMessage
|
|
2297
2313
|
});
|
|
@@ -2299,8 +2315,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2299
2315
|
const suggestionsAbortControllerRef = (0, import_react12.useRef)(null);
|
|
2300
2316
|
const debounceTimerRef = (0, import_react12.useRef)();
|
|
2301
2317
|
const abortSuggestions = () => {
|
|
2302
|
-
var
|
|
2303
|
-
(
|
|
2318
|
+
var _a2;
|
|
2319
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2304
2320
|
suggestionsAbortControllerRef.current = null;
|
|
2305
2321
|
};
|
|
2306
2322
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2326,7 +2342,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2326
2342
|
return () => {
|
|
2327
2343
|
clearTimeout(debounceTimerRef.current);
|
|
2328
2344
|
};
|
|
2329
|
-
}, [
|
|
2345
|
+
}, [
|
|
2346
|
+
isLoading,
|
|
2347
|
+
context.chatSuggestionConfiguration,
|
|
2348
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2349
|
+
// global context
|
|
2350
|
+
visibleMessages.length == 0
|
|
2351
|
+
]);
|
|
2330
2352
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2331
2353
|
abortSuggestions();
|
|
2332
2354
|
setCurrentSuggestions([]);
|
|
@@ -2344,6 +2366,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2344
2366
|
appendMessage(message);
|
|
2345
2367
|
return message;
|
|
2346
2368
|
});
|
|
2369
|
+
const messages = visibleMessages;
|
|
2370
|
+
const { setMessages } = messagesContext;
|
|
2371
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2372
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2373
|
+
if (generalContext.agentSession) {
|
|
2374
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2375
|
+
nodeName: void 0,
|
|
2376
|
+
threadId: void 0
|
|
2377
|
+
}));
|
|
2378
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2379
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2380
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2381
|
+
threadId: void 0,
|
|
2382
|
+
nodeName: void 0,
|
|
2383
|
+
runId: void 0
|
|
2384
|
+
})
|
|
2385
|
+
});
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2390
|
+
if (generalContext.agentSession) {
|
|
2391
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2392
|
+
}
|
|
2393
|
+
});
|
|
2394
|
+
const stopCurrentAgent = () => {
|
|
2395
|
+
if (generalContext.agentSession) {
|
|
2396
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
const setCurrentAgentState = (state) => {
|
|
2400
|
+
if (generalContext.agentSession) {
|
|
2401
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2402
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2403
|
+
[generalContext.agentSession.agentName]: {
|
|
2404
|
+
state
|
|
2405
|
+
}
|
|
2406
|
+
});
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
};
|
|
2410
|
+
function stopGeneration() {
|
|
2411
|
+
if (onStopGeneration) {
|
|
2412
|
+
onStopGeneration({
|
|
2413
|
+
messages,
|
|
2414
|
+
setMessages,
|
|
2415
|
+
stopGeneration: defaultStopGeneration,
|
|
2416
|
+
currentAgentName,
|
|
2417
|
+
restartCurrentAgent,
|
|
2418
|
+
stopCurrentAgent,
|
|
2419
|
+
runCurrentAgent,
|
|
2420
|
+
setCurrentAgentState
|
|
2421
|
+
});
|
|
2422
|
+
} else {
|
|
2423
|
+
defaultStopGeneration();
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
function reloadMessages() {
|
|
2427
|
+
if (onReloadMessages) {
|
|
2428
|
+
onReloadMessages({
|
|
2429
|
+
messages,
|
|
2430
|
+
setMessages,
|
|
2431
|
+
stopGeneration: defaultStopGeneration,
|
|
2432
|
+
currentAgentName,
|
|
2433
|
+
restartCurrentAgent,
|
|
2434
|
+
stopCurrentAgent,
|
|
2435
|
+
runCurrentAgent,
|
|
2436
|
+
setCurrentAgentState
|
|
2437
|
+
});
|
|
2438
|
+
} else {
|
|
2439
|
+
defaultReloadMessages();
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2347
2442
|
return {
|
|
2348
2443
|
visibleMessages,
|
|
2349
2444
|
isLoading,
|
|
@@ -2363,6 +2458,8 @@ var CopilotModal = ({
|
|
|
2363
2458
|
hitEscapeToClose = true,
|
|
2364
2459
|
onSetOpen,
|
|
2365
2460
|
onSubmitMessage,
|
|
2461
|
+
onStopGeneration,
|
|
2462
|
+
onReloadMessages,
|
|
2366
2463
|
shortcut = "/",
|
|
2367
2464
|
icons,
|
|
2368
2465
|
labels,
|
|
@@ -2400,6 +2497,8 @@ var CopilotModal = ({
|
|
|
2400
2497
|
{
|
|
2401
2498
|
instructions,
|
|
2402
2499
|
onSubmitMessage,
|
|
2500
|
+
onStopGeneration,
|
|
2501
|
+
onReloadMessages,
|
|
2403
2502
|
makeSystemMessage,
|
|
2404
2503
|
showResponseButton,
|
|
2405
2504
|
onInProgress,
|