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