@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,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-B6A6OMIG.mjs";
|
|
4
4
|
import "../../chunk-YAGE7RCE.mjs";
|
|
5
5
|
import "../../chunk-VEC45H6Q.mjs";
|
|
6
6
|
import "../../chunk-RQNJNK2W.mjs";
|
|
7
|
-
import "../../chunk-
|
|
7
|
+
import "../../chunk-OI5EKZPO.mjs";
|
|
8
8
|
import "../../chunk-6INMITFA.mjs";
|
|
9
9
|
import "../../chunk-RU73BEZM.mjs";
|
|
10
10
|
import "../../chunk-V7W6IM2V.mjs";
|
|
@@ -2200,6 +2200,7 @@ function DebugMenuButton({
|
|
|
2200
2200
|
}
|
|
2201
2201
|
|
|
2202
2202
|
// src/components/chat/Chat.tsx
|
|
2203
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2203
2204
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2204
2205
|
function CopilotChat({
|
|
2205
2206
|
instructions,
|
|
@@ -2207,6 +2208,8 @@ function CopilotChat({
|
|
|
2207
2208
|
makeSystemMessage,
|
|
2208
2209
|
showResponseButton = true,
|
|
2209
2210
|
onInProgress,
|
|
2211
|
+
onStopGeneration,
|
|
2212
|
+
onReloadMessages,
|
|
2210
2213
|
Messages: Messages2 = Messages,
|
|
2211
2214
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2212
2215
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2229,7 +2232,13 @@ function CopilotChat({
|
|
|
2229
2232
|
sendMessage,
|
|
2230
2233
|
stopGeneration,
|
|
2231
2234
|
reloadMessages
|
|
2232
|
-
} = useCopilotChatLogic(
|
|
2235
|
+
} = useCopilotChatLogic(
|
|
2236
|
+
makeSystemMessage,
|
|
2237
|
+
onInProgress,
|
|
2238
|
+
onSubmitMessage,
|
|
2239
|
+
onStopGeneration,
|
|
2240
|
+
onReloadMessages
|
|
2241
|
+
);
|
|
2233
2242
|
const chatContext = import_react12.default.useContext(ChatContext);
|
|
2234
2243
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2235
2244
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2285,8 +2294,15 @@ function WrappedCopilotChat({
|
|
|
2285
2294
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
|
|
2286
2295
|
}
|
|
2287
2296
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2288
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2289
|
-
|
|
2297
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2298
|
+
var _a;
|
|
2299
|
+
const {
|
|
2300
|
+
visibleMessages,
|
|
2301
|
+
appendMessage,
|
|
2302
|
+
reloadMessages: defaultReloadMessages,
|
|
2303
|
+
stopGeneration: defaultStopGeneration,
|
|
2304
|
+
isLoading
|
|
2305
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2290
2306
|
id: (0, import_shared3.randomId)(),
|
|
2291
2307
|
makeSystemMessage
|
|
2292
2308
|
});
|
|
@@ -2294,8 +2310,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2294
2310
|
const suggestionsAbortControllerRef = (0, import_react12.useRef)(null);
|
|
2295
2311
|
const debounceTimerRef = (0, import_react12.useRef)();
|
|
2296
2312
|
const abortSuggestions = () => {
|
|
2297
|
-
var
|
|
2298
|
-
(
|
|
2313
|
+
var _a2;
|
|
2314
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2299
2315
|
suggestionsAbortControllerRef.current = null;
|
|
2300
2316
|
};
|
|
2301
2317
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2321,7 +2337,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2321
2337
|
return () => {
|
|
2322
2338
|
clearTimeout(debounceTimerRef.current);
|
|
2323
2339
|
};
|
|
2324
|
-
}, [
|
|
2340
|
+
}, [
|
|
2341
|
+
isLoading,
|
|
2342
|
+
context.chatSuggestionConfiguration,
|
|
2343
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2344
|
+
// global context
|
|
2345
|
+
visibleMessages.length == 0
|
|
2346
|
+
]);
|
|
2325
2347
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2326
2348
|
abortSuggestions();
|
|
2327
2349
|
setCurrentSuggestions([]);
|
|
@@ -2339,6 +2361,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2339
2361
|
appendMessage(message);
|
|
2340
2362
|
return message;
|
|
2341
2363
|
});
|
|
2364
|
+
const messages = visibleMessages;
|
|
2365
|
+
const { setMessages } = messagesContext;
|
|
2366
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2367
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2368
|
+
if (generalContext.agentSession) {
|
|
2369
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2370
|
+
nodeName: void 0,
|
|
2371
|
+
threadId: void 0
|
|
2372
|
+
}));
|
|
2373
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2374
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2375
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2376
|
+
threadId: void 0,
|
|
2377
|
+
nodeName: void 0,
|
|
2378
|
+
runId: void 0
|
|
2379
|
+
})
|
|
2380
|
+
});
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2385
|
+
if (generalContext.agentSession) {
|
|
2386
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
const stopCurrentAgent = () => {
|
|
2390
|
+
if (generalContext.agentSession) {
|
|
2391
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2392
|
+
}
|
|
2393
|
+
};
|
|
2394
|
+
const setCurrentAgentState = (state) => {
|
|
2395
|
+
if (generalContext.agentSession) {
|
|
2396
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2397
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2398
|
+
[generalContext.agentSession.agentName]: {
|
|
2399
|
+
state
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
};
|
|
2405
|
+
function stopGeneration() {
|
|
2406
|
+
if (onStopGeneration) {
|
|
2407
|
+
onStopGeneration({
|
|
2408
|
+
messages,
|
|
2409
|
+
setMessages,
|
|
2410
|
+
stopGeneration: defaultStopGeneration,
|
|
2411
|
+
currentAgentName,
|
|
2412
|
+
restartCurrentAgent,
|
|
2413
|
+
stopCurrentAgent,
|
|
2414
|
+
runCurrentAgent,
|
|
2415
|
+
setCurrentAgentState
|
|
2416
|
+
});
|
|
2417
|
+
} else {
|
|
2418
|
+
defaultStopGeneration();
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
function reloadMessages() {
|
|
2422
|
+
if (onReloadMessages) {
|
|
2423
|
+
onReloadMessages({
|
|
2424
|
+
messages,
|
|
2425
|
+
setMessages,
|
|
2426
|
+
stopGeneration: defaultStopGeneration,
|
|
2427
|
+
currentAgentName,
|
|
2428
|
+
restartCurrentAgent,
|
|
2429
|
+
stopCurrentAgent,
|
|
2430
|
+
runCurrentAgent,
|
|
2431
|
+
setCurrentAgentState
|
|
2432
|
+
});
|
|
2433
|
+
} else {
|
|
2434
|
+
defaultReloadMessages();
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2342
2437
|
return {
|
|
2343
2438
|
visibleMessages,
|
|
2344
2439
|
isLoading,
|
|
@@ -2358,6 +2453,8 @@ var CopilotModal = ({
|
|
|
2358
2453
|
hitEscapeToClose = true,
|
|
2359
2454
|
onSetOpen,
|
|
2360
2455
|
onSubmitMessage,
|
|
2456
|
+
onStopGeneration,
|
|
2457
|
+
onReloadMessages,
|
|
2361
2458
|
shortcut = "/",
|
|
2362
2459
|
icons,
|
|
2363
2460
|
labels,
|
|
@@ -2395,6 +2492,8 @@ var CopilotModal = ({
|
|
|
2395
2492
|
{
|
|
2396
2493
|
instructions,
|
|
2397
2494
|
onSubmitMessage,
|
|
2495
|
+
onStopGeneration,
|
|
2496
|
+
onReloadMessages,
|
|
2398
2497
|
makeSystemMessage,
|
|
2399
2498
|
showResponseButton,
|
|
2400
2499
|
onInProgress,
|