@copilotkit/react-ui 1.10.4-next.2 → 1.10.4
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 +23 -0
- package/dist/{chunk-KCRWXHWT.mjs → chunk-DII7M2HW.mjs} +2 -2
- package/dist/{chunk-FJFWH5AF.mjs → chunk-GKIR7J5D.mjs} +7 -7
- package/dist/{chunk-PHH6DYUW.mjs → chunk-NGA4T3VT.mjs} +3 -3
- package/dist/chunk-NGA4T3VT.mjs.map +1 -0
- package/dist/{chunk-Z66Y3KRE.mjs → chunk-NJY6RHHQ.mjs} +8 -11
- package/dist/chunk-NJY6RHHQ.mjs.map +1 -0
- package/dist/{chunk-YO63WHVQ.mjs → chunk-SP2PFXCH.mjs} +2 -2
- package/dist/{chunk-QQDCZRPA.mjs → chunk-TNN2ZGO6.mjs} +2 -2
- package/dist/{chunk-GDSZGYCE.mjs → chunk-V6DDX4LH.mjs} +2 -2
- package/dist/{chunk-FFJHOZX6.mjs → chunk-WBPBTTQD.mjs} +4 -4
- package/dist/{chunk-LJAYSRCB.mjs → chunk-WRQST6DJ.mjs} +4 -4
- package/dist/components/chat/Chat.js +47 -99
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +5 -6
- package/dist/components/chat/Header.mjs +4 -4
- package/dist/components/chat/Messages.js +1 -1
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +4 -4
- package/dist/components/chat/Modal.js +61 -113
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +10 -11
- package/dist/components/chat/Popup.js +63 -115
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +11 -12
- package/dist/components/chat/Sidebar.js +65 -117
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +11 -12
- package/dist/components/chat/index.js +67 -119
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +14 -15
- package/dist/components/chat/messages/ErrorMessage.mjs +57 -4
- package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +3 -3
- package/dist/components/chat/messages/RenderMessage.mjs +2 -2
- package/dist/components/chat/props.d.ts +1 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.mjs +4 -4
- package/dist/components/index.js +67 -119
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +15 -16
- package/dist/index.js +69 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -16
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +1 -2
- package/src/components/chat/Messages.tsx +1 -1
- package/src/components/chat/props.ts +1 -1
- package/dist/chunk-PHH6DYUW.mjs.map +0 -1
- package/dist/chunk-SRY5COHG.mjs +0 -63
- package/dist/chunk-SRY5COHG.mjs.map +0 -1
- package/dist/chunk-Z66Y3KRE.mjs.map +0 -1
- /package/dist/{chunk-KCRWXHWT.mjs.map → chunk-DII7M2HW.mjs.map} +0 -0
- /package/dist/{chunk-FJFWH5AF.mjs.map → chunk-GKIR7J5D.mjs.map} +0 -0
- /package/dist/{chunk-YO63WHVQ.mjs.map → chunk-SP2PFXCH.mjs.map} +0 -0
- /package/dist/{chunk-QQDCZRPA.mjs.map → chunk-TNN2ZGO6.mjs.map} +0 -0
- /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-V6DDX4LH.mjs.map} +0 -0
- /package/dist/{chunk-FFJHOZX6.mjs.map → chunk-WBPBTTQD.mjs.map} +0 -0
- /package/dist/{chunk-LJAYSRCB.mjs.map → chunk-WRQST6DJ.mjs.map} +0 -0
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-GKIR7J5D.mjs";
|
|
4
4
|
import "../../chunk-C3GSYRC3.mjs";
|
|
5
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-V6DDX4LH.mjs";
|
|
6
6
|
import "../../chunk-V7W6IM2V.mjs";
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-Q5V6S67N.mjs";
|
|
9
|
-
import "../../chunk-JY2CSDKN.mjs";
|
|
7
|
+
import "../../chunk-WBPBTTQD.mjs";
|
|
10
8
|
import "../../chunk-KXE2JCUH.mjs";
|
|
11
9
|
import "../../chunk-NRA3CFEE.mjs";
|
|
12
10
|
import "../../chunk-BH6PCAAL.mjs";
|
|
11
|
+
import "../../chunk-Q5V6S67N.mjs";
|
|
12
|
+
import "../../chunk-JY2CSDKN.mjs";
|
|
13
13
|
import "../../chunk-UFN2VWSR.mjs";
|
|
14
|
-
import "../../chunk-
|
|
15
|
-
import "../../chunk-SRY5COHG.mjs";
|
|
14
|
+
import "../../chunk-NJY6RHHQ.mjs";
|
|
16
15
|
import "../../chunk-226ZMOE3.mjs";
|
|
17
16
|
import "../../chunk-W26XFBEG.mjs";
|
|
18
17
|
import "../../chunk-PLHTVHUW.mjs";
|
|
19
18
|
import "../../chunk-DTRPPNSA.mjs";
|
|
20
19
|
import "../../chunk-CGEAG65D.mjs";
|
|
21
20
|
import "../../chunk-QIOJXTIQ.mjs";
|
|
22
|
-
import "../../chunk-
|
|
23
|
-
import "../../chunk-
|
|
24
|
-
import "../../chunk-
|
|
21
|
+
import "../../chunk-NGA4T3VT.mjs";
|
|
22
|
+
import "../../chunk-SP2PFXCH.mjs";
|
|
23
|
+
import "../../chunk-WRQST6DJ.mjs";
|
|
24
|
+
import "../../chunk-VVL6JFCJ.mjs";
|
|
25
25
|
import "../../chunk-X477GDGZ.mjs";
|
|
26
26
|
import "../../chunk-DBKRAOH7.mjs";
|
|
27
|
-
import "../../chunk-VVL6JFCJ.mjs";
|
|
28
27
|
import "../../chunk-SNFHUE5S.mjs";
|
|
29
28
|
import "../../chunk-IEMQ2SQW.mjs";
|
|
30
29
|
import "../../chunk-B5IFB5YJ.mjs";
|
|
@@ -84,7 +84,7 @@ __export(Popup_exports, {
|
|
|
84
84
|
module.exports = __toCommonJS(Popup_exports);
|
|
85
85
|
|
|
86
86
|
// src/components/chat/Modal.tsx
|
|
87
|
-
var
|
|
87
|
+
var import_react15 = __toESM(require("react"));
|
|
88
88
|
|
|
89
89
|
// src/components/chat/ChatContext.tsx
|
|
90
90
|
var import_react = __toESM(require("react"));
|
|
@@ -1872,7 +1872,7 @@ var Messages = ({
|
|
|
1872
1872
|
RenderMessage: RenderMessage2,
|
|
1873
1873
|
AssistantMessage: AssistantMessage2,
|
|
1874
1874
|
UserMessage: UserMessage2,
|
|
1875
|
-
ErrorMessage
|
|
1875
|
+
ErrorMessage,
|
|
1876
1876
|
ImageRenderer: ImageRenderer2,
|
|
1877
1877
|
onRegenerate,
|
|
1878
1878
|
onCopy,
|
|
@@ -1941,7 +1941,7 @@ var Messages = ({
|
|
|
1941
1941
|
);
|
|
1942
1942
|
}),
|
|
1943
1943
|
interrupt,
|
|
1944
|
-
chatError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1944
|
+
chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
|
|
1945
1945
|
] }),
|
|
1946
1946
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
|
|
1947
1947
|
] });
|
|
@@ -2324,67 +2324,15 @@ var Input = ({
|
|
|
2324
2324
|
] });
|
|
2325
2325
|
};
|
|
2326
2326
|
|
|
2327
|
-
// src/components/chat/messages/ErrorMessage.tsx
|
|
2328
|
-
var import_react14 = require("react");
|
|
2329
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2330
|
-
var ErrorMessage = (props) => {
|
|
2331
|
-
const { icons, labels } = useChatContext();
|
|
2332
|
-
const { error, onRegenerate, onCopy, isCurrentMessage } = props;
|
|
2333
|
-
const [copied, setCopied] = (0, import_react14.useState)(false);
|
|
2334
|
-
const handleCopy = () => {
|
|
2335
|
-
const content = error.message;
|
|
2336
|
-
if (content && onCopy) {
|
|
2337
|
-
navigator.clipboard.writeText(content);
|
|
2338
|
-
setCopied(true);
|
|
2339
|
-
onCopy(content);
|
|
2340
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2341
|
-
} else if (content) {
|
|
2342
|
-
navigator.clipboard.writeText(content);
|
|
2343
|
-
setCopied(true);
|
|
2344
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
2345
|
-
}
|
|
2346
|
-
};
|
|
2347
|
-
const handleRegenerate = () => {
|
|
2348
|
-
if (onRegenerate)
|
|
2349
|
-
onRegenerate();
|
|
2350
|
-
};
|
|
2351
|
-
console.log(error);
|
|
2352
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
2353
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Markdown, { content: error.message }),
|
|
2354
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`, children: [
|
|
2355
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2356
|
-
"button",
|
|
2357
|
-
{
|
|
2358
|
-
className: "copilotKitMessageControlButton",
|
|
2359
|
-
onClick: handleRegenerate,
|
|
2360
|
-
"aria-label": labels.regenerateResponse,
|
|
2361
|
-
title: labels.regenerateResponse,
|
|
2362
|
-
children: icons.regenerateIcon
|
|
2363
|
-
}
|
|
2364
|
-
),
|
|
2365
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2366
|
-
"button",
|
|
2367
|
-
{
|
|
2368
|
-
className: "copilotKitMessageControlButton",
|
|
2369
|
-
onClick: handleCopy,
|
|
2370
|
-
"aria-label": labels.copyToClipboard,
|
|
2371
|
-
title: labels.copyToClipboard,
|
|
2372
|
-
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
2373
|
-
}
|
|
2374
|
-
)
|
|
2375
|
-
] })
|
|
2376
|
-
] });
|
|
2377
|
-
};
|
|
2378
|
-
|
|
2379
2327
|
// src/components/chat/Chat.tsx
|
|
2380
|
-
var
|
|
2328
|
+
var import_react14 = __toESM(require("react"));
|
|
2381
2329
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2382
2330
|
var import_shared3 = require("@copilotkit/shared");
|
|
2383
2331
|
var import_shared4 = require("@copilotkit/shared");
|
|
2384
2332
|
var import_react_core10 = require("@copilotkit/react-core");
|
|
2385
2333
|
|
|
2386
2334
|
// src/components/chat/ImageUploadQueue.tsx
|
|
2387
|
-
var
|
|
2335
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2388
2336
|
var ImageUploadQueue = ({
|
|
2389
2337
|
images,
|
|
2390
2338
|
onRemoveImage,
|
|
@@ -2392,7 +2340,7 @@ var ImageUploadQueue = ({
|
|
|
2392
2340
|
}) => {
|
|
2393
2341
|
if (images.length === 0)
|
|
2394
2342
|
return null;
|
|
2395
|
-
return /* @__PURE__ */ (0,
|
|
2343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2396
2344
|
"div",
|
|
2397
2345
|
{
|
|
2398
2346
|
className: `copilotKitImageUploadQueue ${className}`,
|
|
@@ -2403,7 +2351,7 @@ var ImageUploadQueue = ({
|
|
|
2403
2351
|
margin: "8px",
|
|
2404
2352
|
padding: "8px"
|
|
2405
2353
|
},
|
|
2406
|
-
children: images.map((image, index) => /* @__PURE__ */ (0,
|
|
2354
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
2407
2355
|
"div",
|
|
2408
2356
|
{
|
|
2409
2357
|
className: "copilotKitImageUploadQueueItem",
|
|
@@ -2416,7 +2364,7 @@ var ImageUploadQueue = ({
|
|
|
2416
2364
|
overflow: "hidden"
|
|
2417
2365
|
},
|
|
2418
2366
|
children: [
|
|
2419
|
-
/* @__PURE__ */ (0,
|
|
2367
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2420
2368
|
"img",
|
|
2421
2369
|
{
|
|
2422
2370
|
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
@@ -2428,7 +2376,7 @@ var ImageUploadQueue = ({
|
|
|
2428
2376
|
}
|
|
2429
2377
|
}
|
|
2430
2378
|
),
|
|
2431
|
-
/* @__PURE__ */ (0,
|
|
2379
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2432
2380
|
"button",
|
|
2433
2381
|
{
|
|
2434
2382
|
onClick: () => onRemoveImage(index),
|
|
@@ -2463,12 +2411,12 @@ var ImageUploadQueue = ({
|
|
|
2463
2411
|
|
|
2464
2412
|
// src/components/chat/Suggestion.tsx
|
|
2465
2413
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
2466
|
-
var
|
|
2414
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2467
2415
|
function Suggestion({ title, onClick, partial, className }) {
|
|
2468
2416
|
if (!title)
|
|
2469
2417
|
return null;
|
|
2470
2418
|
const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
|
|
2471
|
-
return /* @__PURE__ */ (0,
|
|
2419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2472
2420
|
"button",
|
|
2473
2421
|
{
|
|
2474
2422
|
disabled: partial || isLoading,
|
|
@@ -2478,15 +2426,15 @@ function Suggestion({ title, onClick, partial, className }) {
|
|
|
2478
2426
|
},
|
|
2479
2427
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2480
2428
|
"data-test-id": "suggestion",
|
|
2481
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2429
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
|
|
2482
2430
|
}
|
|
2483
2431
|
);
|
|
2484
2432
|
}
|
|
2485
2433
|
|
|
2486
2434
|
// src/components/chat/Suggestions.tsx
|
|
2487
|
-
var
|
|
2435
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2488
2436
|
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
2489
|
-
return /* @__PURE__ */ (0,
|
|
2437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2490
2438
|
Suggestion,
|
|
2491
2439
|
{
|
|
2492
2440
|
title: suggestion.title,
|
|
@@ -2500,7 +2448,7 @@ function Suggestions({ suggestions, onSuggestionClick }) {
|
|
|
2500
2448
|
}
|
|
2501
2449
|
|
|
2502
2450
|
// src/components/chat/Chat.tsx
|
|
2503
|
-
var
|
|
2451
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2504
2452
|
function CopilotChat({
|
|
2505
2453
|
instructions,
|
|
2506
2454
|
suggestions = "auto",
|
|
@@ -2525,7 +2473,7 @@ function CopilotChat({
|
|
|
2525
2473
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2526
2474
|
UserMessage: UserMessage2 = UserMessage,
|
|
2527
2475
|
ImageRenderer: ImageRenderer2 = ImageRenderer,
|
|
2528
|
-
ErrorMessage
|
|
2476
|
+
ErrorMessage,
|
|
2529
2477
|
imageUploadsEnabled,
|
|
2530
2478
|
inputFileAccept = "image/*",
|
|
2531
2479
|
hideStopButton,
|
|
@@ -2548,10 +2496,10 @@ function CopilotChat({
|
|
|
2548
2496
|
removeInternalErrorHandler
|
|
2549
2497
|
} = (0, import_react_core9.useCopilotContext)();
|
|
2550
2498
|
const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
|
|
2551
|
-
const [selectedImages, setSelectedImages] = (0,
|
|
2552
|
-
const [chatError, setChatError] = (0,
|
|
2553
|
-
const fileInputRef = (0,
|
|
2554
|
-
const triggerObservabilityHook = (0,
|
|
2499
|
+
const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
|
|
2500
|
+
const [chatError, setChatError] = (0, import_react14.useState)(null);
|
|
2501
|
+
const fileInputRef = (0, import_react14.useRef)(null);
|
|
2502
|
+
const triggerObservabilityHook = (0, import_react14.useCallback)(
|
|
2555
2503
|
(hookName, ...args) => {
|
|
2556
2504
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
2557
2505
|
observabilityHooks[hookName](...args);
|
|
@@ -2570,7 +2518,7 @@ function CopilotChat({
|
|
|
2570
2518
|
},
|
|
2571
2519
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
2572
2520
|
);
|
|
2573
|
-
const triggerChatError = (0,
|
|
2521
|
+
const triggerChatError = (0, import_react14.useCallback)(
|
|
2574
2522
|
(error, operation, originalError) => {
|
|
2575
2523
|
const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
|
|
2576
2524
|
setChatError({
|
|
@@ -2616,7 +2564,7 @@ function CopilotChat({
|
|
|
2616
2564
|
},
|
|
2617
2565
|
[publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
|
|
2618
2566
|
);
|
|
2619
|
-
(0,
|
|
2567
|
+
(0, import_react14.useEffect)(() => {
|
|
2620
2568
|
const id = "chat-component";
|
|
2621
2569
|
setInternalErrorHandler({
|
|
2622
2570
|
[id]: (error) => {
|
|
@@ -2629,7 +2577,7 @@ function CopilotChat({
|
|
|
2629
2577
|
removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
|
|
2630
2578
|
};
|
|
2631
2579
|
}, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
|
|
2632
|
-
(0,
|
|
2580
|
+
(0, import_react14.useEffect)(() => {
|
|
2633
2581
|
if (!imageUploadsEnabled)
|
|
2634
2582
|
return;
|
|
2635
2583
|
const handlePaste = (e) => __async(this, null, function* () {
|
|
@@ -2675,7 +2623,7 @@ function CopilotChat({
|
|
|
2675
2623
|
document.addEventListener("paste", handlePaste);
|
|
2676
2624
|
return () => document.removeEventListener("paste", handlePaste);
|
|
2677
2625
|
}, [imageUploadsEnabled, triggerChatError]);
|
|
2678
|
-
(0,
|
|
2626
|
+
(0, import_react14.useEffect)(() => {
|
|
2679
2627
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2680
2628
|
setChatInstructions(instructions || "");
|
|
2681
2629
|
return;
|
|
@@ -2703,8 +2651,8 @@ function CopilotChat({
|
|
|
2703
2651
|
onStopGeneration,
|
|
2704
2652
|
onReloadMessages
|
|
2705
2653
|
);
|
|
2706
|
-
const prevIsLoading = (0,
|
|
2707
|
-
(0,
|
|
2654
|
+
const prevIsLoading = (0, import_react14.useRef)(isLoading);
|
|
2655
|
+
(0, import_react14.useEffect)(() => {
|
|
2708
2656
|
if (prevIsLoading.current !== isLoading) {
|
|
2709
2657
|
if (isLoading) {
|
|
2710
2658
|
triggerObservabilityHook("onChatStarted");
|
|
@@ -2723,7 +2671,7 @@ function CopilotChat({
|
|
|
2723
2671
|
triggerObservabilityHook("onMessageSent", text);
|
|
2724
2672
|
return sendMessage(text, images);
|
|
2725
2673
|
};
|
|
2726
|
-
const chatContext =
|
|
2674
|
+
const chatContext = import_react14.default.useContext(ChatContext);
|
|
2727
2675
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2728
2676
|
const handleRegenerate = (messageId) => {
|
|
2729
2677
|
if (onRegenerate) {
|
|
@@ -2785,14 +2733,14 @@ function CopilotChat({
|
|
|
2785
2733
|
}
|
|
2786
2734
|
triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
|
|
2787
2735
|
};
|
|
2788
|
-
return /* @__PURE__ */ (0,
|
|
2736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2789
2737
|
chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
|
|
2790
2738
|
onDismiss: () => setChatError(null),
|
|
2791
2739
|
onRetry: () => {
|
|
2792
2740
|
setChatError(null);
|
|
2793
2741
|
}
|
|
2794
2742
|
})),
|
|
2795
|
-
/* @__PURE__ */ (0,
|
|
2743
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2796
2744
|
Messages2,
|
|
2797
2745
|
{
|
|
2798
2746
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2806,14 +2754,14 @@ function CopilotChat({
|
|
|
2806
2754
|
onThumbsDown: handleThumbsDown,
|
|
2807
2755
|
markdownTagRenderers,
|
|
2808
2756
|
ImageRenderer: ImageRenderer2,
|
|
2809
|
-
ErrorMessage
|
|
2757
|
+
ErrorMessage,
|
|
2810
2758
|
chatError,
|
|
2811
2759
|
RenderTextMessage,
|
|
2812
2760
|
RenderActionExecutionMessage,
|
|
2813
2761
|
RenderAgentStateMessage,
|
|
2814
2762
|
RenderResultMessage,
|
|
2815
2763
|
RenderImageMessage,
|
|
2816
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2764
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2817
2765
|
RenderSuggestionsList,
|
|
2818
2766
|
{
|
|
2819
2767
|
onSuggestionClick: handleSendMessage,
|
|
@@ -2822,9 +2770,9 @@ function CopilotChat({
|
|
|
2822
2770
|
)
|
|
2823
2771
|
}
|
|
2824
2772
|
),
|
|
2825
|
-
imageUploadsEnabled && /* @__PURE__ */ (0,
|
|
2826
|
-
/* @__PURE__ */ (0,
|
|
2827
|
-
/* @__PURE__ */ (0,
|
|
2773
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2774
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2775
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2828
2776
|
"input",
|
|
2829
2777
|
{
|
|
2830
2778
|
type: "file",
|
|
@@ -2836,7 +2784,7 @@ function CopilotChat({
|
|
|
2836
2784
|
}
|
|
2837
2785
|
)
|
|
2838
2786
|
] }),
|
|
2839
|
-
/* @__PURE__ */ (0,
|
|
2787
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2840
2788
|
Input2,
|
|
2841
2789
|
{
|
|
2842
2790
|
inProgress: isLoading,
|
|
@@ -2858,12 +2806,12 @@ function WrappedCopilotChat({
|
|
|
2858
2806
|
labels,
|
|
2859
2807
|
className
|
|
2860
2808
|
}) {
|
|
2861
|
-
const chatContext =
|
|
2809
|
+
const chatContext = import_react14.default.useContext(ChatContext);
|
|
2862
2810
|
if (!chatContext) {
|
|
2863
|
-
return /* @__PURE__ */ (0,
|
|
2864
|
-
}, children: /* @__PURE__ */ (0,
|
|
2811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2812
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
2865
2813
|
}
|
|
2866
|
-
return /* @__PURE__ */ (0,
|
|
2814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
|
|
2867
2815
|
}
|
|
2868
2816
|
var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
2869
2817
|
var _a;
|
|
@@ -2887,15 +2835,15 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2887
2835
|
const generalContext = (0, import_react_core9.useCopilotContext)();
|
|
2888
2836
|
const messagesContext = (0, import_react_core9.useCopilotMessagesContext)();
|
|
2889
2837
|
const { actions } = generalContext;
|
|
2890
|
-
const [suggestionsFailed, setSuggestionsFailed] = (0,
|
|
2891
|
-
const hasGeneratedInitialSuggestions = (0,
|
|
2892
|
-
(0,
|
|
2838
|
+
const [suggestionsFailed, setSuggestionsFailed] = (0, import_react14.useState)(false);
|
|
2839
|
+
const hasGeneratedInitialSuggestions = (0, import_react14.useRef)(false);
|
|
2840
|
+
(0, import_react14.useEffect)(() => {
|
|
2893
2841
|
if (Array.isArray(chatSuggestions)) {
|
|
2894
2842
|
setSuggestions(chatSuggestions);
|
|
2895
2843
|
hasGeneratedInitialSuggestions.current = true;
|
|
2896
2844
|
}
|
|
2897
2845
|
}, [JSON.stringify(chatSuggestions), setSuggestions]);
|
|
2898
|
-
const generateSuggestionsWithErrorHandling = (0,
|
|
2846
|
+
const generateSuggestionsWithErrorHandling = (0, import_react14.useCallback)(
|
|
2899
2847
|
(context) => __async(void 0, null, function* () {
|
|
2900
2848
|
try {
|
|
2901
2849
|
yield generateSuggestions();
|
|
@@ -2906,7 +2854,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2906
2854
|
}),
|
|
2907
2855
|
[generateSuggestions]
|
|
2908
2856
|
);
|
|
2909
|
-
(0,
|
|
2857
|
+
(0, import_react14.useEffect)(() => {
|
|
2910
2858
|
if (chatSuggestions !== "auto" || isLoadingSuggestions || suggestionsFailed) {
|
|
2911
2859
|
return;
|
|
2912
2860
|
}
|
|
@@ -2936,13 +2884,13 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2936
2884
|
// Use stable string instead of object reference
|
|
2937
2885
|
generateSuggestionsWithErrorHandling
|
|
2938
2886
|
]);
|
|
2939
|
-
(0,
|
|
2887
|
+
(0, import_react14.useEffect)(() => {
|
|
2940
2888
|
if (chatSuggestions !== "auto") {
|
|
2941
2889
|
hasGeneratedInitialSuggestions.current = false;
|
|
2942
2890
|
setSuggestionsFailed(false);
|
|
2943
2891
|
}
|
|
2944
2892
|
}, [chatSuggestions]);
|
|
2945
|
-
const stableContext = (0,
|
|
2893
|
+
const stableContext = (0, import_react14.useMemo)(
|
|
2946
2894
|
() => __spreadValues(__spreadValues({}, generalContext), messagesContext),
|
|
2947
2895
|
[
|
|
2948
2896
|
// Only include stable dependencies
|
|
@@ -2951,12 +2899,12 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
2951
2899
|
generalContext.isLoading
|
|
2952
2900
|
]
|
|
2953
2901
|
);
|
|
2954
|
-
const resetSuggestions = (0,
|
|
2902
|
+
const resetSuggestions = (0, import_react14.useCallback)(() => {
|
|
2955
2903
|
resetSuggestionsFromHook();
|
|
2956
2904
|
setSuggestionsFailed(false);
|
|
2957
2905
|
hasGeneratedInitialSuggestions.current = false;
|
|
2958
2906
|
}, [resetSuggestionsFromHook]);
|
|
2959
|
-
(0,
|
|
2907
|
+
(0, import_react14.useEffect)(() => {
|
|
2960
2908
|
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
2961
2909
|
}, [onInProgress, isLoading]);
|
|
2962
2910
|
const safelySendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
@@ -3102,7 +3050,7 @@ var useCopilotChatLogic = (chatSuggestions, makeSystemMessage, disableSystemMess
|
|
|
3102
3050
|
// src/components/chat/Modal.tsx
|
|
3103
3051
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
3104
3052
|
var import_shared5 = require("@copilotkit/shared");
|
|
3105
|
-
var
|
|
3053
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3106
3054
|
var CopilotModalInner = (_a) => {
|
|
3107
3055
|
var _b = _a, {
|
|
3108
3056
|
observabilityHooks,
|
|
@@ -3129,7 +3077,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3129
3077
|
]);
|
|
3130
3078
|
const { copilotApiConfig, setBannerError } = (0, import_react_core11.useCopilotContext)();
|
|
3131
3079
|
const { publicApiKey } = copilotApiConfig;
|
|
3132
|
-
const triggerObservabilityHook = (0,
|
|
3080
|
+
const triggerObservabilityHook = (0, import_react15.useCallback)(
|
|
3133
3081
|
(hookName, ...args) => {
|
|
3134
3082
|
if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
|
|
3135
3083
|
observabilityHooks[hookName](...args);
|
|
@@ -3149,8 +3097,8 @@ var CopilotModalInner = (_a) => {
|
|
|
3149
3097
|
[publicApiKey, observabilityHooks, setBannerError]
|
|
3150
3098
|
);
|
|
3151
3099
|
const { open } = useChatContext();
|
|
3152
|
-
const prevOpen = (0,
|
|
3153
|
-
(0,
|
|
3100
|
+
const prevOpen = (0, import_react15.useRef)(open);
|
|
3101
|
+
(0, import_react15.useEffect)(() => {
|
|
3154
3102
|
if (prevOpen.current !== open) {
|
|
3155
3103
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
3156
3104
|
if (open) {
|
|
@@ -3161,13 +3109,13 @@ var CopilotModalInner = (_a) => {
|
|
|
3161
3109
|
prevOpen.current = open;
|
|
3162
3110
|
}
|
|
3163
3111
|
}, [open, onSetOpen, triggerObservabilityHook]);
|
|
3164
|
-
const memoizedHeader = (0,
|
|
3165
|
-
const memoizedChildren = (0,
|
|
3166
|
-
return /* @__PURE__ */ (0,
|
|
3112
|
+
const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
|
|
3113
|
+
const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
|
|
3114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
3167
3115
|
memoizedChildren,
|
|
3168
|
-
/* @__PURE__ */ (0,
|
|
3169
|
-
/* @__PURE__ */ (0,
|
|
3170
|
-
/* @__PURE__ */ (0,
|
|
3116
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
|
|
3117
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
|
|
3118
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3171
3119
|
Window2,
|
|
3172
3120
|
{
|
|
3173
3121
|
clickOutsideToClose,
|
|
@@ -3175,7 +3123,7 @@ var CopilotModalInner = (_a) => {
|
|
|
3175
3123
|
hitEscapeToClose,
|
|
3176
3124
|
children: [
|
|
3177
3125
|
memoizedHeader,
|
|
3178
|
-
/* @__PURE__ */ (0,
|
|
3126
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
|
|
3179
3127
|
]
|
|
3180
3128
|
}
|
|
3181
3129
|
)
|
|
@@ -3242,8 +3190,8 @@ var CopilotModal = (_a) => {
|
|
|
3242
3190
|
"children",
|
|
3243
3191
|
"observabilityHooks"
|
|
3244
3192
|
]);
|
|
3245
|
-
const [openState, setOpenState] =
|
|
3246
|
-
return /* @__PURE__ */ (0,
|
|
3193
|
+
const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
|
|
3194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3247
3195
|
CopilotModalInner,
|
|
3248
3196
|
__spreadProps(__spreadValues({
|
|
3249
3197
|
observabilityHooks,
|
|
@@ -3277,12 +3225,12 @@ var CopilotModal = (_a) => {
|
|
|
3277
3225
|
};
|
|
3278
3226
|
|
|
3279
3227
|
// src/components/chat/Popup.tsx
|
|
3280
|
-
var
|
|
3228
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3281
3229
|
function CopilotPopup(props) {
|
|
3282
3230
|
props = __spreadProps(__spreadValues({}, props), {
|
|
3283
3231
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
3284
3232
|
});
|
|
3285
|
-
return /* @__PURE__ */ (0,
|
|
3233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
3286
3234
|
}
|
|
3287
3235
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3288
3236
|
0 && (module.exports = {
|