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