@copilotkit/react-ui 1.8.5-next.0 → 1.8.5-next.2
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 +19 -0
- package/dist/{chunk-GOJ36LAI.mjs → chunk-62QMTKMJ.mjs} +2 -2
- package/dist/{chunk-GOJ36LAI.mjs.map → chunk-62QMTKMJ.mjs.map} +1 -1
- package/dist/{chunk-AENUXMIK.mjs → chunk-GOAED4H6.mjs} +3 -3
- package/dist/{chunk-P7S3E5UW.mjs → chunk-HIORSNVD.mjs} +35 -7
- package/dist/chunk-HIORSNVD.mjs.map +1 -0
- package/dist/chunk-JGMFJZMG.mjs +11 -0
- package/dist/chunk-JGMFJZMG.mjs.map +1 -0
- package/dist/{chunk-4LA24FID.mjs → chunk-SMJ3QQCE.mjs} +2 -2
- package/dist/{chunk-6YTN3554.mjs → chunk-X6EFGEBJ.mjs} +2 -2
- package/dist/{chunk-T2MTGCY3.mjs → chunk-ZLRUNNS7.mjs} +12 -11
- package/dist/chunk-ZLRUNNS7.mjs.map +1 -0
- package/dist/components/chat/Chat.d.ts +8 -3
- package/dist/components/chat/Chat.js +8 -7
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +4 -4
- package/dist/components/chat/Modal.js +74 -39
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +7 -6
- package/dist/components/chat/Popup.js +74 -39
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +8 -7
- package/dist/components/chat/Sidebar.js +74 -39
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +8 -7
- package/dist/components/chat/Window.js +39 -5
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +2 -1
- package/dist/components/chat/index.js +74 -39
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +11 -10
- package/dist/components/chat/messages/AssistantMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderResultMessage.mjs +1 -1
- package/dist/components/chat/messages/RenderTextMessage.js +1 -1
- package/dist/components/chat/messages/RenderTextMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderTextMessage.mjs +2 -2
- package/dist/components/chat/props.d.ts +2 -2
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.js +74 -39
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +11 -10
- package/dist/hooks/use-dark-mode.d.ts +3 -0
- package/dist/hooks/use-dark-mode.js +35 -0
- package/dist/hooks/use-dark-mode.js.map +1 -0
- package/dist/hooks/use-dark-mode.mjs +8 -0
- package/dist/hooks/use-dark-mode.mjs.map +1 -0
- package/dist/index.css +25 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +76 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -10
- package/package.json +6 -6
- package/src/components/chat/Chat.tsx +13 -7
- package/src/components/chat/Window.tsx +26 -1
- package/src/components/chat/messages/RenderTextMessage.tsx +1 -1
- package/src/components/chat/props.ts +2 -2
- package/src/css/input.css +1 -1
- package/src/css/window.css +27 -0
- package/src/hooks/use-dark-mode.ts +10 -0
- package/dist/chunk-P7S3E5UW.mjs.map +0 -1
- package/dist/chunk-T2MTGCY3.mjs.map +0 -1
- /package/dist/{chunk-AENUXMIK.mjs.map → chunk-GOAED4H6.mjs.map} +0 -0
- /package/dist/{chunk-4LA24FID.mjs.map → chunk-SMJ3QQCE.mjs.map} +0 -0
- /package/dist/{chunk-6YTN3554.mjs.map → chunk-X6EFGEBJ.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-GOAED4H6.mjs";
|
|
4
|
+
import "../../chunk-HIORSNVD.mjs";
|
|
5
5
|
import "../../chunk-2OTVZXDX.mjs";
|
|
6
6
|
import "../../chunk-V7W6IM2V.mjs";
|
|
7
7
|
import "../../chunk-D5XIJNXQ.mjs";
|
|
@@ -11,22 +11,23 @@ import "../../chunk-NRA3CFEE.mjs";
|
|
|
11
11
|
import "../../chunk-BH6PCAAL.mjs";
|
|
12
12
|
import "../../chunk-Q5V6S67N.mjs";
|
|
13
13
|
import "../../chunk-YOEL33HG.mjs";
|
|
14
|
-
import "../../chunk-
|
|
14
|
+
import "../../chunk-ZLRUNNS7.mjs";
|
|
15
|
+
import "../../chunk-Q2YY2NX3.mjs";
|
|
15
16
|
import "../../chunk-WNC6OCIB.mjs";
|
|
16
|
-
import "../../chunk-
|
|
17
|
+
import "../../chunk-62QMTKMJ.mjs";
|
|
17
18
|
import "../../chunk-HEIDCT7I.mjs";
|
|
18
19
|
import "../../chunk-NMNC4ROZ.mjs";
|
|
19
|
-
import "../../chunk-Q2YY2NX3.mjs";
|
|
20
20
|
import "../../chunk-5M7ODWKH.mjs";
|
|
21
21
|
import "../../chunk-TOQ7P4DO.mjs";
|
|
22
22
|
import "../../chunk-QJKMOGWN.mjs";
|
|
23
23
|
import "../../chunk-YQFVRDNC.mjs";
|
|
24
24
|
import "../../chunk-XNQO5AZZ.mjs";
|
|
25
|
+
import "../../chunk-PCTCOQK2.mjs";
|
|
25
26
|
import "../../chunk-ZY25LVYR.mjs";
|
|
26
27
|
import "../../chunk-UN2E3HCK.mjs";
|
|
27
|
-
import "../../chunk-PCTCOQK2.mjs";
|
|
28
28
|
import "../../chunk-ORSMX3SE.mjs";
|
|
29
29
|
import "../../chunk-54JAUBUJ.mjs";
|
|
30
|
+
import "../../chunk-JGMFJZMG.mjs";
|
|
30
31
|
import "../../chunk-S5MBUNGN.mjs";
|
|
31
32
|
import "../../chunk-MRXNTQOX.mjs";
|
|
32
33
|
export {
|
|
@@ -383,6 +383,16 @@ var ChatContextProvider = ({
|
|
|
383
383
|
|
|
384
384
|
// src/components/chat/Window.tsx
|
|
385
385
|
var import_react2 = __toESM(require("react"));
|
|
386
|
+
var import_react_core = require("@copilotkit/react-core");
|
|
387
|
+
|
|
388
|
+
// src/hooks/use-dark-mode.ts
|
|
389
|
+
var useDarkMode = () => {
|
|
390
|
+
if (typeof window === "undefined")
|
|
391
|
+
return false;
|
|
392
|
+
return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
// src/components/chat/Window.tsx
|
|
386
396
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
387
397
|
var Window = ({
|
|
388
398
|
children,
|
|
@@ -390,15 +400,17 @@ var Window = ({
|
|
|
390
400
|
shortcut,
|
|
391
401
|
hitEscapeToClose
|
|
392
402
|
}) => {
|
|
403
|
+
var _a;
|
|
393
404
|
const windowRef = import_react2.default.useRef(null);
|
|
405
|
+
const context = (0, import_react_core.useCopilotContext)();
|
|
394
406
|
const { open, setOpen } = useChatContext();
|
|
395
407
|
const handleClickOutside = (0, import_react2.useCallback)(
|
|
396
408
|
(event) => {
|
|
397
|
-
var
|
|
409
|
+
var _a2;
|
|
398
410
|
if (!clickOutsideToClose) {
|
|
399
411
|
return;
|
|
400
412
|
}
|
|
401
|
-
const parentElement = (
|
|
413
|
+
const parentElement = (_a2 = windowRef.current) == null ? void 0 : _a2.parentElement;
|
|
402
414
|
let className = "";
|
|
403
415
|
if (event.target instanceof HTMLElement) {
|
|
404
416
|
className = event.target.className;
|
|
@@ -412,10 +424,10 @@ var Window = ({
|
|
|
412
424
|
);
|
|
413
425
|
const handleKeyDown = (0, import_react2.useCallback)(
|
|
414
426
|
(event) => {
|
|
415
|
-
var
|
|
427
|
+
var _a2;
|
|
416
428
|
const target = event.target;
|
|
417
429
|
const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
|
|
418
|
-
const isDescendantOfWrapper = (
|
|
430
|
+
const isDescendantOfWrapper = (_a2 = windowRef.current) == null ? void 0 : _a2.contains(target);
|
|
419
431
|
if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
|
|
420
432
|
setOpen(false);
|
|
421
433
|
} else if (event.key === shortcut && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
|
|
@@ -470,7 +482,29 @@ var Window = ({
|
|
|
470
482
|
}
|
|
471
483
|
};
|
|
472
484
|
}, [adjustForMobile, handleClickOutside, handleKeyDown]);
|
|
473
|
-
|
|
485
|
+
const isDark = useDarkMode();
|
|
486
|
+
const showPoweredBy = !((_a = context.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
487
|
+
const poweredByStyle = {
|
|
488
|
+
visibility: "visible",
|
|
489
|
+
display: "block",
|
|
490
|
+
position: "static",
|
|
491
|
+
textAlign: "center",
|
|
492
|
+
fontSize: "12px",
|
|
493
|
+
padding: "3px 0",
|
|
494
|
+
color: isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
|
|
495
|
+
};
|
|
496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
className: `copilotKitWindow ${showPoweredBy ? " poweredByContainer" : ""} ${open ? " open" : ""}`,
|
|
500
|
+
ref: windowRef,
|
|
501
|
+
children: [
|
|
502
|
+
children,
|
|
503
|
+
showPoweredBy && // @ts-expect-error -- expecting position not to be a string, but it can be.
|
|
504
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" })
|
|
505
|
+
]
|
|
506
|
+
}
|
|
507
|
+
);
|
|
474
508
|
};
|
|
475
509
|
var preventScroll = (event) => {
|
|
476
510
|
let targetElement = event.target;
|
|
@@ -509,7 +543,7 @@ var Button = ({}) => {
|
|
|
509
543
|
};
|
|
510
544
|
|
|
511
545
|
// src/components/dev-console/utils.ts
|
|
512
|
-
var
|
|
546
|
+
var import_react_core2 = require("@copilotkit/react-core");
|
|
513
547
|
function shouldShowDevConsole(showDevConsole) {
|
|
514
548
|
if (typeof showDevConsole === "boolean") {
|
|
515
549
|
return showDevConsole;
|
|
@@ -571,7 +605,7 @@ function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
|
571
605
|
}
|
|
572
606
|
function logReadables(context) {
|
|
573
607
|
console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
|
|
574
|
-
const readables = context.getContextString([],
|
|
608
|
+
const readables = context.getContextString([], import_react_core2.defaultCopilotContextCategories).trim();
|
|
575
609
|
if (readables.length === 0) {
|
|
576
610
|
console.log("No readables found");
|
|
577
611
|
return;
|
|
@@ -641,7 +675,7 @@ function logMessages(context) {
|
|
|
641
675
|
}
|
|
642
676
|
|
|
643
677
|
// src/components/dev-console/console.tsx
|
|
644
|
-
var
|
|
678
|
+
var import_react_core3 = require("@copilotkit/react-core");
|
|
645
679
|
var import_react4 = require("react");
|
|
646
680
|
|
|
647
681
|
// src/components/dev-console/icons.tsx
|
|
@@ -831,7 +865,7 @@ function CopilotKitHelpModal() {
|
|
|
831
865
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
832
866
|
function CopilotDevConsole() {
|
|
833
867
|
const currentVersion = import_shared.COPILOTKIT_VERSION;
|
|
834
|
-
const context = (0,
|
|
868
|
+
const context = (0, import_react_core3.useCopilotContext)();
|
|
835
869
|
const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
|
|
836
870
|
(0, import_react4.useEffect)(() => {
|
|
837
871
|
setShowDevConsole(shouldShowDevConsole(context.showDevConsole));
|
|
@@ -962,8 +996,8 @@ function DebugMenuButton({
|
|
|
962
996
|
checkForUpdates,
|
|
963
997
|
mode
|
|
964
998
|
}) {
|
|
965
|
-
const context = (0,
|
|
966
|
-
const messagesContext = (0,
|
|
999
|
+
const context = (0, import_react_core3.useCopilotContext)();
|
|
1000
|
+
const messagesContext = (0, import_react_core3.useCopilotMessagesContext)();
|
|
967
1001
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
|
|
968
1002
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
969
1003
|
import_react5.MenuButton,
|
|
@@ -1026,7 +1060,7 @@ var Header = ({}) => {
|
|
|
1026
1060
|
// src/components/chat/Messages.tsx
|
|
1027
1061
|
var import_react6 = require("react");
|
|
1028
1062
|
var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
|
|
1029
|
-
var
|
|
1063
|
+
var import_react_core4 = require("@copilotkit/react-core");
|
|
1030
1064
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1031
1065
|
var Messages = ({
|
|
1032
1066
|
messages,
|
|
@@ -1062,7 +1096,7 @@ var Messages = ({
|
|
|
1062
1096
|
}
|
|
1063
1097
|
}
|
|
1064
1098
|
const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
|
|
1065
|
-
const interrupt = (0,
|
|
1099
|
+
const interrupt = (0, import_react_core4.useLangGraphInterruptRender)();
|
|
1066
1100
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
|
|
1067
1101
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessagesContainer", children: [
|
|
1068
1102
|
messages.map((message, index) => {
|
|
@@ -1260,7 +1294,7 @@ var AutoResizingTextarea = (0, import_react7.forwardRef)(
|
|
|
1260
1294
|
var Textarea_default = AutoResizingTextarea;
|
|
1261
1295
|
|
|
1262
1296
|
// src/hooks/use-push-to-talk.tsx
|
|
1263
|
-
var
|
|
1297
|
+
var import_react_core5 = require("@copilotkit/react-core");
|
|
1264
1298
|
var import_react8 = require("react");
|
|
1265
1299
|
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
1266
1300
|
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
@@ -1315,8 +1349,8 @@ var usePushToTalk = ({
|
|
|
1315
1349
|
const audioContextRef = (0, import_react8.useRef)(null);
|
|
1316
1350
|
const mediaRecorderRef = (0, import_react8.useRef)(null);
|
|
1317
1351
|
const recordedChunks = (0, import_react8.useRef)([]);
|
|
1318
|
-
const generalContext = (0,
|
|
1319
|
-
const messagesContext = (0,
|
|
1352
|
+
const generalContext = (0, import_react_core5.useCopilotContext)();
|
|
1353
|
+
const messagesContext = (0, import_react_core5.useCopilotMessagesContext)();
|
|
1320
1354
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
1321
1355
|
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
|
|
1322
1356
|
(0, import_react8.useEffect)(() => {
|
|
@@ -1364,11 +1398,11 @@ var usePushToTalk = ({
|
|
|
1364
1398
|
};
|
|
1365
1399
|
|
|
1366
1400
|
// src/components/chat/Input.tsx
|
|
1367
|
-
var
|
|
1401
|
+
var import_react_core6 = require("@copilotkit/react-core");
|
|
1368
1402
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1369
1403
|
var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
1370
1404
|
const context = useChatContext();
|
|
1371
|
-
const copilotContext = (0,
|
|
1405
|
+
const copilotContext = (0, import_react_core6.useCopilotContext)();
|
|
1372
1406
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1373
1407
|
const textareaRef = (0, import_react9.useRef)(null);
|
|
1374
1408
|
const handleDivClick = (event) => {
|
|
@@ -2061,7 +2095,7 @@ function RenderTextMessage(_a) {
|
|
|
2061
2095
|
isLoading: inProgress && isCurrentMessage && !message.content,
|
|
2062
2096
|
isGenerating: inProgress && isCurrentMessage && !!message.content,
|
|
2063
2097
|
isCurrentMessage,
|
|
2064
|
-
onRegenerate,
|
|
2098
|
+
onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
|
|
2065
2099
|
onCopy,
|
|
2066
2100
|
onThumbsUp,
|
|
2067
2101
|
onThumbsDown
|
|
@@ -2074,7 +2108,7 @@ function RenderTextMessage(_a) {
|
|
|
2074
2108
|
|
|
2075
2109
|
// src/components/chat/messages/RenderActionExecutionMessage.tsx
|
|
2076
2110
|
var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
|
|
2077
|
-
var
|
|
2111
|
+
var import_react_core7 = require("@copilotkit/react-core");
|
|
2078
2112
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2079
2113
|
function RenderActionExecutionMessage(_a) {
|
|
2080
2114
|
var _b = _a, {
|
|
@@ -2082,7 +2116,7 @@ function RenderActionExecutionMessage(_a) {
|
|
|
2082
2116
|
} = _b, props = __objRest(_b, [
|
|
2083
2117
|
"AssistantMessage"
|
|
2084
2118
|
]);
|
|
2085
|
-
const { chatComponentsCache } = (0,
|
|
2119
|
+
const { chatComponentsCache } = (0, import_react_core7.useCopilotContext)();
|
|
2086
2120
|
const { message, inProgress, index, isCurrentMessage, actionResult } = props;
|
|
2087
2121
|
if (message.isActionExecutionMessage()) {
|
|
2088
2122
|
if (chatComponentsCache.current !== null && (chatComponentsCache.current.actions[message.name] || chatComponentsCache.current.actions["*"])) {
|
|
@@ -2211,7 +2245,7 @@ function RenderResultMessage(_a) {
|
|
|
2211
2245
|
}
|
|
2212
2246
|
|
|
2213
2247
|
// src/components/chat/messages/RenderAgentStateMessage.tsx
|
|
2214
|
-
var
|
|
2248
|
+
var import_react_core8 = require("@copilotkit/react-core");
|
|
2215
2249
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2216
2250
|
function RenderAgentStateMessage(_a) {
|
|
2217
2251
|
var _b = _a, {
|
|
@@ -2219,7 +2253,7 @@ function RenderAgentStateMessage(_a) {
|
|
|
2219
2253
|
} = _b, props = __objRest(_b, [
|
|
2220
2254
|
"AssistantMessage"
|
|
2221
2255
|
]);
|
|
2222
|
-
const { chatComponentsCache } = (0,
|
|
2256
|
+
const { chatComponentsCache } = (0, import_react_core8.useCopilotContext)();
|
|
2223
2257
|
const { message, inProgress, index, isCurrentMessage } = props;
|
|
2224
2258
|
if (message.isAgentStateMessage()) {
|
|
2225
2259
|
let render;
|
|
@@ -2312,7 +2346,7 @@ function RenderAgentStateMessage(_a) {
|
|
|
2312
2346
|
}
|
|
2313
2347
|
|
|
2314
2348
|
// src/components/chat/Suggestion.tsx
|
|
2315
|
-
var
|
|
2349
|
+
var import_react_core9 = require("@copilotkit/react-core");
|
|
2316
2350
|
var import_shared2 = require("@copilotkit/shared");
|
|
2317
2351
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
2318
2352
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
@@ -2344,7 +2378,7 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
2344
2378
|
for (const config of Object.values(chatSuggestionConfiguration)) {
|
|
2345
2379
|
try {
|
|
2346
2380
|
const numOfSuggestionsInstructions = config.minSuggestions === 0 ? `Produce up to ${config.maxSuggestions} suggestions. If there are no highly relevant suggestions you can think of, provide an empty array.` : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
|
|
2347
|
-
const result = yield (0,
|
|
2381
|
+
const result = yield (0, import_react_core9.extract)({
|
|
2348
2382
|
context,
|
|
2349
2383
|
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. ",
|
|
2350
2384
|
data: config.instructions + "\n\n" + numOfSuggestionsInstructions + "\n\nAvailable tools: " + tools + "\n\n",
|
|
@@ -2403,10 +2437,10 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
2403
2437
|
|
|
2404
2438
|
// src/components/chat/Chat.tsx
|
|
2405
2439
|
var import_react13 = __toESM(require("react"));
|
|
2406
|
-
var
|
|
2440
|
+
var import_react_core10 = require("@copilotkit/react-core");
|
|
2407
2441
|
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
2408
2442
|
var import_shared3 = require("@copilotkit/shared");
|
|
2409
|
-
var
|
|
2443
|
+
var import_react_core11 = require("@copilotkit/react-core");
|
|
2410
2444
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2411
2445
|
function CopilotChat({
|
|
2412
2446
|
instructions,
|
|
@@ -2431,7 +2465,7 @@ function CopilotChat({
|
|
|
2431
2465
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2432
2466
|
UserMessage: UserMessage2 = UserMessage
|
|
2433
2467
|
}) {
|
|
2434
|
-
const { additionalInstructions, setChatInstructions } = (0,
|
|
2468
|
+
const { additionalInstructions, setChatInstructions } = (0, import_react_core10.useCopilotContext)();
|
|
2435
2469
|
(0, import_react13.useEffect)(() => {
|
|
2436
2470
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2437
2471
|
setChatInstructions(instructions || "");
|
|
@@ -2461,11 +2495,11 @@ function CopilotChat({
|
|
|
2461
2495
|
);
|
|
2462
2496
|
const chatContext = import_react13.default.useContext(ChatContext);
|
|
2463
2497
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2464
|
-
const handleRegenerate = () => {
|
|
2498
|
+
const handleRegenerate = (messageId) => {
|
|
2465
2499
|
if (onRegenerate) {
|
|
2466
|
-
onRegenerate();
|
|
2500
|
+
onRegenerate(messageId);
|
|
2467
2501
|
}
|
|
2468
|
-
reloadMessages();
|
|
2502
|
+
reloadMessages(messageId);
|
|
2469
2503
|
};
|
|
2470
2504
|
const handleCopy = (message) => {
|
|
2471
2505
|
if (onCopy) {
|
|
@@ -2535,7 +2569,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2535
2569
|
stopGeneration: defaultStopGeneration,
|
|
2536
2570
|
runChatCompletion,
|
|
2537
2571
|
isLoading
|
|
2538
|
-
} = (0,
|
|
2572
|
+
} = (0, import_react_core10.useCopilotChat)({
|
|
2539
2573
|
id: (0, import_shared3.randomId)(),
|
|
2540
2574
|
makeSystemMessage
|
|
2541
2575
|
});
|
|
@@ -2547,8 +2581,8 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2547
2581
|
(_a2 = suggestionsAbortControllerRef.current) == null ? void 0 : _a2.abort();
|
|
2548
2582
|
suggestionsAbortControllerRef.current = null;
|
|
2549
2583
|
};
|
|
2550
|
-
const generalContext = (0,
|
|
2551
|
-
const messagesContext = (0,
|
|
2584
|
+
const generalContext = (0, import_react_core10.useCopilotContext)();
|
|
2585
|
+
const messagesContext = (0, import_react_core10.useCopilotMessagesContext)();
|
|
2552
2586
|
const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
|
|
2553
2587
|
(0, import_react13.useEffect)(() => {
|
|
2554
2588
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
@@ -2616,7 +2650,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2616
2650
|
});
|
|
2617
2651
|
const runCurrentAgent = (hint) => __async(void 0, null, function* () {
|
|
2618
2652
|
if (generalContext.agentSession) {
|
|
2619
|
-
yield (0,
|
|
2653
|
+
yield (0, import_react_core11.runAgent)(
|
|
2620
2654
|
generalContext.agentSession.agentName,
|
|
2621
2655
|
context,
|
|
2622
2656
|
appendMessage,
|
|
@@ -2627,7 +2661,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2627
2661
|
});
|
|
2628
2662
|
const stopCurrentAgent = () => {
|
|
2629
2663
|
if (generalContext.agentSession) {
|
|
2630
|
-
(0,
|
|
2664
|
+
(0, import_react_core11.stopAgent)(generalContext.agentSession.agentName, context);
|
|
2631
2665
|
}
|
|
2632
2666
|
};
|
|
2633
2667
|
const setCurrentAgentState = (state) => {
|
|
@@ -2657,7 +2691,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2657
2691
|
defaultStopGeneration();
|
|
2658
2692
|
}
|
|
2659
2693
|
}
|
|
2660
|
-
function reloadMessages() {
|
|
2694
|
+
function reloadMessages(messageId) {
|
|
2661
2695
|
if (onReloadMessages) {
|
|
2662
2696
|
onReloadMessages({
|
|
2663
2697
|
messages,
|
|
@@ -2667,10 +2701,11 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2667
2701
|
restartCurrentAgent,
|
|
2668
2702
|
stopCurrentAgent,
|
|
2669
2703
|
runCurrentAgent,
|
|
2670
|
-
setCurrentAgentState
|
|
2704
|
+
setCurrentAgentState,
|
|
2705
|
+
messageId
|
|
2671
2706
|
});
|
|
2672
2707
|
} else {
|
|
2673
|
-
defaultReloadMessages();
|
|
2708
|
+
defaultReloadMessages(messageId);
|
|
2674
2709
|
}
|
|
2675
2710
|
}
|
|
2676
2711
|
return {
|