@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
|
@@ -2,18 +2,18 @@ import "../chunk-MMVDU6DF.mjs";
|
|
|
2
2
|
import "../chunk-MRFF7GSQ.mjs";
|
|
3
3
|
import {
|
|
4
4
|
CopilotSidebar
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-RQRK6DEW.mjs";
|
|
6
6
|
import "../chunk-WB3YULQ4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
CopilotPopup
|
|
9
|
-
} from "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
} from "../chunk-Z2RXDT7O.mjs";
|
|
10
|
+
import "../chunk-B6A6OMIG.mjs";
|
|
11
11
|
import "../chunk-YAGE7RCE.mjs";
|
|
12
12
|
import "../chunk-VEC45H6Q.mjs";
|
|
13
13
|
import "../chunk-RQNJNK2W.mjs";
|
|
14
14
|
import {
|
|
15
15
|
CopilotChat
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-OI5EKZPO.mjs";
|
|
17
17
|
import "../chunk-6INMITFA.mjs";
|
|
18
18
|
import "../chunk-RU73BEZM.mjs";
|
|
19
19
|
import "../chunk-V7W6IM2V.mjs";
|
package/dist/index.js
CHANGED
|
@@ -2207,6 +2207,7 @@ function DebugMenuButton({
|
|
|
2207
2207
|
}
|
|
2208
2208
|
|
|
2209
2209
|
// src/components/chat/Chat.tsx
|
|
2210
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2210
2211
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2211
2212
|
function CopilotChat({
|
|
2212
2213
|
instructions,
|
|
@@ -2214,6 +2215,8 @@ function CopilotChat({
|
|
|
2214
2215
|
makeSystemMessage,
|
|
2215
2216
|
showResponseButton = true,
|
|
2216
2217
|
onInProgress,
|
|
2218
|
+
onStopGeneration,
|
|
2219
|
+
onReloadMessages,
|
|
2217
2220
|
Messages: Messages2 = Messages,
|
|
2218
2221
|
RenderTextMessage: RenderTextMessage2 = RenderTextMessage,
|
|
2219
2222
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
@@ -2236,7 +2239,13 @@ function CopilotChat({
|
|
|
2236
2239
|
sendMessage,
|
|
2237
2240
|
stopGeneration,
|
|
2238
2241
|
reloadMessages
|
|
2239
|
-
} = useCopilotChatLogic(
|
|
2242
|
+
} = useCopilotChatLogic(
|
|
2243
|
+
makeSystemMessage,
|
|
2244
|
+
onInProgress,
|
|
2245
|
+
onSubmitMessage,
|
|
2246
|
+
onStopGeneration,
|
|
2247
|
+
onReloadMessages
|
|
2248
|
+
);
|
|
2240
2249
|
const chatContext = import_react12.default.useContext(ChatContext);
|
|
2241
2250
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2242
2251
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
@@ -2292,8 +2301,15 @@ function WrappedCopilotChat({
|
|
|
2292
2301
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
|
|
2293
2302
|
}
|
|
2294
2303
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2295
|
-
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
2296
|
-
|
|
2304
|
+
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2305
|
+
var _a;
|
|
2306
|
+
const {
|
|
2307
|
+
visibleMessages,
|
|
2308
|
+
appendMessage,
|
|
2309
|
+
reloadMessages: defaultReloadMessages,
|
|
2310
|
+
stopGeneration: defaultStopGeneration,
|
|
2311
|
+
isLoading
|
|
2312
|
+
} = (0, import_react_core8.useCopilotChat)({
|
|
2297
2313
|
id: (0, import_shared3.randomId)(),
|
|
2298
2314
|
makeSystemMessage
|
|
2299
2315
|
});
|
|
@@ -2301,8 +2317,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2301
2317
|
const suggestionsAbortControllerRef = (0, import_react12.useRef)(null);
|
|
2302
2318
|
const debounceTimerRef = (0, import_react12.useRef)();
|
|
2303
2319
|
const abortSuggestions = () => {
|
|
2304
|
-
var
|
|
2305
|
-
(
|
|
2320
|
+
var _a2;
|
|
2321
|
+
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2306
2322
|
suggestionsAbortControllerRef.current = null;
|
|
2307
2323
|
};
|
|
2308
2324
|
const generalContext = (0, import_react_core8.useCopilotContext)();
|
|
@@ -2328,7 +2344,13 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2328
2344
|
return () => {
|
|
2329
2345
|
clearTimeout(debounceTimerRef.current);
|
|
2330
2346
|
};
|
|
2331
|
-
}, [
|
|
2347
|
+
}, [
|
|
2348
|
+
isLoading,
|
|
2349
|
+
context.chatSuggestionConfiguration,
|
|
2350
|
+
// hackish way to trigger suggestions reload on reset, but better than moving suggestions to the
|
|
2351
|
+
// global context
|
|
2352
|
+
visibleMessages.length == 0
|
|
2353
|
+
]);
|
|
2332
2354
|
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2333
2355
|
abortSuggestions();
|
|
2334
2356
|
setCurrentSuggestions([]);
|
|
@@ -2346,6 +2368,79 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) =>
|
|
|
2346
2368
|
appendMessage(message);
|
|
2347
2369
|
return message;
|
|
2348
2370
|
});
|
|
2371
|
+
const messages = visibleMessages;
|
|
2372
|
+
const { setMessages } = messagesContext;
|
|
2373
|
+
const currentAgentName = (_a = generalContext.agentSession) == null ? void 0 : _a.agentName;
|
|
2374
|
+
const restartCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2375
|
+
if (generalContext.agentSession) {
|
|
2376
|
+
generalContext.setAgentSession(__spreadProps(__spreadValues({}, generalContext.agentSession), {
|
|
2377
|
+
nodeName: void 0,
|
|
2378
|
+
threadId: void 0
|
|
2379
|
+
}));
|
|
2380
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2381
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2382
|
+
[generalContext.agentSession.agentName]: __spreadProps(__spreadValues({}, prevAgentStates[generalContext.agentSession.agentName]), {
|
|
2383
|
+
threadId: void 0,
|
|
2384
|
+
nodeName: void 0,
|
|
2385
|
+
runId: void 0
|
|
2386
|
+
})
|
|
2387
|
+
});
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
});
|
|
2391
|
+
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2392
|
+
if (generalContext.agentSession) {
|
|
2393
|
+
yield (0, import_react_core9.runAgent)(generalContext.agentSession.agentName, context, appendMessage, hint);
|
|
2394
|
+
}
|
|
2395
|
+
});
|
|
2396
|
+
const stopCurrentAgent = () => {
|
|
2397
|
+
if (generalContext.agentSession) {
|
|
2398
|
+
(0, import_react_core9.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2399
|
+
}
|
|
2400
|
+
};
|
|
2401
|
+
const setCurrentAgentState = (state) => {
|
|
2402
|
+
if (generalContext.agentSession) {
|
|
2403
|
+
generalContext.setCoagentStates((prevAgentStates) => {
|
|
2404
|
+
return __spreadProps(__spreadValues({}, prevAgentStates), {
|
|
2405
|
+
[generalContext.agentSession.agentName]: {
|
|
2406
|
+
state
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
function stopGeneration() {
|
|
2413
|
+
if (onStopGeneration) {
|
|
2414
|
+
onStopGeneration({
|
|
2415
|
+
messages,
|
|
2416
|
+
setMessages,
|
|
2417
|
+
stopGeneration: defaultStopGeneration,
|
|
2418
|
+
currentAgentName,
|
|
2419
|
+
restartCurrentAgent,
|
|
2420
|
+
stopCurrentAgent,
|
|
2421
|
+
runCurrentAgent,
|
|
2422
|
+
setCurrentAgentState
|
|
2423
|
+
});
|
|
2424
|
+
} else {
|
|
2425
|
+
defaultStopGeneration();
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
function reloadMessages() {
|
|
2429
|
+
if (onReloadMessages) {
|
|
2430
|
+
onReloadMessages({
|
|
2431
|
+
messages,
|
|
2432
|
+
setMessages,
|
|
2433
|
+
stopGeneration: defaultStopGeneration,
|
|
2434
|
+
currentAgentName,
|
|
2435
|
+
restartCurrentAgent,
|
|
2436
|
+
stopCurrentAgent,
|
|
2437
|
+
runCurrentAgent,
|
|
2438
|
+
setCurrentAgentState
|
|
2439
|
+
});
|
|
2440
|
+
} else {
|
|
2441
|
+
defaultReloadMessages();
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2349
2444
|
return {
|
|
2350
2445
|
visibleMessages,
|
|
2351
2446
|
isLoading,
|
|
@@ -2365,6 +2460,8 @@ var CopilotModal = ({
|
|
|
2365
2460
|
hitEscapeToClose = true,
|
|
2366
2461
|
onSetOpen,
|
|
2367
2462
|
onSubmitMessage,
|
|
2463
|
+
onStopGeneration,
|
|
2464
|
+
onReloadMessages,
|
|
2368
2465
|
shortcut = "/",
|
|
2369
2466
|
icons,
|
|
2370
2467
|
labels,
|
|
@@ -2402,6 +2499,8 @@ var CopilotModal = ({
|
|
|
2402
2499
|
{
|
|
2403
2500
|
instructions,
|
|
2404
2501
|
onSubmitMessage,
|
|
2502
|
+
onStopGeneration,
|
|
2503
|
+
onReloadMessages,
|
|
2405
2504
|
makeSystemMessage,
|
|
2406
2505
|
showResponseButton,
|
|
2407
2506
|
onInProgress,
|
|
@@ -2446,7 +2545,7 @@ function CopilotSidebar(props) {
|
|
|
2446
2545
|
|
|
2447
2546
|
// src/hooks/use-copilot-chat-suggestions.tsx
|
|
2448
2547
|
var import_react15 = require("react");
|
|
2449
|
-
var
|
|
2548
|
+
var import_react_core10 = require("@copilotkit/react-core");
|
|
2450
2549
|
var import_shared4 = require("@copilotkit/shared");
|
|
2451
2550
|
function useCopilotChatSuggestions({
|
|
2452
2551
|
instructions,
|
|
@@ -2454,7 +2553,7 @@ function useCopilotChatSuggestions({
|
|
|
2454
2553
|
minSuggestions = 1,
|
|
2455
2554
|
maxSuggestions = 3
|
|
2456
2555
|
}, dependencies = []) {
|
|
2457
|
-
const context = (0,
|
|
2556
|
+
const context = (0, import_react_core10.useCopilotContext)();
|
|
2458
2557
|
(0, import_react15.useEffect)(() => {
|
|
2459
2558
|
const id = (0, import_shared4.randomId)();
|
|
2460
2559
|
context.addChatSuggestionConfiguration(id, {
|