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