@copilotkit/react-ui 0.22.0 → 0.36.0-mme-pre.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/.turbo/turbo-build.log +211 -178
- package/CHANGELOG.md +24 -0
- package/dist/chunk-4MKP23AD.mjs +97 -0
- package/dist/chunk-4MKP23AD.mjs.map +1 -0
- package/dist/{chunk-T3WYKWNC.mjs → chunk-6XLZXLM5.mjs} +6 -6
- package/dist/chunk-6XLZXLM5.mjs.map +1 -0
- package/dist/{chunk-73EBDGYK.mjs → chunk-7FES2IQA.mjs} +5 -5
- package/dist/chunk-7FES2IQA.mjs.map +1 -0
- package/dist/chunk-ANO23V2M.mjs +135 -0
- package/dist/chunk-ANO23V2M.mjs.map +1 -0
- package/dist/chunk-BL65ZC6L.mjs +83 -0
- package/dist/chunk-BL65ZC6L.mjs.map +1 -0
- package/dist/{chunk-YEHO5VMA.mjs → chunk-CE7PJAAO.mjs} +2 -2
- package/dist/{chunk-7YXG7D47.mjs → chunk-FZC7X5PK.mjs} +57 -2
- package/dist/chunk-FZC7X5PK.mjs.map +1 -0
- package/dist/chunk-LTCJCXCP.mjs +29 -0
- package/dist/chunk-LTCJCXCP.mjs.map +1 -0
- package/dist/chunk-MRFF7GSQ.mjs +1 -0
- package/dist/{chunk-7JYUCW7H.mjs → chunk-PAQWLSA4.mjs} +2 -2
- package/dist/{chunk-YTIGBBTC.mjs → chunk-RT2XG2T7.mjs} +2 -2
- package/dist/chunk-RT2XG2T7.mjs.map +1 -0
- package/dist/chunk-T26KLXLH.mjs +1 -0
- package/dist/{chunk-6U3O2JZP.mjs → chunk-T3JTSIHT.mjs} +32 -39
- package/dist/chunk-T3JTSIHT.mjs.map +1 -0
- package/dist/{chunk-MBYUBR3F.mjs → chunk-UPTB2MVO.mjs} +2 -2
- package/dist/chunk-VUZA5AFH.mjs +73 -0
- package/dist/chunk-VUZA5AFH.mjs.map +1 -0
- package/dist/{chunk-YAORLSQ3.mjs → chunk-XRODMID5.mjs} +6 -6
- package/dist/chunk-XRODMID5.mjs.map +1 -0
- package/dist/{chunk-WDHLWSSU.mjs → chunk-YQ3D5IQV.mjs} +2 -2
- package/dist/{chunk-WM6BS77F.mjs → chunk-YQFVRDNC.mjs} +2 -2
- package/dist/{chunk-WM6BS77F.mjs.map → chunk-YQFVRDNC.mjs.map} +1 -1
- package/dist/chunk-ZO3GLN23.mjs +137 -0
- package/dist/chunk-ZO3GLN23.mjs.map +1 -0
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +3 -3
- package/dist/components/chat/Chat.d.ts +66 -46
- package/dist/components/chat/Chat.js +433 -278
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +15 -14
- package/dist/components/chat/ChatContext.d.ts +16 -16
- package/dist/components/chat/ChatContext.js +43 -27
- 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 +3 -3
- package/dist/components/chat/Icons.d.ts +7 -5
- package/dist/components/chat/Icons.js +57 -0
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +5 -1
- package/dist/components/chat/Input.d.ts +1 -1
- package/dist/components/chat/Input.js +148 -11
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +5 -4
- 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 +2 -2
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +5 -5
- package/dist/components/chat/Modal.d.ts +50 -0
- package/dist/components/chat/Modal.js +1584 -0
- package/dist/components/chat/Modal.js.map +1 -0
- package/dist/components/chat/Modal.mjs +23 -0
- package/dist/components/chat/Modal.mjs.map +1 -0
- package/dist/components/chat/Popup.d.ts +56 -4
- package/dist/components/chat/Popup.js +428 -78
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +15 -12
- package/dist/components/chat/Response.js.map +1 -1
- package/dist/components/chat/Response.mjs +3 -3
- package/dist/components/chat/Sidebar.d.ts +7 -8
- package/dist/components/chat/Sidebar.js +430 -80
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +15 -12
- package/dist/components/chat/Suggestion.d.ts +13 -0
- package/dist/components/chat/Suggestion.js +172 -0
- package/dist/components/chat/Suggestion.js.map +1 -0
- package/dist/components/chat/Suggestion.mjs +11 -0
- package/dist/components/chat/Suggestion.mjs.map +1 -0
- package/dist/components/chat/Textarea.d.ts +4 -4
- package/dist/components/chat/Textarea.js +1 -1
- package/dist/components/chat/Textarea.js.map +1 -1
- package/dist/components/chat/Textarea.mjs +1 -1
- package/dist/components/chat/index.d.ts +4 -2
- package/dist/components/chat/index.js +436 -84
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +22 -16
- package/dist/components/chat/props.d.ts +10 -3
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/components/index.js +436 -84
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +22 -16
- package/dist/hooks/index.d.ts +1 -2
- package/dist/hooks/index.js +36 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +8 -1
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +87 -0
- package/dist/hooks/use-copilot-chat-suggestions.js +53 -0
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
- package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
- package/dist/hooks/use-push-to-talk.d.ts +19 -0
- package/dist/hooks/use-push-to-talk.js +177 -0
- package/dist/hooks/use-push-to-talk.js.map +1 -0
- package/dist/hooks/use-push-to-talk.mjs +12 -0
- package/dist/hooks/use-push-to-talk.mjs.map +1 -0
- package/dist/index.css +101 -13
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +465 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -19
- package/dist/types/suggestions.d.ts +8 -0
- package/dist/types/suggestions.js +19 -0
- package/dist/types/suggestions.js.map +1 -0
- package/dist/types/suggestions.mjs +1 -0
- package/dist/types/suggestions.mjs.map +1 -0
- package/package.json +6 -6
- package/src/components/chat/Button.tsx +1 -2
- package/src/components/chat/Chat.tsx +163 -104
- package/src/components/chat/ChatContext.tsx +36 -38
- package/src/components/chat/Icons.tsx +44 -0
- package/src/components/chat/Input.tsx +38 -7
- package/src/components/chat/Messages.tsx +3 -3
- package/src/components/chat/Modal.tsx +115 -0
- package/src/components/chat/Popup.tsx +53 -7
- package/src/components/chat/Sidebar.tsx +62 -9
- package/src/components/chat/Suggestion.tsx +109 -0
- package/src/components/chat/Textarea.tsx +1 -1
- package/src/components/chat/index.tsx +1 -0
- package/src/components/chat/props.ts +10 -2
- package/src/css/input.css +18 -8
- package/src/css/messages.css +7 -1
- package/src/css/panel.css +38 -0
- package/src/css/response.css +1 -4
- package/src/css/suggestions.css +35 -0
- package/src/css/window.css +3 -1
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-copilot-chat-suggestions.tsx +117 -0
- package/src/hooks/use-push-to-talk.tsx +162 -0
- package/src/styles.css +2 -0
- package/src/types/suggestions.ts +6 -0
- package/typedoc.json +4 -0
- package/dist/chunk-6U3O2JZP.mjs.map +0 -1
- package/dist/chunk-73EBDGYK.mjs.map +0 -1
- package/dist/chunk-7LMXXGJT.mjs +0 -75
- package/dist/chunk-7LMXXGJT.mjs.map +0 -1
- package/dist/chunk-7YXG7D47.mjs.map +0 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -1
- package/dist/chunk-KE3N45ZY.mjs +0 -63
- package/dist/chunk-KE3N45ZY.mjs.map +0 -1
- package/dist/chunk-T3WYKWNC.mjs.map +0 -1
- package/dist/chunk-UGQQ4WEQ.mjs +0 -1
- package/dist/chunk-YAORLSQ3.mjs.map +0 -1
- package/dist/chunk-YTIGBBTC.mjs.map +0 -1
- /package/dist/{chunk-YEHO5VMA.mjs.map → chunk-CE7PJAAO.mjs.map} +0 -0
- /package/dist/{chunk-H4VKQGVU.mjs.map → chunk-MRFF7GSQ.mjs.map} +0 -0
- /package/dist/{chunk-7JYUCW7H.mjs.map → chunk-PAQWLSA4.mjs.map} +0 -0
- /package/dist/{chunk-UGQQ4WEQ.mjs.map → chunk-T26KLXLH.mjs.map} +0 -0
- /package/dist/{chunk-MBYUBR3F.mjs.map → chunk-UPTB2MVO.mjs.map} +0 -0
- /package/dist/{chunk-WDHLWSSU.mjs.map → chunk-YQ3D5IQV.mjs.map} +0 -0
|
@@ -82,10 +82,10 @@ __export(Sidebar_exports, {
|
|
|
82
82
|
CopilotSidebar: () => CopilotSidebar
|
|
83
83
|
});
|
|
84
84
|
module.exports = __toCommonJS(Sidebar_exports);
|
|
85
|
-
var
|
|
85
|
+
var import_react11 = require("react");
|
|
86
86
|
|
|
87
|
-
// src/components/chat/
|
|
88
|
-
var
|
|
87
|
+
// src/components/chat/Modal.tsx
|
|
88
|
+
var import_react10 = __toESM(require("react"));
|
|
89
89
|
|
|
90
90
|
// src/components/chat/ChatContext.tsx
|
|
91
91
|
var import_react = __toESM(require("react"));
|
|
@@ -191,6 +191,40 @@ var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
|
191
191
|
]
|
|
192
192
|
}
|
|
193
193
|
);
|
|
194
|
+
var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
195
|
+
"svg",
|
|
196
|
+
{
|
|
197
|
+
style: {
|
|
198
|
+
animation: "copilotKitSpinAnimation 1s linear infinite"
|
|
199
|
+
},
|
|
200
|
+
width: "13",
|
|
201
|
+
height: "13",
|
|
202
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
203
|
+
fill: "none",
|
|
204
|
+
viewBox: "0 0 24 24",
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
207
|
+
"circle",
|
|
208
|
+
{
|
|
209
|
+
style: { opacity: 0.25 },
|
|
210
|
+
cx: "12",
|
|
211
|
+
cy: "12",
|
|
212
|
+
r: "10",
|
|
213
|
+
stroke: "currentColor",
|
|
214
|
+
strokeWidth: "4"
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
218
|
+
"path",
|
|
219
|
+
{
|
|
220
|
+
style: { opacity: 0.75 },
|
|
221
|
+
fill: "currentColor",
|
|
222
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
);
|
|
194
228
|
var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
195
229
|
"svg",
|
|
196
230
|
{
|
|
@@ -276,6 +310,25 @@ var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
|
276
310
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z" })
|
|
277
311
|
}
|
|
278
312
|
);
|
|
313
|
+
var PushToTalkIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
314
|
+
"svg",
|
|
315
|
+
{
|
|
316
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
317
|
+
fill: "none",
|
|
318
|
+
viewBox: "0 0 24 24",
|
|
319
|
+
strokeWidth: 1.5,
|
|
320
|
+
stroke: "currentColor",
|
|
321
|
+
className: "w-6 h-6",
|
|
322
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
323
|
+
"path",
|
|
324
|
+
{
|
|
325
|
+
strokeLinecap: "round",
|
|
326
|
+
strokeLinejoin: "round",
|
|
327
|
+
d: "M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1 6 0v8.25a3 3 0 0 1-3 3Z"
|
|
328
|
+
}
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
);
|
|
279
332
|
|
|
280
333
|
// src/components/chat/ChatContext.tsx
|
|
281
334
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -299,40 +352,34 @@ var ChatContextProvider = ({
|
|
|
299
352
|
open,
|
|
300
353
|
setOpen
|
|
301
354
|
}) => {
|
|
302
|
-
const context =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
icons
|
|
324
|
-
}),
|
|
325
|
-
open,
|
|
326
|
-
setOpen
|
|
355
|
+
const context = {
|
|
356
|
+
labels: __spreadValues(__spreadValues({}, {
|
|
357
|
+
initial: "",
|
|
358
|
+
title: "CopilotKit",
|
|
359
|
+
placeholder: "Type a message...",
|
|
360
|
+
error: "\u274C An error occurred. Please try again.",
|
|
361
|
+
stopGenerating: "Stop generating",
|
|
362
|
+
regenerateResponse: "Regenerate response"
|
|
363
|
+
}), labels),
|
|
364
|
+
icons: __spreadProps(__spreadValues({}, {
|
|
365
|
+
openIcon: OpenIcon,
|
|
366
|
+
closeIcon: CloseIcon,
|
|
367
|
+
headerCloseIcon: HeaderCloseIcon,
|
|
368
|
+
sendIcon: SendIcon,
|
|
369
|
+
activityIcon: ActivityIcon,
|
|
370
|
+
spinnerIcon: SpinnerIcon,
|
|
371
|
+
stopIcon: StopIcon,
|
|
372
|
+
regenerateIcon: RegenerateIcon,
|
|
373
|
+
pushToTalkIcon: PushToTalkIcon
|
|
374
|
+
}), {
|
|
375
|
+
icons
|
|
327
376
|
}),
|
|
328
|
-
|
|
329
|
-
|
|
377
|
+
open,
|
|
378
|
+
setOpen
|
|
379
|
+
};
|
|
330
380
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
|
|
331
381
|
};
|
|
332
382
|
|
|
333
|
-
// src/components/chat/Chat.tsx
|
|
334
|
-
var import_react_core2 = require("@copilotkit/react-core");
|
|
335
|
-
|
|
336
383
|
// src/components/chat/Window.tsx
|
|
337
384
|
var import_react2 = __toESM(require("react"));
|
|
338
385
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -942,7 +989,7 @@ var components = {
|
|
|
942
989
|
// src/components/chat/Messages.tsx
|
|
943
990
|
var import_react_core = require("@copilotkit/react-core");
|
|
944
991
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
945
|
-
var Messages = ({ messages, inProgress }) => {
|
|
992
|
+
var Messages = ({ messages, inProgress, children }) => {
|
|
946
993
|
const { chatComponentsCache } = (0, import_react_core.useCopilotContext)();
|
|
947
994
|
const context = useChatContext();
|
|
948
995
|
const initialMessages = (0, import_react5.useMemo)(
|
|
@@ -1028,7 +1075,7 @@ var Messages = ({ messages, inProgress }) => {
|
|
|
1028
1075
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Markdown, { content: message.content }) }, index);
|
|
1029
1076
|
}
|
|
1030
1077
|
}),
|
|
1031
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("footer", { ref: messagesEndRef, children })
|
|
1032
1079
|
] });
|
|
1033
1080
|
};
|
|
1034
1081
|
function makeInitialMessages(initial) {
|
|
@@ -1048,7 +1095,7 @@ function makeInitialMessages(initial) {
|
|
|
1048
1095
|
}
|
|
1049
1096
|
|
|
1050
1097
|
// src/components/chat/Input.tsx
|
|
1051
|
-
var
|
|
1098
|
+
var import_react8 = require("react");
|
|
1052
1099
|
|
|
1053
1100
|
// src/components/chat/Textarea.tsx
|
|
1054
1101
|
var import_react6 = require("react");
|
|
@@ -1088,7 +1135,7 @@ var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
|
1088
1135
|
onKeyDown,
|
|
1089
1136
|
placeholder,
|
|
1090
1137
|
style: {
|
|
1091
|
-
overflow: "
|
|
1138
|
+
overflow: "auto",
|
|
1092
1139
|
resize: "none",
|
|
1093
1140
|
maxHeight: `${maxHeight}px`
|
|
1094
1141
|
},
|
|
@@ -1099,18 +1146,121 @@ var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
|
1099
1146
|
);
|
|
1100
1147
|
var Textarea_default = AutoResizingTextarea;
|
|
1101
1148
|
|
|
1149
|
+
// src/hooks/use-push-to-talk.tsx
|
|
1150
|
+
var import_react_core2 = require("@copilotkit/react-core");
|
|
1151
|
+
var import_react7 = require("react");
|
|
1152
|
+
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
1153
|
+
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
1154
|
+
mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
|
|
1155
|
+
audioContextRef.current = new window.AudioContext();
|
|
1156
|
+
yield audioContextRef.current.resume();
|
|
1157
|
+
}
|
|
1158
|
+
mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current);
|
|
1159
|
+
mediaRecorderRef.current.start(1e3);
|
|
1160
|
+
mediaRecorderRef.current.ondataavailable = (event) => {
|
|
1161
|
+
recordedChunks.push(event.data);
|
|
1162
|
+
};
|
|
1163
|
+
mediaRecorderRef.current.onstop = onStop;
|
|
1164
|
+
});
|
|
1165
|
+
var stopRecording = (mediaRecorderRef) => {
|
|
1166
|
+
if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
|
|
1167
|
+
mediaRecorderRef.current.stop();
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
var transcribeAudio = (recordedChunks, transcribeAudioUrl) => __async(void 0, null, function* () {
|
|
1171
|
+
const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
|
|
1172
|
+
const formData = new FormData();
|
|
1173
|
+
formData.append("file", completeBlob, "recording.mp4");
|
|
1174
|
+
const response = yield fetch(transcribeAudioUrl, {
|
|
1175
|
+
method: "POST",
|
|
1176
|
+
body: formData
|
|
1177
|
+
});
|
|
1178
|
+
if (!response.ok) {
|
|
1179
|
+
throw new Error(`Error: ${response.statusText}`);
|
|
1180
|
+
}
|
|
1181
|
+
const transcription = yield response.json();
|
|
1182
|
+
return transcription.text;
|
|
1183
|
+
});
|
|
1184
|
+
var playAudioResponse = (text, textToSpeechUrl, audioContext) => {
|
|
1185
|
+
const encodedText = encodeURIComponent(text);
|
|
1186
|
+
const url = `${textToSpeechUrl}?text=${encodedText}`;
|
|
1187
|
+
fetch(url).then((response) => response.arrayBuffer()).then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer)).then((audioBuffer) => {
|
|
1188
|
+
const source = audioContext.createBufferSource();
|
|
1189
|
+
source.buffer = audioBuffer;
|
|
1190
|
+
source.connect(audioContext.destination);
|
|
1191
|
+
source.start(0);
|
|
1192
|
+
}).catch((error) => {
|
|
1193
|
+
console.error("Error with decoding audio data", error);
|
|
1194
|
+
});
|
|
1195
|
+
};
|
|
1196
|
+
var usePushToTalk = ({
|
|
1197
|
+
sendFunction,
|
|
1198
|
+
inProgress
|
|
1199
|
+
}) => {
|
|
1200
|
+
const [pushToTalkState, setPushToTalkState] = (0, import_react7.useState)("idle");
|
|
1201
|
+
const mediaStreamRef = (0, import_react7.useRef)(null);
|
|
1202
|
+
const audioContextRef = (0, import_react7.useRef)(null);
|
|
1203
|
+
const mediaRecorderRef = (0, import_react7.useRef)(null);
|
|
1204
|
+
const recordedChunks = (0, import_react7.useRef)([]);
|
|
1205
|
+
const context = (0, import_react_core2.useCopilotContext)();
|
|
1206
|
+
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react7.useState)(null);
|
|
1207
|
+
(0, import_react7.useEffect)(() => {
|
|
1208
|
+
if (pushToTalkState === "recording") {
|
|
1209
|
+
startRecording(
|
|
1210
|
+
mediaStreamRef,
|
|
1211
|
+
mediaRecorderRef,
|
|
1212
|
+
audioContextRef,
|
|
1213
|
+
recordedChunks.current,
|
|
1214
|
+
() => {
|
|
1215
|
+
setPushToTalkState("transcribing");
|
|
1216
|
+
}
|
|
1217
|
+
);
|
|
1218
|
+
} else {
|
|
1219
|
+
stopRecording(mediaRecorderRef);
|
|
1220
|
+
if (pushToTalkState === "transcribing") {
|
|
1221
|
+
transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(
|
|
1222
|
+
(transcription) => __async(void 0, null, function* () {
|
|
1223
|
+
recordedChunks.current = [];
|
|
1224
|
+
setPushToTalkState("idle");
|
|
1225
|
+
const message = yield sendFunction(transcription);
|
|
1226
|
+
setStartReadingFromMessageId(message.id);
|
|
1227
|
+
})
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
return () => {
|
|
1232
|
+
stopRecording(mediaRecorderRef);
|
|
1233
|
+
};
|
|
1234
|
+
}, [pushToTalkState]);
|
|
1235
|
+
(0, import_react7.useEffect)(() => {
|
|
1236
|
+
if (inProgress === false && startReadingFromMessageId) {
|
|
1237
|
+
const lastMessageIndex = context.messages.findIndex(
|
|
1238
|
+
(message) => message.id === startReadingFromMessageId
|
|
1239
|
+
);
|
|
1240
|
+
const messagesAfterLast = context.messages.slice(lastMessageIndex + 1).filter((message) => message.role === "assistant" && message.content);
|
|
1241
|
+
const text = messagesAfterLast.map((message) => message.content).join("\n");
|
|
1242
|
+
playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
|
|
1243
|
+
setStartReadingFromMessageId(null);
|
|
1244
|
+
}
|
|
1245
|
+
}, [startReadingFromMessageId, inProgress]);
|
|
1246
|
+
return { pushToTalkState, setPushToTalkState };
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1102
1249
|
// src/components/chat/Input.tsx
|
|
1250
|
+
var import_react_core3 = require("@copilotkit/react-core");
|
|
1103
1251
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1104
|
-
var Input = ({ inProgress, onSend,
|
|
1252
|
+
var Input = ({ inProgress, onSend, isVisible = false }) => {
|
|
1105
1253
|
const context = useChatContext();
|
|
1106
|
-
const
|
|
1254
|
+
const copilotContext = (0, import_react_core3.useCopilotContext)();
|
|
1255
|
+
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1256
|
+
const textareaRef = (0, import_react8.useRef)(null);
|
|
1107
1257
|
const handleDivClick = (event) => {
|
|
1108
1258
|
var _a;
|
|
1109
1259
|
if (event.target !== event.currentTarget)
|
|
1110
1260
|
return;
|
|
1111
1261
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
1112
1262
|
};
|
|
1113
|
-
const [text, setText] = (0,
|
|
1263
|
+
const [text, setText] = (0, import_react8.useState)("");
|
|
1114
1264
|
const send = () => {
|
|
1115
1265
|
var _a;
|
|
1116
1266
|
if (inProgress)
|
|
@@ -1119,17 +1269,20 @@ var Input = ({ inProgress, onSend, children, isVisible = false }) => {
|
|
|
1119
1269
|
setText("");
|
|
1120
1270
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
1121
1271
|
};
|
|
1122
|
-
(0,
|
|
1272
|
+
(0, import_react8.useEffect)(() => {
|
|
1123
1273
|
var _a;
|
|
1124
1274
|
if (isVisible) {
|
|
1125
1275
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
1126
1276
|
}
|
|
1127
1277
|
}, [isVisible]);
|
|
1128
|
-
const
|
|
1129
|
-
|
|
1278
|
+
const { pushToTalkState, setPushToTalkState } = usePushToTalk({
|
|
1279
|
+
sendFunction: onSend,
|
|
1280
|
+
inProgress
|
|
1281
|
+
});
|
|
1282
|
+
const sendIcon = inProgress || pushToTalkState === "transcribing" ? context.icons.activityIcon : context.icons.sendIcon;
|
|
1283
|
+
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
1284
|
+
const sendDisabled = inProgress || text.length === 0 || pushToTalkState !== "idle";
|
|
1130
1285
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
1131
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children }),
|
|
1132
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
1133
1286
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1134
1287
|
Textarea_default,
|
|
1135
1288
|
{
|
|
@@ -1146,13 +1299,21 @@ var Input = ({ inProgress, onSend, children, isVisible = false }) => {
|
|
|
1146
1299
|
}
|
|
1147
1300
|
}
|
|
1148
1301
|
}
|
|
1149
|
-
)
|
|
1302
|
+
),
|
|
1303
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInputControls", children: [
|
|
1304
|
+
showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1305
|
+
"button",
|
|
1306
|
+
{
|
|
1307
|
+
onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
|
|
1308
|
+
className: pushToTalkState === "recording" ? "copilotKitPushToTalkRecording" : "",
|
|
1309
|
+
children: context.icons.pushToTalkIcon
|
|
1310
|
+
}
|
|
1311
|
+
),
|
|
1312
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { disabled: sendDisabled, onClick: send, children: sendIcon })
|
|
1313
|
+
] })
|
|
1150
1314
|
] });
|
|
1151
1315
|
};
|
|
1152
1316
|
|
|
1153
|
-
// src/components/chat/Chat.tsx
|
|
1154
|
-
var import_nanoid2 = require("nanoid");
|
|
1155
|
-
|
|
1156
1317
|
// src/components/chat/Response.tsx
|
|
1157
1318
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1158
1319
|
var ResponseButton = ({ onClick, inProgress }) => {
|
|
@@ -1163,9 +1324,203 @@ var ResponseButton = ({ onClick, inProgress }) => {
|
|
|
1163
1324
|
] });
|
|
1164
1325
|
};
|
|
1165
1326
|
|
|
1166
|
-
// src/components/chat/
|
|
1327
|
+
// src/components/chat/Suggestion.tsx
|
|
1328
|
+
var import_react_core4 = require("@copilotkit/react-core");
|
|
1167
1329
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1168
|
-
|
|
1330
|
+
function Suggestion({ title, message, onClick, partial, className }) {
|
|
1331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1332
|
+
"button",
|
|
1333
|
+
{
|
|
1334
|
+
disabled: partial,
|
|
1335
|
+
onClick: (e) => {
|
|
1336
|
+
e.preventDefault();
|
|
1337
|
+
onClick(message);
|
|
1338
|
+
},
|
|
1339
|
+
className: className || "suggestion",
|
|
1340
|
+
children: [
|
|
1341
|
+
partial && SmallSpinnerIcon,
|
|
1342
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: title })
|
|
1343
|
+
]
|
|
1344
|
+
}
|
|
1345
|
+
);
|
|
1346
|
+
}
|
|
1347
|
+
var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggestions, abortControllerRef) => __async(void 0, null, function* () {
|
|
1348
|
+
const abortController = abortControllerRef.current;
|
|
1349
|
+
const tools = JSON.stringify(context.getChatCompletionFunctionDescriptions(context.entryPoints));
|
|
1350
|
+
const allSuggestions = [];
|
|
1351
|
+
for (const config of Object.values(chatSuggestionConfiguration)) {
|
|
1352
|
+
try {
|
|
1353
|
+
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.`;
|
|
1354
|
+
const result = yield (0, import_react_core4.extract)({
|
|
1355
|
+
context,
|
|
1356
|
+
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. " + config.instructions + "\n\n" + numOfSuggestionsInstructions,
|
|
1357
|
+
data: "Available tools: " + tools + "\n\n",
|
|
1358
|
+
parameters: [
|
|
1359
|
+
{
|
|
1360
|
+
name: "suggestions",
|
|
1361
|
+
type: "object[]",
|
|
1362
|
+
attributes: [
|
|
1363
|
+
{
|
|
1364
|
+
name: "title",
|
|
1365
|
+
description: "The title of the suggestion. This is shown as a button and should be short.",
|
|
1366
|
+
type: "string"
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
name: "message",
|
|
1370
|
+
description: "The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.",
|
|
1371
|
+
type: "string"
|
|
1372
|
+
}
|
|
1373
|
+
]
|
|
1374
|
+
}
|
|
1375
|
+
],
|
|
1376
|
+
include: {
|
|
1377
|
+
messages: true,
|
|
1378
|
+
readable: true
|
|
1379
|
+
},
|
|
1380
|
+
abortSignal: abortController == null ? void 0 : abortController.signal,
|
|
1381
|
+
stream: ({ status, args }) => {
|
|
1382
|
+
const suggestions = args.suggestions || [];
|
|
1383
|
+
const newSuggestions = [];
|
|
1384
|
+
for (let i = 0; i < suggestions.length; i++) {
|
|
1385
|
+
if (config.maxSuggestions !== void 0 && i >= config.maxSuggestions) {
|
|
1386
|
+
break;
|
|
1387
|
+
}
|
|
1388
|
+
const { title, message } = suggestions[i];
|
|
1389
|
+
const partial = i == suggestions.length - 1 && status !== "complete";
|
|
1390
|
+
newSuggestions.push({
|
|
1391
|
+
title,
|
|
1392
|
+
message,
|
|
1393
|
+
partial,
|
|
1394
|
+
className: config.className
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
setCurrentSuggestions([...allSuggestions, ...newSuggestions]);
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
allSuggestions.push(...result.suggestions);
|
|
1401
|
+
} catch (error) {
|
|
1402
|
+
console.error("Error loading suggestions", error);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
if (abortControllerRef.current === abortController) {
|
|
1406
|
+
abortControllerRef.current = null;
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
|
|
1410
|
+
// src/components/chat/Chat.tsx
|
|
1411
|
+
var import_react9 = __toESM(require("react"));
|
|
1412
|
+
var import_react_core5 = require("@copilotkit/react-core");
|
|
1413
|
+
var import_nanoid2 = require("nanoid");
|
|
1414
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1415
|
+
function CopilotChat({
|
|
1416
|
+
instructions,
|
|
1417
|
+
onSubmitMessage,
|
|
1418
|
+
icons,
|
|
1419
|
+
labels,
|
|
1420
|
+
makeSystemMessage,
|
|
1421
|
+
showResponseButton = true,
|
|
1422
|
+
onInProgress,
|
|
1423
|
+
Messages: Messages2 = Messages,
|
|
1424
|
+
Input: Input2 = Input,
|
|
1425
|
+
ResponseButton: ResponseButton2 = ResponseButton,
|
|
1426
|
+
className
|
|
1427
|
+
}) {
|
|
1428
|
+
const { visibleMessages, isLoading, currentSuggestions, sendMessage, stop, reload } = useCopilotChatLogic(instructions, makeSystemMessage, onInProgress, onSubmitMessage);
|
|
1429
|
+
const context = import_react9.default.useContext(ChatContext);
|
|
1430
|
+
let open = true;
|
|
1431
|
+
let setOpen = () => {
|
|
1432
|
+
};
|
|
1433
|
+
if (context) {
|
|
1434
|
+
icons = context.icons;
|
|
1435
|
+
labels = context.labels;
|
|
1436
|
+
open = context.open;
|
|
1437
|
+
setOpen = context.setOpen;
|
|
1438
|
+
}
|
|
1439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChatContextProvider, { icons, labels, open, setOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `copilotKitPanel ${className}`, children: [
|
|
1440
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Messages2, { messages: visibleMessages, inProgress: isLoading, children: [
|
|
1441
|
+
currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
|
|
1442
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h6", { children: "Suggested:" }),
|
|
1443
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1444
|
+
Suggestion,
|
|
1445
|
+
{
|
|
1446
|
+
title: suggestion.title,
|
|
1447
|
+
message: suggestion.message,
|
|
1448
|
+
partial: suggestion.partial,
|
|
1449
|
+
className: suggestion.className,
|
|
1450
|
+
onClick: (message) => sendMessage(message)
|
|
1451
|
+
},
|
|
1452
|
+
index
|
|
1453
|
+
)) })
|
|
1454
|
+
] }),
|
|
1455
|
+
showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading })
|
|
1456
|
+
] }),
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible: true })
|
|
1458
|
+
] }) });
|
|
1459
|
+
}
|
|
1460
|
+
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
1461
|
+
var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
1462
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = (0, import_react_core5.useCopilotChat)({
|
|
1463
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
1464
|
+
makeSystemMessage,
|
|
1465
|
+
additionalInstructions: instructions
|
|
1466
|
+
});
|
|
1467
|
+
const [currentSuggestions, setCurrentSuggestions] = (0, import_react9.useState)([]);
|
|
1468
|
+
const suggestionsAbortControllerRef = (0, import_react9.useRef)(null);
|
|
1469
|
+
const debounceTimerRef = (0, import_react9.useRef)();
|
|
1470
|
+
const abortSuggestions = () => {
|
|
1471
|
+
var _a;
|
|
1472
|
+
(_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
|
|
1473
|
+
suggestionsAbortControllerRef.current = null;
|
|
1474
|
+
};
|
|
1475
|
+
const context = (0, import_react_core5.useCopilotContext)();
|
|
1476
|
+
(0, import_react9.useEffect)(() => {
|
|
1477
|
+
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
1478
|
+
abortSuggestions();
|
|
1479
|
+
debounceTimerRef.current = setTimeout(
|
|
1480
|
+
() => {
|
|
1481
|
+
if (!isLoading && Object.keys(context.chatSuggestionConfiguration).length !== 0) {
|
|
1482
|
+
suggestionsAbortControllerRef.current = new AbortController();
|
|
1483
|
+
reloadSuggestions(
|
|
1484
|
+
context,
|
|
1485
|
+
context.chatSuggestionConfiguration,
|
|
1486
|
+
setCurrentSuggestions,
|
|
1487
|
+
suggestionsAbortControllerRef
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
},
|
|
1491
|
+
currentSuggestions.length == 0 ? 0 : SUGGESTIONS_DEBOUNCE_TIMEOUT
|
|
1492
|
+
);
|
|
1493
|
+
return () => {
|
|
1494
|
+
clearTimeout(debounceTimerRef.current);
|
|
1495
|
+
};
|
|
1496
|
+
}, [isLoading, context.chatSuggestionConfiguration]);
|
|
1497
|
+
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
1498
|
+
abortSuggestions();
|
|
1499
|
+
setCurrentSuggestions([]);
|
|
1500
|
+
onSubmitMessage == null ? void 0 : onSubmitMessage(messageContent);
|
|
1501
|
+
const message = {
|
|
1502
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
1503
|
+
content: messageContent,
|
|
1504
|
+
role: "user"
|
|
1505
|
+
};
|
|
1506
|
+
append(message);
|
|
1507
|
+
return message;
|
|
1508
|
+
});
|
|
1509
|
+
return {
|
|
1510
|
+
visibleMessages,
|
|
1511
|
+
isLoading,
|
|
1512
|
+
currentSuggestions,
|
|
1513
|
+
sendMessage,
|
|
1514
|
+
stop,
|
|
1515
|
+
reload,
|
|
1516
|
+
input,
|
|
1517
|
+
setInput
|
|
1518
|
+
};
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
// src/components/chat/Modal.tsx
|
|
1522
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1523
|
+
var CopilotModal = ({
|
|
1169
1524
|
instructions,
|
|
1170
1525
|
defaultOpen = false,
|
|
1171
1526
|
clickOutsideToClose = true,
|
|
@@ -1187,32 +1542,16 @@ var CopilotChat = ({
|
|
|
1187
1542
|
className,
|
|
1188
1543
|
children
|
|
1189
1544
|
}) => {
|
|
1190
|
-
const
|
|
1191
|
-
id: (0, import_nanoid2.nanoid)(),
|
|
1192
|
-
makeSystemMessage,
|
|
1193
|
-
additionalInstructions: instructions
|
|
1194
|
-
});
|
|
1195
|
-
(0, import_react8.useEffect)(() => {
|
|
1196
|
-
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
1197
|
-
}, [isLoading]);
|
|
1198
|
-
const [openState, setOpenState] = import_react8.default.useState(defaultOpen);
|
|
1545
|
+
const [openState, setOpenState] = import_react10.default.useState(defaultOpen);
|
|
1199
1546
|
const setOpen = (open) => {
|
|
1200
1547
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
1201
1548
|
setOpenState(open);
|
|
1202
1549
|
};
|
|
1203
|
-
|
|
1204
|
-
onSubmitMessage == null ? void 0 : onSubmitMessage(message);
|
|
1205
|
-
append({
|
|
1206
|
-
id: (0, import_nanoid2.nanoid)(),
|
|
1207
|
-
content: message,
|
|
1208
|
-
role: "user"
|
|
1209
|
-
});
|
|
1210
|
-
});
|
|
1211
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: [
|
|
1550
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: [
|
|
1212
1551
|
children,
|
|
1213
|
-
/* @__PURE__ */ (0,
|
|
1214
|
-
/* @__PURE__ */ (0,
|
|
1215
|
-
/* @__PURE__ */ (0,
|
|
1552
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className, children: [
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button2, { open: openState, setOpen }),
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1216
1555
|
Window2,
|
|
1217
1556
|
{
|
|
1218
1557
|
open: openState,
|
|
@@ -1221,9 +1560,20 @@ var CopilotChat = ({
|
|
|
1221
1560
|
shortcut,
|
|
1222
1561
|
hitEscapeToClose,
|
|
1223
1562
|
children: [
|
|
1224
|
-
/* @__PURE__ */ (0,
|
|
1225
|
-
/* @__PURE__ */ (0,
|
|
1226
|
-
|
|
1563
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Header2, { open: openState, setOpen }),
|
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1565
|
+
CopilotChat,
|
|
1566
|
+
{
|
|
1567
|
+
instructions,
|
|
1568
|
+
makeSystemMessage,
|
|
1569
|
+
onInProgress,
|
|
1570
|
+
onSubmitMessage,
|
|
1571
|
+
showResponseButton,
|
|
1572
|
+
Messages: Messages2,
|
|
1573
|
+
Input: Input2,
|
|
1574
|
+
ResponseButton: ResponseButton2
|
|
1575
|
+
}
|
|
1576
|
+
)
|
|
1227
1577
|
]
|
|
1228
1578
|
}
|
|
1229
1579
|
)
|
|
@@ -1232,12 +1582,12 @@ var CopilotChat = ({
|
|
|
1232
1582
|
};
|
|
1233
1583
|
|
|
1234
1584
|
// src/components/chat/Sidebar.tsx
|
|
1235
|
-
var
|
|
1236
|
-
|
|
1585
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1586
|
+
function CopilotSidebar(props) {
|
|
1237
1587
|
props = __spreadProps(__spreadValues({}, props), {
|
|
1238
1588
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
1239
1589
|
});
|
|
1240
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
1590
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react11.useState)(
|
|
1241
1591
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
1242
1592
|
);
|
|
1243
1593
|
const onSetOpen = (open) => {
|
|
@@ -1245,8 +1595,8 @@ var CopilotSidebar = (props) => {
|
|
|
1245
1595
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
1246
1596
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
1247
1597
|
};
|
|
1248
|
-
return /* @__PURE__ */ (0,
|
|
1249
|
-
}
|
|
1598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
|
|
1599
|
+
}
|
|
1250
1600
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1251
1601
|
0 && (module.exports = {
|
|
1252
1602
|
CopilotSidebar
|