@copilotkit/react-ui 1.8.6 → 1.8.7
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-Q2YY2NX3.mjs → chunk-24TDU7MY.mjs} +2 -2
- package/dist/{chunk-XNQO5AZZ.mjs → chunk-ABHUX6T6.mjs} +2 -2
- package/dist/{chunk-QJKMOGWN.mjs → chunk-BDNHZ3GW.mjs} +4 -3
- package/dist/chunk-BDNHZ3GW.mjs.map +1 -0
- package/dist/{chunk-NMNC4ROZ.mjs → chunk-DSQGQJI4.mjs} +2 -2
- package/dist/{chunk-HEIDCT7I.mjs → chunk-HWMFMBJC.mjs} +2 -2
- package/dist/chunk-HWMFMBJC.mjs.map +1 -0
- package/dist/{chunk-UN2E3HCK.mjs → chunk-IEMQ2SQW.mjs} +6 -4
- package/dist/chunk-IEMQ2SQW.mjs.map +1 -0
- package/dist/{chunk-ZY25LVYR.mjs → chunk-IJADIQAR.mjs} +20 -2
- package/dist/chunk-IJADIQAR.mjs.map +1 -0
- package/dist/{chunk-X6EFGEBJ.mjs → chunk-JOL7NS2W.mjs} +2 -2
- package/dist/{chunk-PCTCOQK2.mjs → chunk-KENCH7RN.mjs} +2 -2
- package/dist/{chunk-ZLRUNNS7.mjs → chunk-O34Z4XM2.mjs} +170 -30
- package/dist/chunk-O34Z4XM2.mjs.map +1 -0
- package/dist/{chunk-5M7ODWKH.mjs → chunk-OZXUB3V7.mjs} +3 -3
- package/dist/chunk-PLHTVHUW.mjs +82 -0
- package/dist/chunk-PLHTVHUW.mjs.map +1 -0
- package/dist/{chunk-62QMTKMJ.mjs → chunk-POWCBXRY.mjs} +3 -3
- package/dist/chunk-PXEVB7IK.mjs +1 -0
- package/dist/{chunk-HIORSNVD.mjs → chunk-Q2NFQTCQ.mjs} +2 -2
- package/dist/chunk-SLTG4L62.mjs +78 -0
- package/dist/chunk-SLTG4L62.mjs.map +1 -0
- package/dist/{chunk-SMJ3QQCE.mjs → chunk-T7N77F5Y.mjs} +2 -2
- package/dist/{chunk-YOEL33HG.mjs → chunk-UFN2VWSR.mjs} +2 -2
- package/dist/{chunk-2OTVZXDX.mjs → chunk-UH2UFL5W.mjs} +3 -3
- package/dist/{chunk-D5XIJNXQ.mjs → chunk-VGPQYMKJ.mjs} +8 -8
- package/dist/{chunk-WNC6OCIB.mjs → chunk-XFCMZH2H.mjs} +2 -2
- package/dist/{chunk-ORSMX3SE.mjs → chunk-XWG3L6QC.mjs} +15 -1
- package/dist/{chunk-ORSMX3SE.mjs.map → chunk-XWG3L6QC.mjs.map} +1 -1
- package/dist/{chunk-TOQ7P4DO.mjs → chunk-XZNY26GH.mjs} +2 -2
- package/dist/{chunk-GOAED4H6.mjs → chunk-Y7UO3RPW.mjs} +10 -10
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +3 -3
- package/dist/components/chat/Chat.d.ts +23 -3
- package/dist/components/chat/Chat.js +341 -30
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +16 -14
- package/dist/components/chat/ChatContext.d.ts +5 -0
- package/dist/components/chat/ChatContext.js +15 -1
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +2 -2
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +2 -2
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +5 -5
- package/dist/components/chat/Icons.d.ts +2 -1
- package/dist/components/chat/Icons.js +17 -2
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +5 -3
- package/dist/components/chat/ImageUploadQueue.d.ts +13 -0
- package/dist/components/chat/ImageUploadQueue.js +106 -0
- package/dist/components/chat/ImageUploadQueue.js.map +1 -0
- package/dist/components/chat/ImageUploadQueue.mjs +8 -0
- package/dist/components/chat/ImageUploadQueue.mjs.map +1 -0
- package/dist/components/chat/Input.d.ts +1 -1
- package/dist/components/chat/Input.js +2 -1
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +3 -3
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +3 -3
- package/dist/components/chat/Messages.d.ts +1 -1
- package/dist/components/chat/Messages.js +18 -0
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +3 -3
- package/dist/components/chat/Modal.js +348 -37
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +22 -20
- package/dist/components/chat/Popup.js +350 -39
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +23 -21
- package/dist/components/chat/Sidebar.js +350 -39
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +23 -21
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +2 -2
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +3 -3
- package/dist/components/chat/index.d.ts +1 -0
- package/dist/components/chat/index.js +354 -41
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +30 -25
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +5 -5
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +6 -6
- package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderAgentStateMessage.mjs +6 -6
- package/dist/components/chat/messages/RenderImageMessage.d.ts +7 -0
- package/dist/components/chat/messages/RenderImageMessage.js +774 -0
- package/dist/components/chat/messages/RenderImageMessage.js.map +1 -0
- package/dist/components/chat/messages/RenderImageMessage.mjs +15 -0
- package/dist/components/chat/messages/RenderImageMessage.mjs.map +1 -0
- package/dist/components/chat/messages/RenderResultMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderResultMessage.mjs +6 -6
- 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 +7 -7
- package/dist/components/chat/messages/UserMessage.js +1 -1
- package/dist/components/chat/messages/UserMessage.js.map +1 -1
- package/dist/components/chat/messages/UserMessage.mjs +1 -1
- package/dist/components/chat/props.d.ts +3 -0
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +3 -3
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +3 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +354 -41
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +30 -25
- package/dist/index.d.ts +1 -0
- package/dist/index.js +354 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -25
- package/package.json +6 -6
- package/src/components/chat/Chat.tsx +198 -18
- package/src/components/chat/ChatContext.tsx +7 -0
- package/src/components/chat/Icons.tsx +14 -0
- package/src/components/chat/ImageUploadQueue.tsx +77 -0
- package/src/components/chat/Input.tsx +8 -1
- package/src/components/chat/Messages.tsx +17 -0
- package/src/components/chat/index.tsx +1 -0
- package/src/components/chat/messages/RenderImageMessage.tsx +64 -0
- package/src/components/chat/messages/UserMessage.tsx +5 -1
- package/src/components/chat/props.ts +3 -0
- package/dist/chunk-HEIDCT7I.mjs.map +0 -1
- package/dist/chunk-QJKMOGWN.mjs.map +0 -1
- package/dist/chunk-SQMEPWVT.mjs +0 -1
- package/dist/chunk-UN2E3HCK.mjs.map +0 -1
- package/dist/chunk-ZLRUNNS7.mjs.map +0 -1
- package/dist/chunk-ZY25LVYR.mjs.map +0 -1
- /package/dist/{chunk-Q2YY2NX3.mjs.map → chunk-24TDU7MY.mjs.map} +0 -0
- /package/dist/{chunk-XNQO5AZZ.mjs.map → chunk-ABHUX6T6.mjs.map} +0 -0
- /package/dist/{chunk-NMNC4ROZ.mjs.map → chunk-DSQGQJI4.mjs.map} +0 -0
- /package/dist/{chunk-X6EFGEBJ.mjs.map → chunk-JOL7NS2W.mjs.map} +0 -0
- /package/dist/{chunk-PCTCOQK2.mjs.map → chunk-KENCH7RN.mjs.map} +0 -0
- /package/dist/{chunk-5M7ODWKH.mjs.map → chunk-OZXUB3V7.mjs.map} +0 -0
- /package/dist/{chunk-62QMTKMJ.mjs.map → chunk-POWCBXRY.mjs.map} +0 -0
- /package/dist/{chunk-SQMEPWVT.mjs.map → chunk-PXEVB7IK.mjs.map} +0 -0
- /package/dist/{chunk-HIORSNVD.mjs.map → chunk-Q2NFQTCQ.mjs.map} +0 -0
- /package/dist/{chunk-SMJ3QQCE.mjs.map → chunk-T7N77F5Y.mjs.map} +0 -0
- /package/dist/{chunk-YOEL33HG.mjs.map → chunk-UFN2VWSR.mjs.map} +0 -0
- /package/dist/{chunk-2OTVZXDX.mjs.map → chunk-UH2UFL5W.mjs.map} +0 -0
- /package/dist/{chunk-D5XIJNXQ.mjs.map → chunk-VGPQYMKJ.mjs.map} +0 -0
- /package/dist/{chunk-WNC6OCIB.mjs.map → chunk-XFCMZH2H.mjs.map} +0 -0
- /package/dist/{chunk-TOQ7P4DO.mjs.map → chunk-XZNY26GH.mjs.map} +0 -0
- /package/dist/{chunk-GOAED4H6.mjs.map → chunk-Y7UO3RPW.mjs.map} +0 -0
|
@@ -84,6 +84,7 @@ __export(chat_exports, {
|
|
|
84
84
|
CopilotPopup: () => CopilotPopup,
|
|
85
85
|
CopilotSidebar: () => CopilotSidebar,
|
|
86
86
|
Markdown: () => Markdown,
|
|
87
|
+
RenderImageMessage: () => RenderImageMessage,
|
|
87
88
|
UserMessage: () => UserMessage,
|
|
88
89
|
useChatContext: () => useChatContext
|
|
89
90
|
});
|
|
@@ -306,6 +307,19 @@ var DownloadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
|
306
307
|
)
|
|
307
308
|
}
|
|
308
309
|
);
|
|
310
|
+
var UploadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
311
|
+
"svg",
|
|
312
|
+
{
|
|
313
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
314
|
+
fill: "none",
|
|
315
|
+
viewBox: "0 0 24 24",
|
|
316
|
+
strokeWidth: "1.5",
|
|
317
|
+
stroke: "currentColor",
|
|
318
|
+
width: "24",
|
|
319
|
+
height: "24",
|
|
320
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" })
|
|
321
|
+
}
|
|
322
|
+
);
|
|
309
323
|
var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
310
324
|
"svg",
|
|
311
325
|
{
|
|
@@ -371,7 +385,8 @@ var ChatContextProvider = ({
|
|
|
371
385
|
pushToTalkIcon: MicrophoneIcon,
|
|
372
386
|
copyIcon: CopyIcon,
|
|
373
387
|
thumbsUpIcon: ThumbsUpIcon,
|
|
374
|
-
thumbsDownIcon: ThumbsDownIcon
|
|
388
|
+
thumbsDownIcon: ThumbsDownIcon,
|
|
389
|
+
uploadIcon: UploadIcon
|
|
375
390
|
}), icons),
|
|
376
391
|
[icons]
|
|
377
392
|
);
|
|
@@ -1076,6 +1091,7 @@ var Messages = ({
|
|
|
1076
1091
|
RenderActionExecutionMessage: RenderActionExecutionMessage2,
|
|
1077
1092
|
RenderAgentStateMessage: RenderAgentStateMessage2,
|
|
1078
1093
|
RenderResultMessage: RenderResultMessage2,
|
|
1094
|
+
RenderImageMessage: RenderImageMessage2,
|
|
1079
1095
|
AssistantMessage: AssistantMessage2,
|
|
1080
1096
|
UserMessage: UserMessage2,
|
|
1081
1097
|
onRegenerate,
|
|
@@ -1164,6 +1180,23 @@ var Messages = ({
|
|
|
1164
1180
|
},
|
|
1165
1181
|
index
|
|
1166
1182
|
);
|
|
1183
|
+
} else if (message.isImageMessage && message.isImageMessage()) {
|
|
1184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1185
|
+
RenderImageMessage2,
|
|
1186
|
+
{
|
|
1187
|
+
message,
|
|
1188
|
+
inProgress,
|
|
1189
|
+
index,
|
|
1190
|
+
isCurrentMessage,
|
|
1191
|
+
AssistantMessage: AssistantMessage2,
|
|
1192
|
+
UserMessage: UserMessage2,
|
|
1193
|
+
onRegenerate,
|
|
1194
|
+
onCopy,
|
|
1195
|
+
onThumbsUp,
|
|
1196
|
+
onThumbsDown
|
|
1197
|
+
},
|
|
1198
|
+
index
|
|
1199
|
+
);
|
|
1167
1200
|
}
|
|
1168
1201
|
}),
|
|
1169
1202
|
interrupt
|
|
@@ -1406,7 +1439,7 @@ var usePushToTalk = ({
|
|
|
1406
1439
|
// src/components/chat/Input.tsx
|
|
1407
1440
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
1408
1441
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1409
|
-
var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
1442
|
+
var Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }) => {
|
|
1410
1443
|
const context = useChatContext();
|
|
1411
1444
|
const copilotContext = (0, import_react_core6.useCopilotContext)();
|
|
1412
1445
|
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
@@ -1470,6 +1503,7 @@ var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
|
1470
1503
|
}
|
|
1471
1504
|
),
|
|
1472
1505
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "copilotKitInputControls", children: [
|
|
1506
|
+
onUpload && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
|
|
1473
1507
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { flexGrow: 1 } }),
|
|
1474
1508
|
showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1475
1509
|
"button",
|
|
@@ -1497,7 +1531,7 @@ var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
|
1497
1531
|
// src/components/chat/messages/UserMessage.tsx
|
|
1498
1532
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1499
1533
|
var UserMessage = (props) => {
|
|
1500
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: props.message });
|
|
1534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: props.subComponent || props.message });
|
|
1501
1535
|
};
|
|
1502
1536
|
|
|
1503
1537
|
// src/components/chat/Markdown.tsx
|
|
@@ -2351,13 +2385,77 @@ function RenderAgentStateMessage(_a) {
|
|
|
2351
2385
|
}
|
|
2352
2386
|
}
|
|
2353
2387
|
|
|
2388
|
+
// src/components/chat/messages/RenderImageMessage.tsx
|
|
2389
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2390
|
+
function RenderImageMessage(_a) {
|
|
2391
|
+
var _b = _a, {
|
|
2392
|
+
UserMessage: UserMessage2 = UserMessage,
|
|
2393
|
+
AssistantMessage: AssistantMessage2 = AssistantMessage
|
|
2394
|
+
} = _b, props = __objRest(_b, [
|
|
2395
|
+
"UserMessage",
|
|
2396
|
+
"AssistantMessage"
|
|
2397
|
+
]);
|
|
2398
|
+
const {
|
|
2399
|
+
message,
|
|
2400
|
+
inProgress,
|
|
2401
|
+
index,
|
|
2402
|
+
isCurrentMessage,
|
|
2403
|
+
onRegenerate,
|
|
2404
|
+
onCopy,
|
|
2405
|
+
onThumbsUp,
|
|
2406
|
+
onThumbsDown
|
|
2407
|
+
} = props;
|
|
2408
|
+
if (message.isImageMessage()) {
|
|
2409
|
+
const imageData = `data:${message.format};base64,${message.bytes}`;
|
|
2410
|
+
const imageComponent = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "copilotKitImage", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2411
|
+
"img",
|
|
2412
|
+
{
|
|
2413
|
+
src: imageData,
|
|
2414
|
+
alt: "User uploaded image",
|
|
2415
|
+
style: { maxWidth: "100%", maxHeight: "300px", borderRadius: "8px" }
|
|
2416
|
+
}
|
|
2417
|
+
) });
|
|
2418
|
+
if (message.role === "user") {
|
|
2419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2420
|
+
UserMessage2,
|
|
2421
|
+
{
|
|
2422
|
+
"data-message-role": "user",
|
|
2423
|
+
message: "",
|
|
2424
|
+
rawData: message,
|
|
2425
|
+
subComponent: imageComponent
|
|
2426
|
+
},
|
|
2427
|
+
index
|
|
2428
|
+
);
|
|
2429
|
+
} else if (message.role === "assistant") {
|
|
2430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2431
|
+
AssistantMessage2,
|
|
2432
|
+
{
|
|
2433
|
+
"data-message-role": "assistant",
|
|
2434
|
+
message: "",
|
|
2435
|
+
rawData: message,
|
|
2436
|
+
subComponent: imageComponent,
|
|
2437
|
+
isLoading: inProgress && isCurrentMessage && !message.bytes,
|
|
2438
|
+
isGenerating: inProgress && isCurrentMessage && !!message.bytes,
|
|
2439
|
+
isCurrentMessage,
|
|
2440
|
+
onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
|
|
2441
|
+
onCopy,
|
|
2442
|
+
onThumbsUp,
|
|
2443
|
+
onThumbsDown
|
|
2444
|
+
},
|
|
2445
|
+
index
|
|
2446
|
+
);
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
return null;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2354
2452
|
// src/components/chat/Suggestion.tsx
|
|
2355
2453
|
var import_react_core9 = require("@copilotkit/react-core");
|
|
2356
2454
|
var import_shared2 = require("@copilotkit/shared");
|
|
2357
2455
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
2358
|
-
var
|
|
2456
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2359
2457
|
function Suggestion({ title, message, onClick, partial, className }) {
|
|
2360
|
-
return /* @__PURE__ */ (0,
|
|
2458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
2361
2459
|
"button",
|
|
2362
2460
|
{
|
|
2363
2461
|
disabled: partial,
|
|
@@ -2367,7 +2465,7 @@ function Suggestion({ title, message, onClick, partial, className }) {
|
|
|
2367
2465
|
},
|
|
2368
2466
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
2369
2467
|
"data-test-id": "suggestion",
|
|
2370
|
-
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0,
|
|
2468
|
+
children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
|
|
2371
2469
|
}
|
|
2372
2470
|
);
|
|
2373
2471
|
}
|
|
@@ -2447,7 +2545,87 @@ var import_react_core10 = require("@copilotkit/react-core");
|
|
|
2447
2545
|
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
2448
2546
|
var import_shared3 = require("@copilotkit/shared");
|
|
2449
2547
|
var import_react_core11 = require("@copilotkit/react-core");
|
|
2450
|
-
|
|
2548
|
+
|
|
2549
|
+
// src/components/chat/ImageUploadQueue.tsx
|
|
2550
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2551
|
+
var ImageUploadQueue = ({
|
|
2552
|
+
images,
|
|
2553
|
+
onRemoveImage,
|
|
2554
|
+
className = ""
|
|
2555
|
+
}) => {
|
|
2556
|
+
if (images.length === 0)
|
|
2557
|
+
return null;
|
|
2558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2559
|
+
"div",
|
|
2560
|
+
{
|
|
2561
|
+
className: `copilotKitImageUploadQueue ${className}`,
|
|
2562
|
+
style: {
|
|
2563
|
+
display: "flex",
|
|
2564
|
+
flexWrap: "wrap",
|
|
2565
|
+
gap: "8px",
|
|
2566
|
+
margin: "8px",
|
|
2567
|
+
padding: "8px"
|
|
2568
|
+
},
|
|
2569
|
+
children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2570
|
+
"div",
|
|
2571
|
+
{
|
|
2572
|
+
className: "copilotKitImageUploadQueueItem",
|
|
2573
|
+
style: {
|
|
2574
|
+
position: "relative",
|
|
2575
|
+
display: "inline-block",
|
|
2576
|
+
width: "60px",
|
|
2577
|
+
height: "60px",
|
|
2578
|
+
borderRadius: "4px",
|
|
2579
|
+
overflow: "hidden"
|
|
2580
|
+
},
|
|
2581
|
+
children: [
|
|
2582
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2583
|
+
"img",
|
|
2584
|
+
{
|
|
2585
|
+
src: `data:${image.contentType};base64,${image.bytes}`,
|
|
2586
|
+
alt: `Selected image ${index + 1}`,
|
|
2587
|
+
style: {
|
|
2588
|
+
width: "100%",
|
|
2589
|
+
height: "100%",
|
|
2590
|
+
objectFit: "cover"
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
),
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2595
|
+
"button",
|
|
2596
|
+
{
|
|
2597
|
+
onClick: () => onRemoveImage(index),
|
|
2598
|
+
className: "copilotKitImageUploadQueueRemoveButton",
|
|
2599
|
+
style: {
|
|
2600
|
+
position: "absolute",
|
|
2601
|
+
top: "2px",
|
|
2602
|
+
right: "2px",
|
|
2603
|
+
background: "rgba(0,0,0,0.6)",
|
|
2604
|
+
color: "white",
|
|
2605
|
+
border: "none",
|
|
2606
|
+
borderRadius: "50%",
|
|
2607
|
+
width: "18px",
|
|
2608
|
+
height: "18px",
|
|
2609
|
+
display: "flex",
|
|
2610
|
+
alignItems: "center",
|
|
2611
|
+
justifyContent: "center",
|
|
2612
|
+
cursor: "pointer",
|
|
2613
|
+
fontSize: "10px",
|
|
2614
|
+
padding: 0
|
|
2615
|
+
},
|
|
2616
|
+
children: "\u2715"
|
|
2617
|
+
}
|
|
2618
|
+
)
|
|
2619
|
+
]
|
|
2620
|
+
},
|
|
2621
|
+
index
|
|
2622
|
+
))
|
|
2623
|
+
}
|
|
2624
|
+
);
|
|
2625
|
+
};
|
|
2626
|
+
|
|
2627
|
+
// src/components/chat/Chat.tsx
|
|
2628
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2451
2629
|
function CopilotChat({
|
|
2452
2630
|
instructions,
|
|
2453
2631
|
onSubmitMessage,
|
|
@@ -2464,14 +2642,64 @@ function CopilotChat({
|
|
|
2464
2642
|
RenderActionExecutionMessage: RenderActionExecutionMessage2 = RenderActionExecutionMessage,
|
|
2465
2643
|
RenderAgentStateMessage: RenderAgentStateMessage2 = RenderAgentStateMessage,
|
|
2466
2644
|
RenderResultMessage: RenderResultMessage2 = RenderResultMessage,
|
|
2645
|
+
RenderImageMessage: RenderImageMessage2 = RenderImageMessage,
|
|
2467
2646
|
Input: Input2 = Input,
|
|
2468
2647
|
className,
|
|
2469
2648
|
icons,
|
|
2470
2649
|
labels,
|
|
2471
2650
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2472
|
-
UserMessage: UserMessage2 = UserMessage
|
|
2651
|
+
UserMessage: UserMessage2 = UserMessage,
|
|
2652
|
+
imageUploadsEnabled,
|
|
2653
|
+
inputFileAccept = "image/*"
|
|
2473
2654
|
}) {
|
|
2474
2655
|
const { additionalInstructions, setChatInstructions } = (0, import_react_core10.useCopilotContext)();
|
|
2656
|
+
const [selectedImages, setSelectedImages] = (0, import_react13.useState)([]);
|
|
2657
|
+
const fileInputRef = (0, import_react13.useRef)(null);
|
|
2658
|
+
(0, import_react13.useEffect)(() => {
|
|
2659
|
+
if (!imageUploadsEnabled)
|
|
2660
|
+
return;
|
|
2661
|
+
const handlePaste = (e) => __async(this, null, function* () {
|
|
2662
|
+
var _a, _b;
|
|
2663
|
+
const target = e.target;
|
|
2664
|
+
if (!((_a = target.parentElement) == null ? void 0 : _a.classList.contains("copilotKitInput")))
|
|
2665
|
+
return;
|
|
2666
|
+
const items = Array.from(((_b = e.clipboardData) == null ? void 0 : _b.items) || []);
|
|
2667
|
+
const imageItems = items.filter((item) => item.type.startsWith("image/"));
|
|
2668
|
+
if (imageItems.length === 0)
|
|
2669
|
+
return;
|
|
2670
|
+
e.preventDefault();
|
|
2671
|
+
const imagePromises = imageItems.map((item) => {
|
|
2672
|
+
const file = item.getAsFile();
|
|
2673
|
+
if (!file)
|
|
2674
|
+
return Promise.resolve(null);
|
|
2675
|
+
return new Promise((resolve, reject) => {
|
|
2676
|
+
const reader = new FileReader();
|
|
2677
|
+
reader.onload = (e2) => {
|
|
2678
|
+
var _a2, _b2;
|
|
2679
|
+
const base64String = (_b2 = (_a2 = e2.target) == null ? void 0 : _a2.result) == null ? void 0 : _b2.split(",")[1];
|
|
2680
|
+
if (base64String) {
|
|
2681
|
+
resolve({
|
|
2682
|
+
contentType: file.type,
|
|
2683
|
+
bytes: base64String
|
|
2684
|
+
});
|
|
2685
|
+
} else {
|
|
2686
|
+
resolve(null);
|
|
2687
|
+
}
|
|
2688
|
+
};
|
|
2689
|
+
reader.onerror = reject;
|
|
2690
|
+
reader.readAsDataURL(file);
|
|
2691
|
+
});
|
|
2692
|
+
});
|
|
2693
|
+
try {
|
|
2694
|
+
const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
|
|
2695
|
+
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2696
|
+
} catch (error) {
|
|
2697
|
+
console.error("Error processing pasted images:", error);
|
|
2698
|
+
}
|
|
2699
|
+
});
|
|
2700
|
+
document.addEventListener("paste", handlePaste);
|
|
2701
|
+
return () => document.removeEventListener("paste", handlePaste);
|
|
2702
|
+
}, [imageUploadsEnabled]);
|
|
2475
2703
|
(0, import_react13.useEffect)(() => {
|
|
2476
2704
|
if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
|
|
2477
2705
|
setChatInstructions(instructions || "");
|
|
@@ -2499,6 +2727,14 @@ function CopilotChat({
|
|
|
2499
2727
|
onStopGeneration,
|
|
2500
2728
|
onReloadMessages
|
|
2501
2729
|
);
|
|
2730
|
+
const handleSendMessage = (text) => {
|
|
2731
|
+
const images = selectedImages;
|
|
2732
|
+
setSelectedImages([]);
|
|
2733
|
+
if (fileInputRef.current) {
|
|
2734
|
+
fileInputRef.current.value = "";
|
|
2735
|
+
}
|
|
2736
|
+
return sendMessage(text, images);
|
|
2737
|
+
};
|
|
2502
2738
|
const chatContext = import_react13.default.useContext(ChatContext);
|
|
2503
2739
|
const isVisible = chatContext ? chatContext.open : true;
|
|
2504
2740
|
const handleRegenerate = (messageId) => {
|
|
@@ -2512,8 +2748,42 @@ function CopilotChat({
|
|
|
2512
2748
|
onCopy(message);
|
|
2513
2749
|
}
|
|
2514
2750
|
};
|
|
2515
|
-
|
|
2516
|
-
|
|
2751
|
+
const handleImageUpload = (event) => __async(this, null, function* () {
|
|
2752
|
+
if (!event.target.files || event.target.files.length === 0) {
|
|
2753
|
+
return;
|
|
2754
|
+
}
|
|
2755
|
+
const files = Array.from(event.target.files).filter((file) => file.type.startsWith("image/"));
|
|
2756
|
+
if (files.length === 0)
|
|
2757
|
+
return;
|
|
2758
|
+
const fileReadPromises = files.map((file) => {
|
|
2759
|
+
return new Promise((resolve, reject) => {
|
|
2760
|
+
const reader = new FileReader();
|
|
2761
|
+
reader.onload = (e) => {
|
|
2762
|
+
var _a, _b;
|
|
2763
|
+
const base64String = ((_b = (_a = e.target) == null ? void 0 : _a.result) == null ? void 0 : _b.split(",")[1]) || "";
|
|
2764
|
+
if (base64String) {
|
|
2765
|
+
resolve({
|
|
2766
|
+
contentType: file.type,
|
|
2767
|
+
bytes: base64String
|
|
2768
|
+
});
|
|
2769
|
+
}
|
|
2770
|
+
};
|
|
2771
|
+
reader.onerror = reject;
|
|
2772
|
+
reader.readAsDataURL(file);
|
|
2773
|
+
});
|
|
2774
|
+
});
|
|
2775
|
+
try {
|
|
2776
|
+
const loadedImages = yield Promise.all(fileReadPromises);
|
|
2777
|
+
setSelectedImages((prev) => [...prev, ...loadedImages]);
|
|
2778
|
+
} catch (error) {
|
|
2779
|
+
console.error("Error reading files:", error);
|
|
2780
|
+
}
|
|
2781
|
+
});
|
|
2782
|
+
const removeSelectedImage = (index) => {
|
|
2783
|
+
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
2784
|
+
};
|
|
2785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2786
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2517
2787
|
Messages2,
|
|
2518
2788
|
{
|
|
2519
2789
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2522,32 +2792,51 @@ function CopilotChat({
|
|
|
2522
2792
|
RenderActionExecutionMessage: RenderActionExecutionMessage2,
|
|
2523
2793
|
RenderAgentStateMessage: RenderAgentStateMessage2,
|
|
2524
2794
|
RenderResultMessage: RenderResultMessage2,
|
|
2795
|
+
RenderImageMessage: RenderImageMessage2,
|
|
2525
2796
|
messages: visibleMessages,
|
|
2526
2797
|
inProgress: isLoading,
|
|
2527
2798
|
onRegenerate: handleRegenerate,
|
|
2528
2799
|
onCopy: handleCopy,
|
|
2529
2800
|
onThumbsUp,
|
|
2530
2801
|
onThumbsDown,
|
|
2531
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2802
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2532
2803
|
Suggestion,
|
|
2533
2804
|
{
|
|
2534
2805
|
title: suggestion.title,
|
|
2535
2806
|
message: suggestion.message,
|
|
2536
2807
|
partial: suggestion.partial,
|
|
2537
2808
|
className: suggestion.className,
|
|
2538
|
-
onClick: (message) =>
|
|
2809
|
+
onClick: (message) => handleSendMessage(message)
|
|
2539
2810
|
},
|
|
2540
2811
|
index
|
|
2541
2812
|
)) })
|
|
2542
2813
|
}
|
|
2543
2814
|
),
|
|
2544
|
-
/* @__PURE__ */ (0,
|
|
2815
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
2816
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2818
|
+
"input",
|
|
2819
|
+
{
|
|
2820
|
+
type: "file",
|
|
2821
|
+
multiple: true,
|
|
2822
|
+
ref: fileInputRef,
|
|
2823
|
+
onChange: handleImageUpload,
|
|
2824
|
+
accept: inputFileAccept,
|
|
2825
|
+
style: { display: "none" }
|
|
2826
|
+
}
|
|
2827
|
+
)
|
|
2828
|
+
] }),
|
|
2829
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2545
2830
|
Input2,
|
|
2546
2831
|
{
|
|
2547
2832
|
inProgress: isLoading,
|
|
2548
|
-
onSend:
|
|
2833
|
+
onSend: handleSendMessage,
|
|
2549
2834
|
isVisible,
|
|
2550
|
-
onStop: stopGeneration
|
|
2835
|
+
onStop: stopGeneration,
|
|
2836
|
+
onUpload: imageUploadsEnabled ? () => {
|
|
2837
|
+
var _a;
|
|
2838
|
+
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
2839
|
+
} : void 0
|
|
2551
2840
|
}
|
|
2552
2841
|
)
|
|
2553
2842
|
] });
|
|
@@ -2560,10 +2849,10 @@ function WrappedCopilotChat({
|
|
|
2560
2849
|
}) {
|
|
2561
2850
|
const chatContext = import_react13.default.useContext(ChatContext);
|
|
2562
2851
|
if (!chatContext) {
|
|
2563
|
-
return /* @__PURE__ */ (0,
|
|
2564
|
-
}, children: /* @__PURE__ */ (0,
|
|
2852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2853
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className}`, children }) });
|
|
2565
2854
|
}
|
|
2566
|
-
return /* @__PURE__ */ (0,
|
|
2855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
|
|
2567
2856
|
}
|
|
2568
2857
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2569
2858
|
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|
|
@@ -2617,22 +2906,45 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2617
2906
|
// global context
|
|
2618
2907
|
visibleMessages.length == 0
|
|
2619
2908
|
]);
|
|
2620
|
-
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
2909
|
+
const sendMessage = (messageContent, imagesToUse) => __async(void 0, null, function* () {
|
|
2910
|
+
const images = imagesToUse || [];
|
|
2621
2911
|
abortSuggestions();
|
|
2622
2912
|
setCurrentSuggestions([]);
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2913
|
+
let firstMessage = null;
|
|
2914
|
+
if (messageContent.trim().length > 0) {
|
|
2915
|
+
const textMessage = new import_runtime_client_gql4.TextMessage({
|
|
2916
|
+
content: messageContent,
|
|
2917
|
+
role: import_runtime_client_gql4.Role.User
|
|
2918
|
+
});
|
|
2919
|
+
if (onSubmitMessage) {
|
|
2920
|
+
try {
|
|
2921
|
+
yield onSubmitMessage(messageContent);
|
|
2922
|
+
} catch (error) {
|
|
2923
|
+
console.error("Error in onSubmitMessage:", error);
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
yield appendMessage(textMessage, { followUp: images.length === 0 });
|
|
2927
|
+
if (!firstMessage) {
|
|
2928
|
+
firstMessage = textMessage;
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
if (images.length > 0) {
|
|
2932
|
+
for (let i = 0; i < images.length; i++) {
|
|
2933
|
+
const imageMessage = new import_runtime_client_gql4.ImageMessage({
|
|
2934
|
+
format: images[i].contentType.replace("image/", ""),
|
|
2935
|
+
bytes: images[i].bytes,
|
|
2936
|
+
role: import_runtime_client_gql4.Role.User
|
|
2937
|
+
});
|
|
2938
|
+
yield appendMessage(imageMessage, { followUp: i === images.length - 1 });
|
|
2939
|
+
if (!firstMessage) {
|
|
2940
|
+
firstMessage = imageMessage;
|
|
2941
|
+
}
|
|
2632
2942
|
}
|
|
2633
2943
|
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2944
|
+
if (!firstMessage) {
|
|
2945
|
+
return new import_runtime_client_gql4.TextMessage({ content: "", role: import_runtime_client_gql4.Role.User });
|
|
2946
|
+
}
|
|
2947
|
+
return firstMessage;
|
|
2636
2948
|
});
|
|
2637
2949
|
const messages = visibleMessages;
|
|
2638
2950
|
const { setMessages } = messagesContext;
|
|
@@ -2725,7 +3037,7 @@ var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onS
|
|
|
2725
3037
|
};
|
|
2726
3038
|
|
|
2727
3039
|
// src/components/chat/Modal.tsx
|
|
2728
|
-
var
|
|
3040
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2729
3041
|
var CopilotModal = ({
|
|
2730
3042
|
instructions,
|
|
2731
3043
|
defaultOpen = false,
|
|
@@ -2759,19 +3071,19 @@ var CopilotModal = ({
|
|
|
2759
3071
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
2760
3072
|
setOpenState(open);
|
|
2761
3073
|
};
|
|
2762
|
-
return /* @__PURE__ */ (0,
|
|
3074
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
|
|
2763
3075
|
children,
|
|
2764
|
-
/* @__PURE__ */ (0,
|
|
2765
|
-
/* @__PURE__ */ (0,
|
|
2766
|
-
/* @__PURE__ */ (0,
|
|
3076
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
|
|
3078
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2767
3079
|
Window2,
|
|
2768
3080
|
{
|
|
2769
3081
|
clickOutsideToClose,
|
|
2770
3082
|
shortcut,
|
|
2771
3083
|
hitEscapeToClose,
|
|
2772
3084
|
children: [
|
|
2773
|
-
/* @__PURE__ */ (0,
|
|
2774
|
-
/* @__PURE__ */ (0,
|
|
3085
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}),
|
|
3086
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2775
3087
|
CopilotChat,
|
|
2776
3088
|
{
|
|
2777
3089
|
instructions,
|
|
@@ -2798,17 +3110,17 @@ var CopilotModal = ({
|
|
|
2798
3110
|
};
|
|
2799
3111
|
|
|
2800
3112
|
// src/components/chat/Popup.tsx
|
|
2801
|
-
var
|
|
3113
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2802
3114
|
function CopilotPopup(props) {
|
|
2803
3115
|
props = __spreadProps(__spreadValues({}, props), {
|
|
2804
3116
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
2805
3117
|
});
|
|
2806
|
-
return /* @__PURE__ */ (0,
|
|
3118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
2807
3119
|
}
|
|
2808
3120
|
|
|
2809
3121
|
// src/components/chat/Sidebar.tsx
|
|
2810
3122
|
var import_react15 = require("react");
|
|
2811
|
-
var
|
|
3123
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2812
3124
|
function CopilotSidebar(props) {
|
|
2813
3125
|
props = __spreadProps(__spreadValues({}, props), {
|
|
2814
3126
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
@@ -2821,7 +3133,7 @@ function CopilotSidebar(props) {
|
|
|
2821
3133
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
2822
3134
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
2823
3135
|
};
|
|
2824
|
-
return /* @__PURE__ */ (0,
|
|
3136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
|
|
2825
3137
|
}
|
|
2826
3138
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2827
3139
|
0 && (module.exports = {
|
|
@@ -2830,6 +3142,7 @@ function CopilotSidebar(props) {
|
|
|
2830
3142
|
CopilotPopup,
|
|
2831
3143
|
CopilotSidebar,
|
|
2832
3144
|
Markdown,
|
|
3145
|
+
RenderImageMessage,
|
|
2833
3146
|
UserMessage,
|
|
2834
3147
|
useChatContext
|
|
2835
3148
|
});
|