@copilotkit/react-ui 0.14.0-alpha.4 → 0.14.0-alpha.5
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 +112 -116
- package/CHANGELOG.md +11 -0
- package/dist/components/chat-components/chat-list.mjs +440 -12
- package/dist/components/chat-components/chat-list.mjs.map +1 -1
- package/dist/components/chat-components/chat-message-actions.mjs +168 -7
- package/dist/components/chat-components/chat-message-actions.mjs.map +1 -1
- package/dist/components/chat-components/chat-message.mjs +403 -10
- package/dist/components/chat-components/chat-message.mjs.map +1 -1
- package/dist/components/chat-components/chat-panel.mjs +301 -9
- package/dist/components/chat-components/chat-panel.mjs.map +1 -1
- package/dist/components/chat-components/chat-scroll-anchor.mjs +44 -4
- package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -1
- package/dist/components/chat-components/clear-history.mjs +249 -25
- package/dist/components/chat-components/clear-history.mjs.map +1 -1
- package/dist/components/chat-components/copilot-chat.mjs +809 -21
- package/dist/components/chat-components/copilot-chat.mjs.map +1 -1
- package/dist/components/chat-components/default-empty-screen.mjs +175 -7
- package/dist/components/chat-components/default-empty-screen.mjs.map +1 -1
- package/dist/components/chat-components/external-link.mjs +25 -3
- package/dist/components/chat-components/external-link.mjs.map +1 -1
- package/dist/components/chat-components/markdown.mjs +10 -3
- package/dist/components/chat-components/markdown.mjs.map +1 -1
- package/dist/components/chat-components/prompt-form.mjs +227 -8
- package/dist/components/chat-components/prompt-form.mjs.map +1 -1
- package/dist/components/chat-components/theme-toggle.mjs +130 -14
- package/dist/components/chat-components/theme-toggle.mjs.map +1 -1
- package/dist/components/chat-components/toaster.mjs +7 -3
- package/dist/components/chat-components/toaster.mjs.map +1 -1
- package/dist/components/chat-components/ui/alert-dialog.mjs +199 -5
- package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -1
- package/dist/components/chat-components/ui/badge.mjs +49 -7
- package/dist/components/chat-components/ui/badge.mjs.map +1 -1
- package/dist/components/chat-components/ui/button.mjs +85 -4
- package/dist/components/chat-components/ui/button.mjs.map +1 -1
- package/dist/components/chat-components/ui/codeblock.mjs +283 -7
- package/dist/components/chat-components/ui/codeblock.mjs.map +1 -1
- package/dist/components/chat-components/ui/dialog.mjs +93 -25
- package/dist/components/chat-components/ui/dialog.mjs.map +1 -1
- package/dist/components/chat-components/ui/dropdown-menu.mjs +61 -8
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -1
- package/dist/components/chat-components/ui/icons.mjs +554 -4
- package/dist/components/chat-components/ui/icons.mjs.map +1 -1
- package/dist/components/chat-components/ui/input.mjs +48 -7
- package/dist/components/chat-components/ui/input.mjs.map +1 -1
- package/dist/components/chat-components/ui/label.mjs +51 -9
- package/dist/components/chat-components/ui/label.mjs.map +1 -1
- package/dist/components/chat-components/ui/select.mjs +106 -23
- package/dist/components/chat-components/ui/select.mjs.map +1 -1
- package/dist/components/chat-components/ui/separator.mjs +68 -4
- package/dist/components/chat-components/ui/separator.mjs.map +1 -1
- package/dist/components/chat-components/ui/sheet.mjs +92 -23
- package/dist/components/chat-components/ui/sheet.mjs.map +1 -1
- package/dist/components/chat-components/ui/switch.mjs +53 -8
- package/dist/components/chat-components/ui/switch.mjs.map +1 -1
- package/dist/components/chat-components/ui/textarea.mjs +48 -7
- package/dist/components/chat-components/ui/textarea.mjs.map +1 -1
- package/dist/components/chat-components/ui/tooltip.mjs +72 -4
- package/dist/components/chat-components/ui/tooltip.mjs.map +1 -1
- package/dist/components/index.mjs +925 -25
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +920 -24
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -1
- package/dist/components/sidebar/copilot-sidebar.mjs +842 -22
- package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -1
- package/dist/components/sidebar/sidebar-context.mjs +10 -3
- package/dist/components/sidebar/sidebar-context.mjs.map +1 -1
- package/dist/context/index.mjs +0 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/index.mjs +0 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/use-at-bottom.mjs +19 -3
- package/dist/hooks/use-at-bottom.mjs.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +26 -3
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
- package/dist/hooks/use-enter-submit.mjs +16 -3
- package/dist/hooks/use-enter-submit.mjs.map +1 -1
- package/dist/index.mjs +925 -28
- package/dist/index.mjs.map +1 -1
- package/dist/lib/utils.mjs +62 -3
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +1 -1
- package/dist/types/types.mjs +0 -2
- package/dist/types/types.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-2KAF7NKC.mjs +0 -484
- package/dist/chunk-2KAF7NKC.mjs.map +0 -1
- package/dist/chunk-5KEDV5VC.mjs +0 -27
- package/dist/chunk-5KEDV5VC.mjs.map +0 -1
- package/dist/chunk-6LAZQHEB.mjs +0 -129
- package/dist/chunk-6LAZQHEB.mjs.map +0 -1
- package/dist/chunk-7NSRDJ5C.mjs +0 -3
- package/dist/chunk-7NSRDJ5C.mjs.map +0 -1
- package/dist/chunk-C34L4AWW.mjs +0 -39
- package/dist/chunk-C34L4AWW.mjs.map +0 -1
- package/dist/chunk-CF3BK4OX.mjs +0 -53
- package/dist/chunk-CF3BK4OX.mjs.map +0 -1
- package/dist/chunk-CNQX2VY3.mjs +0 -66
- package/dist/chunk-CNQX2VY3.mjs.map +0 -1
- package/dist/chunk-GCOPYGHH.mjs +0 -27
- package/dist/chunk-GCOPYGHH.mjs.map +0 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -3
- package/dist/chunk-H4VKQGVU.mjs.map +0 -1
- package/dist/chunk-IJLMKBSZ.mjs +0 -25
- package/dist/chunk-IJLMKBSZ.mjs.map +0 -1
- package/dist/chunk-INCNMGJ7.mjs +0 -72
- package/dist/chunk-INCNMGJ7.mjs.map +0 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -3
- package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
- package/dist/chunk-M3CZWJI3.mjs +0 -44
- package/dist/chunk-M3CZWJI3.mjs.map +0 -1
- package/dist/chunk-MC6KTH4X.mjs +0 -12
- package/dist/chunk-MC6KTH4X.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs +0 -55
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-OHWEJUCS.mjs +0 -18
- package/dist/chunk-OHWEJUCS.mjs.map +0 -1
- package/dist/chunk-OOBQC5H6.mjs +0 -34
- package/dist/chunk-OOBQC5H6.mjs.map +0 -1
- package/dist/chunk-POVINPXX.mjs +0 -26
- package/dist/chunk-POVINPXX.mjs.map +0 -1
- package/dist/chunk-Q6YO7LDK.mjs +0 -40
- package/dist/chunk-Q6YO7LDK.mjs.map +0 -1
- package/dist/chunk-RPTRCFSO.mjs +0 -42
- package/dist/chunk-RPTRCFSO.mjs.map +0 -1
- package/dist/chunk-SEH5PQVW.mjs +0 -52
- package/dist/chunk-SEH5PQVW.mjs.map +0 -1
- package/dist/chunk-SHOTWRKC.mjs +0 -18
- package/dist/chunk-SHOTWRKC.mjs.map +0 -1
- package/dist/chunk-SRBUGQTM.mjs +0 -109
- package/dist/chunk-SRBUGQTM.mjs.map +0 -1
- package/dist/chunk-TEYIQHMK.mjs +0 -12
- package/dist/chunk-TEYIQHMK.mjs.map +0 -1
- package/dist/chunk-U6NJWGTV.mjs +0 -3
- package/dist/chunk-U6NJWGTV.mjs.map +0 -1
- package/dist/chunk-VGX2W5ZB.mjs +0 -28
- package/dist/chunk-VGX2W5ZB.mjs.map +0 -1
- package/dist/chunk-XGUBRIUV.mjs +0 -72
- package/dist/chunk-XGUBRIUV.mjs.map +0 -1
- package/dist/chunk-ZYC5YVDO.mjs +0 -21
- package/dist/chunk-ZYC5YVDO.mjs.map +0 -1
|
@@ -1,26 +1,926 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/components/chat-components/ui/separator.tsx
|
|
54
|
+
import * as React from "react";
|
|
55
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
56
|
+
|
|
57
|
+
// src/lib/utils.ts
|
|
58
|
+
import { clsx } from "clsx";
|
|
59
|
+
import { customAlphabet } from "nanoid";
|
|
60
|
+
import { twMerge } from "tailwind-merge";
|
|
61
|
+
function cn(...inputs) {
|
|
62
|
+
return twMerge(clsx(inputs));
|
|
63
|
+
}
|
|
64
|
+
var nanoid = customAlphabet(
|
|
65
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
66
|
+
7
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// src/components/chat-components/ui/separator.tsx
|
|
70
|
+
import { jsx } from "react/jsx-runtime";
|
|
71
|
+
var Separator = React.forwardRef((_a, ref) => {
|
|
72
|
+
var _b = _a, { className, orientation = "horizontal", decorative = true } = _b, props = __objRest(_b, ["className", "orientation", "decorative"]);
|
|
73
|
+
return /* @__PURE__ */ jsx(
|
|
74
|
+
SeparatorPrimitive.Root,
|
|
75
|
+
__spreadValues({
|
|
76
|
+
ref,
|
|
77
|
+
decorative,
|
|
78
|
+
orientation,
|
|
79
|
+
className: cn(
|
|
80
|
+
"shrink-0 bg-border",
|
|
81
|
+
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
82
|
+
className
|
|
83
|
+
)
|
|
84
|
+
}, props)
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
88
|
+
|
|
89
|
+
// src/components/chat-components/chat-message.tsx
|
|
90
|
+
import remarkGfm from "remark-gfm";
|
|
91
|
+
import remarkMath from "remark-math";
|
|
92
|
+
|
|
93
|
+
// src/components/chat-components/ui/codeblock.tsx
|
|
94
|
+
import { memo } from "react";
|
|
95
|
+
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
|
|
96
|
+
|
|
97
|
+
// src/hooks/use-copy-to-clipboard.tsx
|
|
98
|
+
import * as React2 from "react";
|
|
99
|
+
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
100
|
+
const [isCopied, setIsCopied] = React2.useState(false);
|
|
101
|
+
const copyToClipboard = (value) => {
|
|
102
|
+
var _a;
|
|
103
|
+
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!value) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
navigator.clipboard.writeText(value).then(() => {
|
|
110
|
+
setIsCopied(true);
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
setIsCopied(false);
|
|
113
|
+
}, timeout);
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
return { isCopied, copyToClipboard };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/components/chat-components/ui/icons.tsx
|
|
120
|
+
import * as React3 from "react";
|
|
121
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
122
|
+
function IconOpenAI(_a) {
|
|
123
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
124
|
+
return /* @__PURE__ */ jsxs(
|
|
125
|
+
"svg",
|
|
126
|
+
__spreadProps(__spreadValues({
|
|
127
|
+
fill: "currentColor",
|
|
128
|
+
viewBox: "0 0 24 24",
|
|
129
|
+
role: "img",
|
|
130
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
131
|
+
className: cn("h-4 w-4", className)
|
|
132
|
+
}, props), {
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx2("title", { children: "OpenAI icon" }),
|
|
135
|
+
/* @__PURE__ */ jsx2("path", { d: "M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z" })
|
|
136
|
+
]
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function IconArrowRight(_a) {
|
|
141
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
142
|
+
return /* @__PURE__ */ jsx2(
|
|
143
|
+
"svg",
|
|
144
|
+
__spreadProps(__spreadValues({
|
|
145
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
146
|
+
viewBox: "0 0 256 256",
|
|
147
|
+
fill: "currentColor",
|
|
148
|
+
className: cn("h-4 w-4", className)
|
|
149
|
+
}, props), {
|
|
150
|
+
children: /* @__PURE__ */ jsx2("path", { d: "m221.66 133.66-72 72a8 8 0 0 1-11.32-11.32L196.69 136H40a8 8 0 0 1 0-16h156.69l-58.35-58.34a8 8 0 0 1 11.32-11.32l72 72a8 8 0 0 1 0 11.32Z" })
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function IconUser(_a) {
|
|
155
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
156
|
+
return /* @__PURE__ */ jsx2(
|
|
157
|
+
"svg",
|
|
158
|
+
__spreadProps(__spreadValues({
|
|
159
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
160
|
+
viewBox: "0 0 256 256",
|
|
161
|
+
fill: "currentColor",
|
|
162
|
+
className: cn("h-4 w-4", className)
|
|
163
|
+
}, props), {
|
|
164
|
+
children: /* @__PURE__ */ jsx2("path", { d: "M230.92 212c-15.23-26.33-38.7-45.21-66.09-54.16a72 72 0 1 0-73.66 0c-27.39 8.94-50.86 27.82-66.09 54.16a8 8 0 1 0 13.85 8c18.84-32.56 52.14-52 89.07-52s70.23 19.44 89.07 52a8 8 0 1 0 13.85-8ZM72 96a56 56 0 1 1 56 56 56.06 56.06 0 0 1-56-56Z" })
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
function IconArrowElbow(_a) {
|
|
169
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
170
|
+
return /* @__PURE__ */ jsx2(
|
|
171
|
+
"svg",
|
|
172
|
+
__spreadProps(__spreadValues({
|
|
173
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
174
|
+
viewBox: "0 0 256 256",
|
|
175
|
+
fill: "currentColor",
|
|
176
|
+
className: cn("h-4 w-4", className)
|
|
177
|
+
}, props), {
|
|
178
|
+
children: /* @__PURE__ */ jsx2("path", { d: "M200 32v144a8 8 0 0 1-8 8H67.31l34.35 34.34a8 8 0 0 1-11.32 11.32l-48-48a8 8 0 0 1 0-11.32l48-48a8 8 0 0 1 11.32 11.32L67.31 168H184V32a8 8 0 0 1 16 0Z" })
|
|
179
|
+
})
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
function IconRefresh(_a) {
|
|
183
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
184
|
+
return /* @__PURE__ */ jsx2(
|
|
185
|
+
"svg",
|
|
186
|
+
__spreadProps(__spreadValues({
|
|
187
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
188
|
+
viewBox: "0 0 256 256",
|
|
189
|
+
fill: "currentColor",
|
|
190
|
+
className: cn("h-4 w-4", className)
|
|
191
|
+
}, props), {
|
|
192
|
+
children: /* @__PURE__ */ jsx2("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" })
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
function IconStop(_a) {
|
|
197
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
198
|
+
return /* @__PURE__ */ jsx2(
|
|
199
|
+
"svg",
|
|
200
|
+
__spreadProps(__spreadValues({
|
|
201
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
202
|
+
viewBox: "0 0 256 256",
|
|
203
|
+
fill: "currentColor",
|
|
204
|
+
className: cn("h-4 w-4", className)
|
|
205
|
+
}, props), {
|
|
206
|
+
children: /* @__PURE__ */ jsx2("path", { d: "M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z" })
|
|
207
|
+
})
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
function IconCopy(_a) {
|
|
211
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
212
|
+
return /* @__PURE__ */ jsx2(
|
|
213
|
+
"svg",
|
|
214
|
+
__spreadProps(__spreadValues({
|
|
215
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
216
|
+
viewBox: "0 0 256 256",
|
|
217
|
+
fill: "currentColor",
|
|
218
|
+
className: cn("h-4 w-4", className)
|
|
219
|
+
}, props), {
|
|
220
|
+
children: /* @__PURE__ */ jsx2("path", { d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" })
|
|
221
|
+
})
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
function IconCheck(_a) {
|
|
225
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
226
|
+
return /* @__PURE__ */ jsx2(
|
|
227
|
+
"svg",
|
|
228
|
+
__spreadProps(__spreadValues({
|
|
229
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
230
|
+
viewBox: "0 0 256 256",
|
|
231
|
+
fill: "currentColor",
|
|
232
|
+
className: cn("h-4 w-4", className)
|
|
233
|
+
}, props), {
|
|
234
|
+
children: /* @__PURE__ */ jsx2("path", { d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" })
|
|
235
|
+
})
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
function IconDownload(_a) {
|
|
239
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
240
|
+
return /* @__PURE__ */ jsx2(
|
|
241
|
+
"svg",
|
|
242
|
+
__spreadProps(__spreadValues({
|
|
243
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
244
|
+
viewBox: "0 0 256 256",
|
|
245
|
+
fill: "currentColor",
|
|
246
|
+
className: cn("h-4 w-4", className)
|
|
247
|
+
}, props), {
|
|
248
|
+
children: /* @__PURE__ */ jsx2("path", { d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" })
|
|
249
|
+
})
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/components/chat-components/ui/button.tsx
|
|
254
|
+
import * as React4 from "react";
|
|
255
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
256
|
+
import { cva } from "class-variance-authority";
|
|
257
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
258
|
+
var buttonVariants = cva(
|
|
259
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
260
|
+
{
|
|
261
|
+
variants: {
|
|
262
|
+
variant: {
|
|
263
|
+
default: "bg-primary text-primary-foreground shadow-md hover:bg-primary/90",
|
|
264
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
265
|
+
outline: "border border-input hover:bg-accent hover:text-accent-foreground",
|
|
266
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
267
|
+
ghost: "shadow-none hover:bg-accent hover:text-accent-foreground",
|
|
268
|
+
link: "text-primary underline-offset-4 shadow-none hover:underline"
|
|
269
|
+
},
|
|
270
|
+
size: {
|
|
271
|
+
default: "h-8 px-4 py-2",
|
|
272
|
+
sm: "h-8 rounded-md px-3",
|
|
273
|
+
lg: "h-11 rounded-md px-8",
|
|
274
|
+
icon: "h-8 w-8 p-0"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
defaultVariants: {
|
|
278
|
+
variant: "default",
|
|
279
|
+
size: "default"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
var Button = React4.forwardRef(
|
|
284
|
+
(_a, ref) => {
|
|
285
|
+
var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
|
|
286
|
+
const Comp = asChild ? Slot : "button";
|
|
287
|
+
return /* @__PURE__ */ jsx3(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
Button.displayName = "Button";
|
|
291
|
+
|
|
292
|
+
// src/components/chat-components/ui/codeblock.tsx
|
|
293
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
294
|
+
var programmingLanguages = {
|
|
295
|
+
javascript: ".js",
|
|
296
|
+
python: ".py",
|
|
297
|
+
java: ".java",
|
|
298
|
+
c: ".c",
|
|
299
|
+
cpp: ".cpp",
|
|
300
|
+
"c++": ".cpp",
|
|
301
|
+
"c#": ".cs",
|
|
302
|
+
ruby: ".rb",
|
|
303
|
+
php: ".php",
|
|
304
|
+
swift: ".swift",
|
|
305
|
+
"objective-c": ".m",
|
|
306
|
+
kotlin: ".kt",
|
|
307
|
+
typescript: ".ts",
|
|
308
|
+
go: ".go",
|
|
309
|
+
perl: ".pl",
|
|
310
|
+
rust: ".rs",
|
|
311
|
+
scala: ".scala",
|
|
312
|
+
haskell: ".hs",
|
|
313
|
+
lua: ".lua",
|
|
314
|
+
shell: ".sh",
|
|
315
|
+
sql: ".sql",
|
|
316
|
+
html: ".html",
|
|
317
|
+
css: ".css"
|
|
318
|
+
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
319
|
+
};
|
|
320
|
+
var generateRandomString = (length, lowercase = false) => {
|
|
321
|
+
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
322
|
+
let result = "";
|
|
323
|
+
for (let i = 0; i < length; i++) {
|
|
324
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
325
|
+
}
|
|
326
|
+
return lowercase ? result.toLowerCase() : result;
|
|
327
|
+
};
|
|
328
|
+
var CodeBlock = memo(({ language, value }) => {
|
|
329
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
330
|
+
const downloadAsFile = () => {
|
|
331
|
+
if (typeof window === "undefined") {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const fileExtension = programmingLanguages[language] || ".file";
|
|
335
|
+
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
336
|
+
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
337
|
+
if (!fileName) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const blob = new Blob([value], { type: "text/plain" });
|
|
341
|
+
const url = URL.createObjectURL(blob);
|
|
342
|
+
const link = document.createElement("a");
|
|
343
|
+
link.download = fileName;
|
|
344
|
+
link.href = url;
|
|
345
|
+
link.style.display = "none";
|
|
346
|
+
document.body.appendChild(link);
|
|
347
|
+
link.click();
|
|
348
|
+
document.body.removeChild(link);
|
|
349
|
+
URL.revokeObjectURL(url);
|
|
350
|
+
};
|
|
351
|
+
const onCopy = () => {
|
|
352
|
+
if (isCopied)
|
|
353
|
+
return;
|
|
354
|
+
copyToClipboard(value);
|
|
355
|
+
};
|
|
356
|
+
return /* @__PURE__ */ jsxs2("div", { className: "codeblock relative w-full bg-zinc-950 font-sans", children: [
|
|
357
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100", children: [
|
|
358
|
+
/* @__PURE__ */ jsx4("span", { className: "text-xs lowercase", children: language }),
|
|
359
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center space-x-1", children: [
|
|
360
|
+
/* @__PURE__ */ jsxs2(
|
|
361
|
+
Button,
|
|
362
|
+
{
|
|
363
|
+
variant: "ghost",
|
|
364
|
+
className: "hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
|
|
365
|
+
onClick: downloadAsFile,
|
|
366
|
+
size: "icon",
|
|
367
|
+
children: [
|
|
368
|
+
/* @__PURE__ */ jsx4(IconDownload, {}),
|
|
369
|
+
/* @__PURE__ */ jsx4("span", { className: "sr-only", children: "Download" })
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ jsxs2(
|
|
374
|
+
Button,
|
|
375
|
+
{
|
|
376
|
+
variant: "ghost",
|
|
377
|
+
size: "icon",
|
|
378
|
+
className: "text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
|
|
379
|
+
onClick: onCopy,
|
|
380
|
+
children: [
|
|
381
|
+
isCopied ? /* @__PURE__ */ jsx4(IconCheck, {}) : /* @__PURE__ */ jsx4(IconCopy, {}),
|
|
382
|
+
/* @__PURE__ */ jsx4("span", { className: "sr-only", children: "Copy code" })
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
)
|
|
386
|
+
] })
|
|
387
|
+
] }),
|
|
388
|
+
/* @__PURE__ */ jsx4(
|
|
389
|
+
SyntaxHighlighter,
|
|
390
|
+
{
|
|
391
|
+
language,
|
|
392
|
+
PreTag: "div",
|
|
393
|
+
showLineNumbers: true,
|
|
394
|
+
customStyle: {
|
|
395
|
+
margin: 0,
|
|
396
|
+
width: "100%",
|
|
397
|
+
background: "transparent",
|
|
398
|
+
padding: "1.5rem 1rem"
|
|
399
|
+
},
|
|
400
|
+
codeTagProps: {
|
|
401
|
+
style: {
|
|
402
|
+
fontSize: "0.9rem",
|
|
403
|
+
fontFamily: "var(--font-mono)"
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
children: value
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
] });
|
|
410
|
+
});
|
|
411
|
+
CodeBlock.displayName = "CodeBlock";
|
|
412
|
+
|
|
413
|
+
// src/components/chat-components/markdown.tsx
|
|
414
|
+
import { memo as memo2 } from "react";
|
|
415
|
+
import ReactMarkdown from "react-markdown";
|
|
416
|
+
var MemoizedReactMarkdown = memo2(
|
|
417
|
+
ReactMarkdown,
|
|
418
|
+
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
// src/components/chat-components/chat-message-actions.tsx
|
|
422
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
423
|
+
function ChatMessageActions(_a) {
|
|
424
|
+
var _b = _a, { message, className } = _b, props = __objRest(_b, ["message", "className"]);
|
|
425
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
426
|
+
const onCopy = () => {
|
|
427
|
+
if (isCopied)
|
|
428
|
+
return;
|
|
429
|
+
copyToClipboard(message.content);
|
|
430
|
+
};
|
|
431
|
+
return /* @__PURE__ */ jsx5(
|
|
432
|
+
"div",
|
|
433
|
+
__spreadProps(__spreadValues({
|
|
434
|
+
className: cn(
|
|
435
|
+
"flex items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0",
|
|
436
|
+
className
|
|
437
|
+
)
|
|
438
|
+
}, props), {
|
|
439
|
+
children: /* @__PURE__ */ jsxs3(Button, { variant: "ghost", size: "icon", onClick: onCopy, children: [
|
|
440
|
+
isCopied ? /* @__PURE__ */ jsx5(IconCheck, {}) : /* @__PURE__ */ jsx5(IconCopy, {}),
|
|
441
|
+
/* @__PURE__ */ jsx5("span", { className: "sr-only", children: "Copy message" })
|
|
442
|
+
] })
|
|
443
|
+
})
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// src/components/chat-components/chat-message.tsx
|
|
448
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
449
|
+
function ChatMessage(_a) {
|
|
450
|
+
var _b = _a, { message } = _b, props = __objRest(_b, ["message"]);
|
|
451
|
+
return /* @__PURE__ */ jsxs4("div", __spreadProps(__spreadValues({ className: cn("group relative mb-4 flex items-start") }, props), { children: [
|
|
452
|
+
/* @__PURE__ */ jsx6(
|
|
453
|
+
"div",
|
|
454
|
+
{
|
|
455
|
+
className: cn(
|
|
456
|
+
"flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow",
|
|
457
|
+
message.role === "user" ? "bg-background" : "bg-primary text-primary-foreground"
|
|
458
|
+
),
|
|
459
|
+
children: message.role === "user" ? /* @__PURE__ */ jsx6(IconUser, {}) : /* @__PURE__ */ jsx6(IconOpenAI, {})
|
|
460
|
+
}
|
|
461
|
+
),
|
|
462
|
+
/* @__PURE__ */ jsxs4("div", { className: "ml-4 flex-1 space-y-2 overflow-hidden px-1", children: [
|
|
463
|
+
/* @__PURE__ */ jsx6(
|
|
464
|
+
MemoizedReactMarkdown,
|
|
465
|
+
{
|
|
466
|
+
className: "prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm",
|
|
467
|
+
remarkPlugins: [remarkGfm, remarkMath],
|
|
468
|
+
components: {
|
|
469
|
+
p({ children }) {
|
|
470
|
+
return /* @__PURE__ */ jsx6("p", { className: "mb-2 last:mb-0", children });
|
|
471
|
+
},
|
|
472
|
+
code(_a2) {
|
|
473
|
+
var _b2 = _a2, { children, className, inline } = _b2, props2 = __objRest(_b2, ["children", "className", "inline"]);
|
|
474
|
+
if (children.length) {
|
|
475
|
+
if (children[0] == "\u258D") {
|
|
476
|
+
return /* @__PURE__ */ jsx6("span", { className: "mt-1 animate-pulse cursor-default", children: "\u258D" });
|
|
477
|
+
}
|
|
478
|
+
children[0] = children[0].replace("`\u258D`", "\u258D");
|
|
479
|
+
}
|
|
480
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
481
|
+
if (inline) {
|
|
482
|
+
return /* @__PURE__ */ jsx6("code", __spreadProps(__spreadValues({ className }, props2), { children }));
|
|
483
|
+
}
|
|
484
|
+
return /* @__PURE__ */ jsx6(
|
|
485
|
+
CodeBlock,
|
|
486
|
+
__spreadValues({
|
|
487
|
+
language: match && match[1] || "",
|
|
488
|
+
value: String(children).replace(/\n$/, "")
|
|
489
|
+
}, props2),
|
|
490
|
+
Math.random()
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
children: message.content
|
|
495
|
+
}
|
|
496
|
+
),
|
|
497
|
+
/* @__PURE__ */ jsx6(ChatMessageActions, { message })
|
|
498
|
+
] })
|
|
499
|
+
] }));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// src/components/chat-components/chat-list.tsx
|
|
503
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
504
|
+
function ChatList({ messages }) {
|
|
505
|
+
const displayedMessages = messages.filter((message) => message.role !== "system");
|
|
506
|
+
if (!displayedMessages.length) {
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
return /* @__PURE__ */ jsx7("div", { className: "relative mx-auto max-w-2xl px-0", children: displayedMessages.map((message, index) => /* @__PURE__ */ jsxs5("div", { children: [
|
|
510
|
+
/* @__PURE__ */ jsx7(ChatMessage, { message }),
|
|
511
|
+
index < displayedMessages.length - 1 && /* @__PURE__ */ jsx7(Separator, { className: "my-4 md:my-4" })
|
|
512
|
+
] }, index)) });
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// src/components/chat-components/prompt-form.tsx
|
|
516
|
+
import * as React6 from "react";
|
|
517
|
+
import TextareaAutosize from "react-textarea-autosize";
|
|
518
|
+
|
|
519
|
+
// src/hooks/use-enter-submit.tsx
|
|
520
|
+
import { useRef } from "react";
|
|
521
|
+
function useEnterSubmit() {
|
|
522
|
+
const formRef = useRef(null);
|
|
523
|
+
const handleKeyDown = (event) => {
|
|
524
|
+
var _a;
|
|
525
|
+
if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
|
|
526
|
+
(_a = formRef.current) == null ? void 0 : _a.requestSubmit();
|
|
527
|
+
event.preventDefault();
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
return { formRef, onKeyDown: handleKeyDown };
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// src/components/chat-components/ui/tooltip.tsx
|
|
534
|
+
import * as React5 from "react";
|
|
535
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
536
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
537
|
+
var TooltipProvider = TooltipPrimitive.Provider;
|
|
538
|
+
var Tooltip = TooltipPrimitive.Root;
|
|
539
|
+
var TooltipTrigger = TooltipPrimitive.Trigger;
|
|
540
|
+
var TooltipContent = React5.forwardRef((_a, ref) => {
|
|
541
|
+
var _b = _a, { className, sideOffset = 4 } = _b, props = __objRest(_b, ["className", "sideOffset"]);
|
|
542
|
+
return /* @__PURE__ */ jsx8(
|
|
543
|
+
TooltipPrimitive.Content,
|
|
544
|
+
__spreadValues({
|
|
545
|
+
ref,
|
|
546
|
+
sideOffset,
|
|
547
|
+
className: cn(
|
|
548
|
+
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md animate-in fade-in-50 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",
|
|
549
|
+
className
|
|
550
|
+
)
|
|
551
|
+
}, props)
|
|
552
|
+
);
|
|
553
|
+
});
|
|
554
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
555
|
+
|
|
556
|
+
// src/components/chat-components/prompt-form.tsx
|
|
557
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
558
|
+
function PromptForm({ onSubmit, input, setInput, isLoading }) {
|
|
559
|
+
const { formRef, onKeyDown } = useEnterSubmit();
|
|
560
|
+
const inputRef = React6.useRef(null);
|
|
561
|
+
React6.useEffect(() => {
|
|
562
|
+
if (inputRef.current) {
|
|
563
|
+
inputRef.current.focus();
|
|
564
|
+
}
|
|
565
|
+
}, []);
|
|
566
|
+
return /* @__PURE__ */ jsx9(
|
|
567
|
+
"form",
|
|
568
|
+
{
|
|
569
|
+
onSubmit: (e) => __async(this, null, function* () {
|
|
570
|
+
e.preventDefault();
|
|
571
|
+
if (!(input == null ? void 0 : input.trim())) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
setInput("");
|
|
575
|
+
yield onSubmit(input);
|
|
576
|
+
}),
|
|
577
|
+
ref: formRef,
|
|
578
|
+
children: /* @__PURE__ */ jsxs6("div", { className: "relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md border sm:px-12", children: [
|
|
579
|
+
/* @__PURE__ */ jsxs6(Tooltip, { children: [
|
|
580
|
+
/* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true }),
|
|
581
|
+
/* @__PURE__ */ jsx9(TooltipContent, { children: "New Chat" })
|
|
582
|
+
] }),
|
|
583
|
+
/* @__PURE__ */ jsx9(
|
|
584
|
+
TextareaAutosize,
|
|
585
|
+
{
|
|
586
|
+
ref: inputRef,
|
|
587
|
+
tabIndex: 0,
|
|
588
|
+
onKeyDown,
|
|
589
|
+
rows: 1,
|
|
590
|
+
value: input,
|
|
591
|
+
onChange: (e) => setInput(e.target.value),
|
|
592
|
+
placeholder: "Send a message.",
|
|
593
|
+
spellCheck: false,
|
|
594
|
+
className: "min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"
|
|
595
|
+
}
|
|
596
|
+
),
|
|
597
|
+
/* @__PURE__ */ jsx9("div", { className: "absolute right-0 top-4 sm:right-4", children: /* @__PURE__ */ jsxs6(Tooltip, { children: [
|
|
598
|
+
/* @__PURE__ */ jsx9(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs6(
|
|
599
|
+
Button,
|
|
600
|
+
{
|
|
601
|
+
type: "submit",
|
|
602
|
+
size: "icon",
|
|
603
|
+
disabled: isLoading || input === "",
|
|
604
|
+
className: " bg-slate-300",
|
|
605
|
+
children: [
|
|
606
|
+
/* @__PURE__ */ jsx9(IconArrowElbow, {}),
|
|
607
|
+
/* @__PURE__ */ jsx9("span", { className: "sr-only", children: "Send message" })
|
|
608
|
+
]
|
|
609
|
+
}
|
|
610
|
+
) }),
|
|
611
|
+
/* @__PURE__ */ jsx9(TooltipContent, { children: "Send message" })
|
|
612
|
+
] }) })
|
|
613
|
+
] })
|
|
614
|
+
}
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// src/components/chat-components/chat-panel.tsx
|
|
619
|
+
import { nanoid as nanoid2 } from "nanoid";
|
|
620
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
621
|
+
function ChatPanel({
|
|
622
|
+
id,
|
|
623
|
+
isLoading,
|
|
624
|
+
stop,
|
|
625
|
+
append,
|
|
626
|
+
reload,
|
|
627
|
+
input,
|
|
628
|
+
setInput,
|
|
629
|
+
messages
|
|
630
|
+
}) {
|
|
631
|
+
return /* @__PURE__ */ jsx10(
|
|
632
|
+
"div",
|
|
633
|
+
{
|
|
634
|
+
className: "inset-x-0 bottom-0 bg-gradient-to-b from-muted/10 from-10% to-muted/30 to-50% mt-4 mb-8",
|
|
635
|
+
style: { width: "100%", overflow: "hidden", boxSizing: "border-box" },
|
|
636
|
+
children: /* @__PURE__ */ jsxs7("div", { className: "mx-auto sm:max-w-2xl sm:px-4", children: [
|
|
637
|
+
/* @__PURE__ */ jsx10("div", { className: "flex h-10 items-center justify-center mb-4", children: isLoading ? /* @__PURE__ */ jsxs7(Button, { variant: "outline", onClick: () => stop(), className: "bg-background", children: [
|
|
638
|
+
/* @__PURE__ */ jsx10(IconStop, { className: "mr-2" }),
|
|
639
|
+
"Stop generating"
|
|
640
|
+
] }) : (messages == null ? void 0 : messages.length) > 0 && /* @__PURE__ */ jsxs7(Button, { variant: "outline", onClick: () => reload(), className: "bg-background", children: [
|
|
641
|
+
/* @__PURE__ */ jsx10(IconRefresh, { className: "mr-2" }),
|
|
642
|
+
"Regenerate response"
|
|
643
|
+
] }) }),
|
|
644
|
+
/* @__PURE__ */ jsx10("div", { className: "space-y-4 border-2 bg-background px-4 py-2 shadow-lg sm:rounded-xl md:py-4", children: /* @__PURE__ */ jsx10(
|
|
645
|
+
PromptForm,
|
|
646
|
+
{
|
|
647
|
+
onSubmit: (value) => __async(this, null, function* () {
|
|
648
|
+
yield append({
|
|
649
|
+
id: id || nanoid2(),
|
|
650
|
+
content: value,
|
|
651
|
+
role: "user"
|
|
652
|
+
});
|
|
653
|
+
}),
|
|
654
|
+
input,
|
|
655
|
+
setInput,
|
|
656
|
+
isLoading
|
|
657
|
+
}
|
|
658
|
+
) })
|
|
659
|
+
] })
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/components/chat-components/external-link.tsx
|
|
665
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
666
|
+
function ExternalLink({ href, children }) {
|
|
667
|
+
return /* @__PURE__ */ jsxs8(
|
|
668
|
+
"a",
|
|
669
|
+
{
|
|
670
|
+
href,
|
|
671
|
+
target: "_blank",
|
|
672
|
+
className: "inline-flex flex-1 justify-center gap-1 leading-4 hover:underline",
|
|
673
|
+
children: [
|
|
674
|
+
/* @__PURE__ */ jsx11("span", { children }),
|
|
675
|
+
/* @__PURE__ */ jsx11("svg", { "aria-hidden": "true", height: "7", viewBox: "0 0 6 6", width: "7", className: "opacity-70", children: /* @__PURE__ */ jsx11(
|
|
676
|
+
"path",
|
|
677
|
+
{
|
|
678
|
+
d: "M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z",
|
|
679
|
+
fill: "currentColor"
|
|
680
|
+
}
|
|
681
|
+
) })
|
|
682
|
+
]
|
|
683
|
+
}
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// src/components/chat-components/default-empty-screen.tsx
|
|
688
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
689
|
+
var exampleMessages = [
|
|
690
|
+
{
|
|
691
|
+
heading: "Explain technical concepts",
|
|
692
|
+
message: `What is a "serverless function"?`
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
heading: "Summarize an article",
|
|
696
|
+
message: "Summarize the following article for a 2nd grader: \n"
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
heading: "Draft an email",
|
|
700
|
+
message: `Draft an email to my boss about the following:
|
|
701
|
+
`
|
|
702
|
+
}
|
|
703
|
+
];
|
|
704
|
+
var DefaultEmptyScreen = (props) => {
|
|
705
|
+
return /* @__PURE__ */ jsx12("div", { className: "mx-auto max-w-2xl px-4", children: /* @__PURE__ */ jsxs9("div", { className: "rounded-lg border bg-background p-8", children: [
|
|
706
|
+
/* @__PURE__ */ jsx12("h1", { className: "mb-2 text-lg font-semibold", children: "Welcome to CopilotKit! \u{1F44B}" }),
|
|
707
|
+
/* @__PURE__ */ jsxs9("p", { className: "mb-2 leading-normal text-muted-foreground", children: [
|
|
708
|
+
"This is a Copilot built with",
|
|
709
|
+
" ",
|
|
710
|
+
/* @__PURE__ */ jsx12(ExternalLink, { href: "https://recursively.ai", children: "recursively.ai's" }),
|
|
711
|
+
" ",
|
|
712
|
+
/* @__PURE__ */ jsx12(ExternalLink, { href: "https://github.com/RecursivelyAI/CopilotKit", children: "CopilotKit" }),
|
|
713
|
+
" ",
|
|
714
|
+
"."
|
|
715
|
+
] }),
|
|
716
|
+
/* @__PURE__ */ jsx12("p", { className: "leading-normal text-muted-foreground", children: "You can start a conversation here or try the following examples:" }),
|
|
717
|
+
/* @__PURE__ */ jsx12("div", { className: "mt-4 flex flex-col items-start space-y-2", children: exampleMessages.map((message, index) => /* @__PURE__ */ jsxs9(
|
|
718
|
+
Button,
|
|
719
|
+
{
|
|
720
|
+
variant: "link",
|
|
721
|
+
className: "h-auto p-0 text-base",
|
|
722
|
+
onClick: () => props.setInput(message.message),
|
|
723
|
+
children: [
|
|
724
|
+
/* @__PURE__ */ jsx12(IconArrowRight, { className: "mr-2 text-muted-foreground" }),
|
|
725
|
+
message.heading
|
|
726
|
+
]
|
|
727
|
+
},
|
|
728
|
+
index
|
|
729
|
+
)) })
|
|
730
|
+
] }) });
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// src/components/chat-components/chat-scroll-anchor.tsx
|
|
734
|
+
import * as React8 from "react";
|
|
735
|
+
import { useInView } from "react-intersection-observer";
|
|
736
|
+
|
|
737
|
+
// src/hooks/use-at-bottom.tsx
|
|
738
|
+
import * as React7 from "react";
|
|
739
|
+
function useAtBottom(offset = 0) {
|
|
740
|
+
const [isAtBottom, setIsAtBottom] = React7.useState(false);
|
|
741
|
+
React7.useEffect(() => {
|
|
742
|
+
const handleScroll = () => {
|
|
743
|
+
setIsAtBottom(window.innerHeight + window.scrollY >= document.body.offsetHeight - offset);
|
|
744
|
+
};
|
|
745
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
746
|
+
handleScroll();
|
|
747
|
+
return () => {
|
|
748
|
+
window.removeEventListener("scroll", handleScroll);
|
|
749
|
+
};
|
|
750
|
+
}, [offset]);
|
|
751
|
+
return isAtBottom;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// src/components/chat-components/chat-scroll-anchor.tsx
|
|
755
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
756
|
+
function ChatScrollAnchor({ trackVisibility }) {
|
|
757
|
+
const isAtBottom = useAtBottom();
|
|
758
|
+
const { ref, entry, inView } = useInView({
|
|
759
|
+
trackVisibility,
|
|
760
|
+
delay: 100,
|
|
761
|
+
rootMargin: "0px 0px -150px 0px"
|
|
762
|
+
});
|
|
763
|
+
React8.useEffect(() => {
|
|
764
|
+
if (isAtBottom && trackVisibility && !inView) {
|
|
765
|
+
entry == null ? void 0 : entry.target.scrollIntoView({
|
|
766
|
+
block: "start"
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
}, [inView, entry, isAtBottom, trackVisibility]);
|
|
770
|
+
return /* @__PURE__ */ jsx13("div", { ref, className: "h-px w-full" });
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// src/components/chat-components/copilot-chat.tsx
|
|
774
|
+
import { useCopilotChat } from "@copilotkit/react-core";
|
|
775
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
776
|
+
function CopilotChat({
|
|
777
|
+
id,
|
|
778
|
+
initialMessages,
|
|
779
|
+
makeSystemMessage,
|
|
780
|
+
EmptyScreen = DefaultEmptyScreen
|
|
781
|
+
}) {
|
|
782
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({
|
|
783
|
+
id,
|
|
784
|
+
initialMessages,
|
|
785
|
+
makeSystemMessage
|
|
786
|
+
});
|
|
787
|
+
return /* @__PURE__ */ jsxs10("div", { className: "w-full h-full flex flex-col overflow-hidden box-border items-start", children: [
|
|
788
|
+
/* @__PURE__ */ jsx14("div", { className: "pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow", children: visibleMessages.length ? /* @__PURE__ */ jsxs10("div", { className: "pl-0 pr-6", children: [
|
|
789
|
+
/* @__PURE__ */ jsx14(ChatList, { messages: visibleMessages }),
|
|
790
|
+
/* @__PURE__ */ jsx14(ChatScrollAnchor, { trackVisibility: isLoading })
|
|
791
|
+
] }) : /* @__PURE__ */ jsx14(EmptyScreen, { setInput }) }),
|
|
792
|
+
/* @__PURE__ */ jsx14("div", { className: "flex-shrink-0 w-full", children: /* @__PURE__ */ jsx14(
|
|
793
|
+
ChatPanel,
|
|
794
|
+
{
|
|
795
|
+
id,
|
|
796
|
+
isLoading,
|
|
797
|
+
stop,
|
|
798
|
+
append,
|
|
799
|
+
reload,
|
|
800
|
+
messages: visibleMessages,
|
|
801
|
+
input,
|
|
802
|
+
setInput
|
|
803
|
+
}
|
|
804
|
+
) })
|
|
805
|
+
] });
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// src/components/sidebar/copilot-sidebar-ui-provider.tsx
|
|
809
|
+
import { useCallback } from "react";
|
|
810
|
+
import { useState as useState3 } from "react";
|
|
811
|
+
|
|
812
|
+
// src/components/sidebar/copilot-sidebar.tsx
|
|
813
|
+
import { XMarkIcon } from "@heroicons/react/24/outline";
|
|
814
|
+
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
815
|
+
function CopilotSidebar(props) {
|
|
816
|
+
return /* @__PURE__ */ jsxs11(
|
|
817
|
+
"div",
|
|
818
|
+
{
|
|
819
|
+
className: "shadow-lg bg-gray-50 flex flex-col border-l-2",
|
|
820
|
+
style: { width: "100%", height: "100%" },
|
|
821
|
+
children: [
|
|
822
|
+
/* @__PURE__ */ jsx15(TopBar, __spreadValues({}, props)),
|
|
823
|
+
/* @__PURE__ */ jsx15(CopilotChat, {})
|
|
824
|
+
]
|
|
825
|
+
}
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
function TopBar(props) {
|
|
829
|
+
return /* @__PURE__ */ jsxs11("div", { className: "py-6 flex bg-gray-50 items-center justify-between px-4", children: [
|
|
830
|
+
/* @__PURE__ */ jsx15("h1", { className: "text-base font-semibold leading-6 text-gray-900", children: "Copilot Chat" }),
|
|
831
|
+
/* @__PURE__ */ jsx15("div", { className: "ml-3 flex h-7 items-center", children: /* @__PURE__ */ jsxs11(
|
|
832
|
+
"button",
|
|
833
|
+
{
|
|
834
|
+
type: "button",
|
|
835
|
+
className: "rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",
|
|
836
|
+
onClick: () => props.setSidebarOpen(false),
|
|
837
|
+
children: [
|
|
838
|
+
/* @__PURE__ */ jsx15("span", { className: "sr-only", children: "Close panel" }),
|
|
839
|
+
/* @__PURE__ */ jsx15(XMarkIcon, { className: "h-6 w-6", "aria-hidden": "true" })
|
|
840
|
+
]
|
|
841
|
+
}
|
|
842
|
+
) })
|
|
843
|
+
] });
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// src/components/sidebar/sidebar-context.tsx
|
|
847
|
+
import { createContext } from "react";
|
|
848
|
+
var CopilotSidebarContext = createContext({
|
|
849
|
+
isSidebarOpen: false,
|
|
850
|
+
toggleSidebar: () => {
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
// src/components/sidebar/copilot-sidebar-ui-provider.tsx
|
|
855
|
+
import { Fragment, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
856
|
+
function CopilotSidebarUIProvider({ children }) {
|
|
857
|
+
const [sidebarOpen, setSidebarOpen] = useState3(true);
|
|
858
|
+
const toggleSidebar = useCallback(() => {
|
|
859
|
+
setSidebarOpen((prev) => !prev);
|
|
860
|
+
}, []);
|
|
861
|
+
return /* @__PURE__ */ jsx16(CopilotSidebarContext.Provider, { value: { isSidebarOpen: sidebarOpen, toggleSidebar }, children: /* @__PURE__ */ jsx16(Fragment, { children: /* @__PURE__ */ jsxs12(
|
|
862
|
+
"div",
|
|
863
|
+
{
|
|
864
|
+
style: {
|
|
865
|
+
height: "100vh",
|
|
866
|
+
width: "100vw",
|
|
867
|
+
position: "relative"
|
|
868
|
+
},
|
|
869
|
+
children: [
|
|
870
|
+
/* @__PURE__ */ jsx16(
|
|
871
|
+
"div",
|
|
872
|
+
{
|
|
873
|
+
style: {
|
|
874
|
+
overflowY: "auto",
|
|
875
|
+
overflowX: "hidden",
|
|
876
|
+
height: "100%",
|
|
877
|
+
width: sidebarOpen ? "calc(100% - 450px)" : "100%",
|
|
878
|
+
position: "absolute",
|
|
879
|
+
transition: "width 0.5s ease-in-out"
|
|
880
|
+
// New
|
|
881
|
+
},
|
|
882
|
+
children: /* @__PURE__ */ jsx16("main", { children })
|
|
883
|
+
}
|
|
884
|
+
),
|
|
885
|
+
/* @__PURE__ */ jsx16(
|
|
886
|
+
"div",
|
|
887
|
+
{
|
|
888
|
+
style: {
|
|
889
|
+
overflowY: "auto",
|
|
890
|
+
height: "100%",
|
|
891
|
+
width: "450px",
|
|
892
|
+
position: "absolute",
|
|
893
|
+
right: sidebarOpen ? "0" : "-450px",
|
|
894
|
+
transition: "right 0.5s ease-in-out"
|
|
895
|
+
},
|
|
896
|
+
children: /* @__PURE__ */ jsx16(TooltipProvider, { children: /* @__PURE__ */ jsx16(CopilotSidebar, { setSidebarOpen }) })
|
|
897
|
+
}
|
|
898
|
+
),
|
|
899
|
+
!sidebarOpen && /* @__PURE__ */ jsx16(
|
|
900
|
+
"button",
|
|
901
|
+
{
|
|
902
|
+
onClick: toggleSidebar,
|
|
903
|
+
style: {
|
|
904
|
+
position: "absolute",
|
|
905
|
+
top: "5%",
|
|
906
|
+
right: "20px",
|
|
907
|
+
transform: "translateY(-50%)",
|
|
908
|
+
transition: "opacity 0.5s ease-in-out"
|
|
909
|
+
},
|
|
910
|
+
className: "bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg",
|
|
911
|
+
children: "Open Copilot"
|
|
912
|
+
}
|
|
913
|
+
)
|
|
914
|
+
]
|
|
915
|
+
}
|
|
916
|
+
) }) });
|
|
917
|
+
}
|
|
918
|
+
export {
|
|
919
|
+
CopilotChat,
|
|
920
|
+
CopilotSidebar,
|
|
921
|
+
CopilotSidebarContext,
|
|
922
|
+
CopilotSidebarUIProvider,
|
|
923
|
+
Tooltip,
|
|
924
|
+
TooltipProvider
|
|
925
|
+
};
|
|
26
926
|
//# sourceMappingURL=index.mjs.map
|