@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
|
@@ -79,14 +79,15 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
79
|
// src/components/chat/index.tsx
|
|
80
80
|
var chat_exports = {};
|
|
81
81
|
__export(chat_exports, {
|
|
82
|
+
CopilotChat: () => CopilotChat,
|
|
82
83
|
CopilotPopup: () => CopilotPopup,
|
|
83
84
|
CopilotSidebar: () => CopilotSidebar,
|
|
84
85
|
useChatContext: () => useChatContext
|
|
85
86
|
});
|
|
86
87
|
module.exports = __toCommonJS(chat_exports);
|
|
87
88
|
|
|
88
|
-
// src/components/chat/
|
|
89
|
-
var
|
|
89
|
+
// src/components/chat/Modal.tsx
|
|
90
|
+
var import_react10 = __toESM(require("react"));
|
|
90
91
|
|
|
91
92
|
// src/components/chat/ChatContext.tsx
|
|
92
93
|
var import_react = __toESM(require("react"));
|
|
@@ -192,6 +193,40 @@ var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
|
192
193
|
]
|
|
193
194
|
}
|
|
194
195
|
);
|
|
196
|
+
var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
197
|
+
"svg",
|
|
198
|
+
{
|
|
199
|
+
style: {
|
|
200
|
+
animation: "copilotKitSpinAnimation 1s linear infinite"
|
|
201
|
+
},
|
|
202
|
+
width: "13",
|
|
203
|
+
height: "13",
|
|
204
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
205
|
+
fill: "none",
|
|
206
|
+
viewBox: "0 0 24 24",
|
|
207
|
+
children: [
|
|
208
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
209
|
+
"circle",
|
|
210
|
+
{
|
|
211
|
+
style: { opacity: 0.25 },
|
|
212
|
+
cx: "12",
|
|
213
|
+
cy: "12",
|
|
214
|
+
r: "10",
|
|
215
|
+
stroke: "currentColor",
|
|
216
|
+
strokeWidth: "4"
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
220
|
+
"path",
|
|
221
|
+
{
|
|
222
|
+
style: { opacity: 0.75 },
|
|
223
|
+
fill: "currentColor",
|
|
224
|
+
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"
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
);
|
|
195
230
|
var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
196
231
|
"svg",
|
|
197
232
|
{
|
|
@@ -277,6 +312,25 @@ var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
|
277
312
|
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" })
|
|
278
313
|
}
|
|
279
314
|
);
|
|
315
|
+
var PushToTalkIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
316
|
+
"svg",
|
|
317
|
+
{
|
|
318
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
319
|
+
fill: "none",
|
|
320
|
+
viewBox: "0 0 24 24",
|
|
321
|
+
strokeWidth: 1.5,
|
|
322
|
+
stroke: "currentColor",
|
|
323
|
+
className: "w-6 h-6",
|
|
324
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
325
|
+
"path",
|
|
326
|
+
{
|
|
327
|
+
strokeLinecap: "round",
|
|
328
|
+
strokeLinejoin: "round",
|
|
329
|
+
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"
|
|
330
|
+
}
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
);
|
|
280
334
|
|
|
281
335
|
// src/components/chat/ChatContext.tsx
|
|
282
336
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -300,40 +354,34 @@ var ChatContextProvider = ({
|
|
|
300
354
|
open,
|
|
301
355
|
setOpen
|
|
302
356
|
}) => {
|
|
303
|
-
const context =
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
icons
|
|
325
|
-
}),
|
|
326
|
-
open,
|
|
327
|
-
setOpen
|
|
357
|
+
const context = {
|
|
358
|
+
labels: __spreadValues(__spreadValues({}, {
|
|
359
|
+
initial: "",
|
|
360
|
+
title: "CopilotKit",
|
|
361
|
+
placeholder: "Type a message...",
|
|
362
|
+
error: "\u274C An error occurred. Please try again.",
|
|
363
|
+
stopGenerating: "Stop generating",
|
|
364
|
+
regenerateResponse: "Regenerate response"
|
|
365
|
+
}), labels),
|
|
366
|
+
icons: __spreadProps(__spreadValues({}, {
|
|
367
|
+
openIcon: OpenIcon,
|
|
368
|
+
closeIcon: CloseIcon,
|
|
369
|
+
headerCloseIcon: HeaderCloseIcon,
|
|
370
|
+
sendIcon: SendIcon,
|
|
371
|
+
activityIcon: ActivityIcon,
|
|
372
|
+
spinnerIcon: SpinnerIcon,
|
|
373
|
+
stopIcon: StopIcon,
|
|
374
|
+
regenerateIcon: RegenerateIcon,
|
|
375
|
+
pushToTalkIcon: PushToTalkIcon
|
|
376
|
+
}), {
|
|
377
|
+
icons
|
|
328
378
|
}),
|
|
329
|
-
|
|
330
|
-
|
|
379
|
+
open,
|
|
380
|
+
setOpen
|
|
381
|
+
};
|
|
331
382
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
|
|
332
383
|
};
|
|
333
384
|
|
|
334
|
-
// src/components/chat/Chat.tsx
|
|
335
|
-
var import_react_core2 = require("@copilotkit/react-core");
|
|
336
|
-
|
|
337
385
|
// src/components/chat/Window.tsx
|
|
338
386
|
var import_react2 = __toESM(require("react"));
|
|
339
387
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -943,7 +991,7 @@ var components = {
|
|
|
943
991
|
// src/components/chat/Messages.tsx
|
|
944
992
|
var import_react_core = require("@copilotkit/react-core");
|
|
945
993
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
946
|
-
var Messages = ({ messages, inProgress }) => {
|
|
994
|
+
var Messages = ({ messages, inProgress, children }) => {
|
|
947
995
|
const { chatComponentsCache } = (0, import_react_core.useCopilotContext)();
|
|
948
996
|
const context = useChatContext();
|
|
949
997
|
const initialMessages = (0, import_react5.useMemo)(
|
|
@@ -1029,7 +1077,7 @@ var Messages = ({ messages, inProgress }) => {
|
|
|
1029
1077
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Markdown, { content: message.content }) }, index);
|
|
1030
1078
|
}
|
|
1031
1079
|
}),
|
|
1032
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("footer", { ref: messagesEndRef, children })
|
|
1033
1081
|
] });
|
|
1034
1082
|
};
|
|
1035
1083
|
function makeInitialMessages(initial) {
|
|
@@ -1049,7 +1097,7 @@ function makeInitialMessages(initial) {
|
|
|
1049
1097
|
}
|
|
1050
1098
|
|
|
1051
1099
|
// src/components/chat/Input.tsx
|
|
1052
|
-
var
|
|
1100
|
+
var import_react8 = require("react");
|
|
1053
1101
|
|
|
1054
1102
|
// src/components/chat/Textarea.tsx
|
|
1055
1103
|
var import_react6 = require("react");
|
|
@@ -1089,7 +1137,7 @@ var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
|
1089
1137
|
onKeyDown,
|
|
1090
1138
|
placeholder,
|
|
1091
1139
|
style: {
|
|
1092
|
-
overflow: "
|
|
1140
|
+
overflow: "auto",
|
|
1093
1141
|
resize: "none",
|
|
1094
1142
|
maxHeight: `${maxHeight}px`
|
|
1095
1143
|
},
|
|
@@ -1100,18 +1148,121 @@ var AutoResizingTextarea = (0, import_react6.forwardRef)(
|
|
|
1100
1148
|
);
|
|
1101
1149
|
var Textarea_default = AutoResizingTextarea;
|
|
1102
1150
|
|
|
1151
|
+
// src/hooks/use-push-to-talk.tsx
|
|
1152
|
+
var import_react_core2 = require("@copilotkit/react-core");
|
|
1153
|
+
var import_react7 = require("react");
|
|
1154
|
+
var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
|
|
1155
|
+
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
1156
|
+
mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
|
|
1157
|
+
audioContextRef.current = new window.AudioContext();
|
|
1158
|
+
yield audioContextRef.current.resume();
|
|
1159
|
+
}
|
|
1160
|
+
mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current);
|
|
1161
|
+
mediaRecorderRef.current.start(1e3);
|
|
1162
|
+
mediaRecorderRef.current.ondataavailable = (event) => {
|
|
1163
|
+
recordedChunks.push(event.data);
|
|
1164
|
+
};
|
|
1165
|
+
mediaRecorderRef.current.onstop = onStop;
|
|
1166
|
+
});
|
|
1167
|
+
var stopRecording = (mediaRecorderRef) => {
|
|
1168
|
+
if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
|
|
1169
|
+
mediaRecorderRef.current.stop();
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
var transcribeAudio = (recordedChunks, transcribeAudioUrl) => __async(void 0, null, function* () {
|
|
1173
|
+
const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
|
|
1174
|
+
const formData = new FormData();
|
|
1175
|
+
formData.append("file", completeBlob, "recording.mp4");
|
|
1176
|
+
const response = yield fetch(transcribeAudioUrl, {
|
|
1177
|
+
method: "POST",
|
|
1178
|
+
body: formData
|
|
1179
|
+
});
|
|
1180
|
+
if (!response.ok) {
|
|
1181
|
+
throw new Error(`Error: ${response.statusText}`);
|
|
1182
|
+
}
|
|
1183
|
+
const transcription = yield response.json();
|
|
1184
|
+
return transcription.text;
|
|
1185
|
+
});
|
|
1186
|
+
var playAudioResponse = (text, textToSpeechUrl, audioContext) => {
|
|
1187
|
+
const encodedText = encodeURIComponent(text);
|
|
1188
|
+
const url = `${textToSpeechUrl}?text=${encodedText}`;
|
|
1189
|
+
fetch(url).then((response) => response.arrayBuffer()).then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer)).then((audioBuffer) => {
|
|
1190
|
+
const source = audioContext.createBufferSource();
|
|
1191
|
+
source.buffer = audioBuffer;
|
|
1192
|
+
source.connect(audioContext.destination);
|
|
1193
|
+
source.start(0);
|
|
1194
|
+
}).catch((error) => {
|
|
1195
|
+
console.error("Error with decoding audio data", error);
|
|
1196
|
+
});
|
|
1197
|
+
};
|
|
1198
|
+
var usePushToTalk = ({
|
|
1199
|
+
sendFunction,
|
|
1200
|
+
inProgress
|
|
1201
|
+
}) => {
|
|
1202
|
+
const [pushToTalkState, setPushToTalkState] = (0, import_react7.useState)("idle");
|
|
1203
|
+
const mediaStreamRef = (0, import_react7.useRef)(null);
|
|
1204
|
+
const audioContextRef = (0, import_react7.useRef)(null);
|
|
1205
|
+
const mediaRecorderRef = (0, import_react7.useRef)(null);
|
|
1206
|
+
const recordedChunks = (0, import_react7.useRef)([]);
|
|
1207
|
+
const context = (0, import_react_core2.useCopilotContext)();
|
|
1208
|
+
const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react7.useState)(null);
|
|
1209
|
+
(0, import_react7.useEffect)(() => {
|
|
1210
|
+
if (pushToTalkState === "recording") {
|
|
1211
|
+
startRecording(
|
|
1212
|
+
mediaStreamRef,
|
|
1213
|
+
mediaRecorderRef,
|
|
1214
|
+
audioContextRef,
|
|
1215
|
+
recordedChunks.current,
|
|
1216
|
+
() => {
|
|
1217
|
+
setPushToTalkState("transcribing");
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1220
|
+
} else {
|
|
1221
|
+
stopRecording(mediaRecorderRef);
|
|
1222
|
+
if (pushToTalkState === "transcribing") {
|
|
1223
|
+
transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(
|
|
1224
|
+
(transcription) => __async(void 0, null, function* () {
|
|
1225
|
+
recordedChunks.current = [];
|
|
1226
|
+
setPushToTalkState("idle");
|
|
1227
|
+
const message = yield sendFunction(transcription);
|
|
1228
|
+
setStartReadingFromMessageId(message.id);
|
|
1229
|
+
})
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return () => {
|
|
1234
|
+
stopRecording(mediaRecorderRef);
|
|
1235
|
+
};
|
|
1236
|
+
}, [pushToTalkState]);
|
|
1237
|
+
(0, import_react7.useEffect)(() => {
|
|
1238
|
+
if (inProgress === false && startReadingFromMessageId) {
|
|
1239
|
+
const lastMessageIndex = context.messages.findIndex(
|
|
1240
|
+
(message) => message.id === startReadingFromMessageId
|
|
1241
|
+
);
|
|
1242
|
+
const messagesAfterLast = context.messages.slice(lastMessageIndex + 1).filter((message) => message.role === "assistant" && message.content);
|
|
1243
|
+
const text = messagesAfterLast.map((message) => message.content).join("\n");
|
|
1244
|
+
playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
|
|
1245
|
+
setStartReadingFromMessageId(null);
|
|
1246
|
+
}
|
|
1247
|
+
}, [startReadingFromMessageId, inProgress]);
|
|
1248
|
+
return { pushToTalkState, setPushToTalkState };
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1103
1251
|
// src/components/chat/Input.tsx
|
|
1252
|
+
var import_react_core3 = require("@copilotkit/react-core");
|
|
1104
1253
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1105
|
-
var Input = ({ inProgress, onSend,
|
|
1254
|
+
var Input = ({ inProgress, onSend, isVisible = false }) => {
|
|
1106
1255
|
const context = useChatContext();
|
|
1107
|
-
const
|
|
1256
|
+
const copilotContext = (0, import_react_core3.useCopilotContext)();
|
|
1257
|
+
const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
|
|
1258
|
+
const textareaRef = (0, import_react8.useRef)(null);
|
|
1108
1259
|
const handleDivClick = (event) => {
|
|
1109
1260
|
var _a;
|
|
1110
1261
|
if (event.target !== event.currentTarget)
|
|
1111
1262
|
return;
|
|
1112
1263
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
1113
1264
|
};
|
|
1114
|
-
const [text, setText] = (0,
|
|
1265
|
+
const [text, setText] = (0, import_react8.useState)("");
|
|
1115
1266
|
const send = () => {
|
|
1116
1267
|
var _a;
|
|
1117
1268
|
if (inProgress)
|
|
@@ -1120,17 +1271,20 @@ var Input = ({ inProgress, onSend, children, isVisible = false }) => {
|
|
|
1120
1271
|
setText("");
|
|
1121
1272
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
1122
1273
|
};
|
|
1123
|
-
(0,
|
|
1274
|
+
(0, import_react8.useEffect)(() => {
|
|
1124
1275
|
var _a;
|
|
1125
1276
|
if (isVisible) {
|
|
1126
1277
|
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
1127
1278
|
}
|
|
1128
1279
|
}, [isVisible]);
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1280
|
+
const { pushToTalkState, setPushToTalkState } = usePushToTalk({
|
|
1281
|
+
sendFunction: onSend,
|
|
1282
|
+
inProgress
|
|
1283
|
+
});
|
|
1284
|
+
const sendIcon = inProgress || pushToTalkState === "transcribing" ? context.icons.activityIcon : context.icons.sendIcon;
|
|
1285
|
+
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
1286
|
+
const sendDisabled = inProgress || text.length === 0 || pushToTalkState !== "idle";
|
|
1131
1287
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
1132
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children }),
|
|
1133
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
|
|
1134
1288
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1135
1289
|
Textarea_default,
|
|
1136
1290
|
{
|
|
@@ -1147,13 +1301,21 @@ var Input = ({ inProgress, onSend, children, isVisible = false }) => {
|
|
|
1147
1301
|
}
|
|
1148
1302
|
}
|
|
1149
1303
|
}
|
|
1150
|
-
)
|
|
1304
|
+
),
|
|
1305
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInputControls", children: [
|
|
1306
|
+
showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1307
|
+
"button",
|
|
1308
|
+
{
|
|
1309
|
+
onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
|
|
1310
|
+
className: pushToTalkState === "recording" ? "copilotKitPushToTalkRecording" : "",
|
|
1311
|
+
children: context.icons.pushToTalkIcon
|
|
1312
|
+
}
|
|
1313
|
+
),
|
|
1314
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { disabled: sendDisabled, onClick: send, children: sendIcon })
|
|
1315
|
+
] })
|
|
1151
1316
|
] });
|
|
1152
1317
|
};
|
|
1153
1318
|
|
|
1154
|
-
// src/components/chat/Chat.tsx
|
|
1155
|
-
var import_nanoid2 = require("nanoid");
|
|
1156
|
-
|
|
1157
1319
|
// src/components/chat/Response.tsx
|
|
1158
1320
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1159
1321
|
var ResponseButton = ({ onClick, inProgress }) => {
|
|
@@ -1164,9 +1326,203 @@ var ResponseButton = ({ onClick, inProgress }) => {
|
|
|
1164
1326
|
] });
|
|
1165
1327
|
};
|
|
1166
1328
|
|
|
1167
|
-
// src/components/chat/
|
|
1329
|
+
// src/components/chat/Suggestion.tsx
|
|
1330
|
+
var import_react_core4 = require("@copilotkit/react-core");
|
|
1168
1331
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1169
|
-
|
|
1332
|
+
function Suggestion({ title, message, onClick, partial, className }) {
|
|
1333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1334
|
+
"button",
|
|
1335
|
+
{
|
|
1336
|
+
disabled: partial,
|
|
1337
|
+
onClick: (e) => {
|
|
1338
|
+
e.preventDefault();
|
|
1339
|
+
onClick(message);
|
|
1340
|
+
},
|
|
1341
|
+
className: className || "suggestion",
|
|
1342
|
+
children: [
|
|
1343
|
+
partial && SmallSpinnerIcon,
|
|
1344
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: title })
|
|
1345
|
+
]
|
|
1346
|
+
}
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggestions, abortControllerRef) => __async(void 0, null, function* () {
|
|
1350
|
+
const abortController = abortControllerRef.current;
|
|
1351
|
+
const tools = JSON.stringify(context.getChatCompletionFunctionDescriptions(context.entryPoints));
|
|
1352
|
+
const allSuggestions = [];
|
|
1353
|
+
for (const config of Object.values(chatSuggestionConfiguration)) {
|
|
1354
|
+
try {
|
|
1355
|
+
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.`;
|
|
1356
|
+
const result = yield (0, import_react_core4.extract)({
|
|
1357
|
+
context,
|
|
1358
|
+
instructions: "Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. " + config.instructions + "\n\n" + numOfSuggestionsInstructions,
|
|
1359
|
+
data: "Available tools: " + tools + "\n\n",
|
|
1360
|
+
parameters: [
|
|
1361
|
+
{
|
|
1362
|
+
name: "suggestions",
|
|
1363
|
+
type: "object[]",
|
|
1364
|
+
attributes: [
|
|
1365
|
+
{
|
|
1366
|
+
name: "title",
|
|
1367
|
+
description: "The title of the suggestion. This is shown as a button and should be short.",
|
|
1368
|
+
type: "string"
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
name: "message",
|
|
1372
|
+
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.",
|
|
1373
|
+
type: "string"
|
|
1374
|
+
}
|
|
1375
|
+
]
|
|
1376
|
+
}
|
|
1377
|
+
],
|
|
1378
|
+
include: {
|
|
1379
|
+
messages: true,
|
|
1380
|
+
readable: true
|
|
1381
|
+
},
|
|
1382
|
+
abortSignal: abortController == null ? void 0 : abortController.signal,
|
|
1383
|
+
stream: ({ status, args }) => {
|
|
1384
|
+
const suggestions = args.suggestions || [];
|
|
1385
|
+
const newSuggestions = [];
|
|
1386
|
+
for (let i = 0; i < suggestions.length; i++) {
|
|
1387
|
+
if (config.maxSuggestions !== void 0 && i >= config.maxSuggestions) {
|
|
1388
|
+
break;
|
|
1389
|
+
}
|
|
1390
|
+
const { title, message } = suggestions[i];
|
|
1391
|
+
const partial = i == suggestions.length - 1 && status !== "complete";
|
|
1392
|
+
newSuggestions.push({
|
|
1393
|
+
title,
|
|
1394
|
+
message,
|
|
1395
|
+
partial,
|
|
1396
|
+
className: config.className
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
setCurrentSuggestions([...allSuggestions, ...newSuggestions]);
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
allSuggestions.push(...result.suggestions);
|
|
1403
|
+
} catch (error) {
|
|
1404
|
+
console.error("Error loading suggestions", error);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
if (abortControllerRef.current === abortController) {
|
|
1408
|
+
abortControllerRef.current = null;
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
|
|
1412
|
+
// src/components/chat/Chat.tsx
|
|
1413
|
+
var import_react9 = __toESM(require("react"));
|
|
1414
|
+
var import_react_core5 = require("@copilotkit/react-core");
|
|
1415
|
+
var import_nanoid2 = require("nanoid");
|
|
1416
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1417
|
+
function CopilotChat({
|
|
1418
|
+
instructions,
|
|
1419
|
+
onSubmitMessage,
|
|
1420
|
+
icons,
|
|
1421
|
+
labels,
|
|
1422
|
+
makeSystemMessage,
|
|
1423
|
+
showResponseButton = true,
|
|
1424
|
+
onInProgress,
|
|
1425
|
+
Messages: Messages2 = Messages,
|
|
1426
|
+
Input: Input2 = Input,
|
|
1427
|
+
ResponseButton: ResponseButton2 = ResponseButton,
|
|
1428
|
+
className
|
|
1429
|
+
}) {
|
|
1430
|
+
const { visibleMessages, isLoading, currentSuggestions, sendMessage, stop, reload } = useCopilotChatLogic(instructions, makeSystemMessage, onInProgress, onSubmitMessage);
|
|
1431
|
+
const context = import_react9.default.useContext(ChatContext);
|
|
1432
|
+
let open = true;
|
|
1433
|
+
let setOpen = () => {
|
|
1434
|
+
};
|
|
1435
|
+
if (context) {
|
|
1436
|
+
icons = context.icons;
|
|
1437
|
+
labels = context.labels;
|
|
1438
|
+
open = context.open;
|
|
1439
|
+
setOpen = context.setOpen;
|
|
1440
|
+
}
|
|
1441
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChatContextProvider, { icons, labels, open, setOpen, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `copilotKitPanel ${className}`, children: [
|
|
1442
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Messages2, { messages: visibleMessages, inProgress: isLoading, children: [
|
|
1443
|
+
currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
|
|
1444
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h6", { children: "Suggested:" }),
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "suggestions", children: currentSuggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1446
|
+
Suggestion,
|
|
1447
|
+
{
|
|
1448
|
+
title: suggestion.title,
|
|
1449
|
+
message: suggestion.message,
|
|
1450
|
+
partial: suggestion.partial,
|
|
1451
|
+
className: suggestion.className,
|
|
1452
|
+
onClick: (message) => sendMessage(message)
|
|
1453
|
+
},
|
|
1454
|
+
index
|
|
1455
|
+
)) })
|
|
1456
|
+
] }),
|
|
1457
|
+
showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading })
|
|
1458
|
+
] }),
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible: true })
|
|
1460
|
+
] }) });
|
|
1461
|
+
}
|
|
1462
|
+
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
1463
|
+
var useCopilotChatLogic = (instructions, makeSystemMessage, onInProgress, onSubmitMessage) => {
|
|
1464
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = (0, import_react_core5.useCopilotChat)({
|
|
1465
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
1466
|
+
makeSystemMessage,
|
|
1467
|
+
additionalInstructions: instructions
|
|
1468
|
+
});
|
|
1469
|
+
const [currentSuggestions, setCurrentSuggestions] = (0, import_react9.useState)([]);
|
|
1470
|
+
const suggestionsAbortControllerRef = (0, import_react9.useRef)(null);
|
|
1471
|
+
const debounceTimerRef = (0, import_react9.useRef)();
|
|
1472
|
+
const abortSuggestions = () => {
|
|
1473
|
+
var _a;
|
|
1474
|
+
(_a = suggestionsAbortControllerRef.current) == null ? void 0 : _a.abort();
|
|
1475
|
+
suggestionsAbortControllerRef.current = null;
|
|
1476
|
+
};
|
|
1477
|
+
const context = (0, import_react_core5.useCopilotContext)();
|
|
1478
|
+
(0, import_react9.useEffect)(() => {
|
|
1479
|
+
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
1480
|
+
abortSuggestions();
|
|
1481
|
+
debounceTimerRef.current = setTimeout(
|
|
1482
|
+
() => {
|
|
1483
|
+
if (!isLoading && Object.keys(context.chatSuggestionConfiguration).length !== 0) {
|
|
1484
|
+
suggestionsAbortControllerRef.current = new AbortController();
|
|
1485
|
+
reloadSuggestions(
|
|
1486
|
+
context,
|
|
1487
|
+
context.chatSuggestionConfiguration,
|
|
1488
|
+
setCurrentSuggestions,
|
|
1489
|
+
suggestionsAbortControllerRef
|
|
1490
|
+
);
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
currentSuggestions.length == 0 ? 0 : SUGGESTIONS_DEBOUNCE_TIMEOUT
|
|
1494
|
+
);
|
|
1495
|
+
return () => {
|
|
1496
|
+
clearTimeout(debounceTimerRef.current);
|
|
1497
|
+
};
|
|
1498
|
+
}, [isLoading, context.chatSuggestionConfiguration]);
|
|
1499
|
+
const sendMessage = (messageContent) => __async(void 0, null, function* () {
|
|
1500
|
+
abortSuggestions();
|
|
1501
|
+
setCurrentSuggestions([]);
|
|
1502
|
+
onSubmitMessage == null ? void 0 : onSubmitMessage(messageContent);
|
|
1503
|
+
const message = {
|
|
1504
|
+
id: (0, import_nanoid2.nanoid)(),
|
|
1505
|
+
content: messageContent,
|
|
1506
|
+
role: "user"
|
|
1507
|
+
};
|
|
1508
|
+
append(message);
|
|
1509
|
+
return message;
|
|
1510
|
+
});
|
|
1511
|
+
return {
|
|
1512
|
+
visibleMessages,
|
|
1513
|
+
isLoading,
|
|
1514
|
+
currentSuggestions,
|
|
1515
|
+
sendMessage,
|
|
1516
|
+
stop,
|
|
1517
|
+
reload,
|
|
1518
|
+
input,
|
|
1519
|
+
setInput
|
|
1520
|
+
};
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
// src/components/chat/Modal.tsx
|
|
1524
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1525
|
+
var CopilotModal = ({
|
|
1170
1526
|
instructions,
|
|
1171
1527
|
defaultOpen = false,
|
|
1172
1528
|
clickOutsideToClose = true,
|
|
@@ -1188,32 +1544,16 @@ var CopilotChat = ({
|
|
|
1188
1544
|
className,
|
|
1189
1545
|
children
|
|
1190
1546
|
}) => {
|
|
1191
|
-
const
|
|
1192
|
-
id: (0, import_nanoid2.nanoid)(),
|
|
1193
|
-
makeSystemMessage,
|
|
1194
|
-
additionalInstructions: instructions
|
|
1195
|
-
});
|
|
1196
|
-
(0, import_react8.useEffect)(() => {
|
|
1197
|
-
onInProgress == null ? void 0 : onInProgress(isLoading);
|
|
1198
|
-
}, [isLoading]);
|
|
1199
|
-
const [openState, setOpenState] = import_react8.default.useState(defaultOpen);
|
|
1547
|
+
const [openState, setOpenState] = import_react10.default.useState(defaultOpen);
|
|
1200
1548
|
const setOpen = (open) => {
|
|
1201
1549
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
1202
1550
|
setOpenState(open);
|
|
1203
1551
|
};
|
|
1204
|
-
|
|
1205
|
-
onSubmitMessage == null ? void 0 : onSubmitMessage(message);
|
|
1206
|
-
append({
|
|
1207
|
-
id: (0, import_nanoid2.nanoid)(),
|
|
1208
|
-
content: message,
|
|
1209
|
-
role: "user"
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: [
|
|
1552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: [
|
|
1213
1553
|
children,
|
|
1214
|
-
/* @__PURE__ */ (0,
|
|
1215
|
-
/* @__PURE__ */ (0,
|
|
1216
|
-
/* @__PURE__ */ (0,
|
|
1554
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className, children: [
|
|
1555
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button2, { open: openState, setOpen }),
|
|
1556
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1217
1557
|
Window2,
|
|
1218
1558
|
{
|
|
1219
1559
|
open: openState,
|
|
@@ -1222,9 +1562,20 @@ var CopilotChat = ({
|
|
|
1222
1562
|
shortcut,
|
|
1223
1563
|
hitEscapeToClose,
|
|
1224
1564
|
children: [
|
|
1225
|
-
/* @__PURE__ */ (0,
|
|
1226
|
-
/* @__PURE__ */ (0,
|
|
1227
|
-
|
|
1565
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Header2, { open: openState, setOpen }),
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1567
|
+
CopilotChat,
|
|
1568
|
+
{
|
|
1569
|
+
instructions,
|
|
1570
|
+
makeSystemMessage,
|
|
1571
|
+
onInProgress,
|
|
1572
|
+
onSubmitMessage,
|
|
1573
|
+
showResponseButton,
|
|
1574
|
+
Messages: Messages2,
|
|
1575
|
+
Input: Input2,
|
|
1576
|
+
ResponseButton: ResponseButton2
|
|
1577
|
+
}
|
|
1578
|
+
)
|
|
1228
1579
|
]
|
|
1229
1580
|
}
|
|
1230
1581
|
)
|
|
@@ -1233,22 +1584,22 @@ var CopilotChat = ({
|
|
|
1233
1584
|
};
|
|
1234
1585
|
|
|
1235
1586
|
// src/components/chat/Popup.tsx
|
|
1236
|
-
var
|
|
1237
|
-
|
|
1587
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1588
|
+
function CopilotPopup(props) {
|
|
1238
1589
|
props = __spreadProps(__spreadValues({}, props), {
|
|
1239
1590
|
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
1240
1591
|
});
|
|
1241
|
-
return /* @__PURE__ */ (0,
|
|
1242
|
-
}
|
|
1592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
|
|
1593
|
+
}
|
|
1243
1594
|
|
|
1244
1595
|
// src/components/chat/Sidebar.tsx
|
|
1245
|
-
var
|
|
1246
|
-
var
|
|
1247
|
-
|
|
1596
|
+
var import_react11 = require("react");
|
|
1597
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1598
|
+
function CopilotSidebar(props) {
|
|
1248
1599
|
props = __spreadProps(__spreadValues({}, props), {
|
|
1249
1600
|
className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
|
|
1250
1601
|
});
|
|
1251
|
-
const [expandedClassName, setExpandedClassName] = (0,
|
|
1602
|
+
const [expandedClassName, setExpandedClassName] = (0, import_react11.useState)(
|
|
1252
1603
|
props.defaultOpen ? "sidebarExpanded" : ""
|
|
1253
1604
|
);
|
|
1254
1605
|
const onSetOpen = (open) => {
|
|
@@ -1256,10 +1607,11 @@ var CopilotSidebar = (props) => {
|
|
|
1256
1607
|
(_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
|
|
1257
1608
|
setExpandedClassName(open ? "sidebarExpanded" : "");
|
|
1258
1609
|
};
|
|
1259
|
-
return /* @__PURE__ */ (0,
|
|
1260
|
-
}
|
|
1610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
|
|
1611
|
+
}
|
|
1261
1612
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1262
1613
|
0 && (module.exports = {
|
|
1614
|
+
CopilotChat,
|
|
1263
1615
|
CopilotPopup,
|
|
1264
1616
|
CopilotSidebar,
|
|
1265
1617
|
useChatContext
|