@copilotkit/react-ui 0.3.0 → 0.4.0
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 +192 -13
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/chunk-46XC7ODX.mjs +72 -0
- package/dist/chunk-46XC7ODX.mjs.map +1 -0
- package/dist/chunk-4HK6C362.mjs +106 -0
- package/dist/chunk-4HK6C362.mjs.map +1 -0
- package/dist/chunk-6LAC5RA2.mjs +28 -0
- package/dist/chunk-6LAC5RA2.mjs.map +1 -0
- package/dist/chunk-6LRNF2VU.mjs +12 -0
- package/dist/chunk-6LRNF2VU.mjs.map +1 -0
- package/dist/chunk-7NSRDJ5C.mjs +3 -0
- package/dist/chunk-7NSRDJ5C.mjs.map +1 -0
- package/dist/chunk-BB6IP63P.mjs +29 -0
- package/dist/chunk-BB6IP63P.mjs.map +1 -0
- package/dist/chunk-BIPCPNHG.mjs +18 -0
- package/dist/chunk-BIPCPNHG.mjs.map +1 -0
- package/dist/chunk-BS6RR2DJ.mjs +25 -0
- package/dist/chunk-BS6RR2DJ.mjs.map +1 -0
- package/dist/chunk-DOMJCSI6.mjs +26 -0
- package/dist/chunk-DOMJCSI6.mjs.map +1 -0
- package/dist/chunk-E2YBQYWM.mjs +69 -0
- package/dist/chunk-E2YBQYWM.mjs.map +1 -0
- package/dist/chunk-E5BOIXYO.mjs +45 -0
- package/dist/chunk-E5BOIXYO.mjs.map +1 -0
- package/dist/chunk-H4VKQGVU.mjs +3 -0
- package/dist/chunk-H4VKQGVU.mjs.map +1 -0
- package/dist/chunk-I2AB5FK4.mjs +123 -0
- package/dist/chunk-I2AB5FK4.mjs.map +1 -0
- package/dist/chunk-IU3WTXLQ.mjs +3 -0
- package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
- package/dist/chunk-KR7MH7XO.mjs +481 -0
- package/dist/chunk-KR7MH7XO.mjs.map +1 -0
- package/dist/chunk-KXJV37FS.mjs +33 -0
- package/dist/chunk-KXJV37FS.mjs.map +1 -0
- package/dist/chunk-MC6KTH4X.mjs +12 -0
- package/dist/chunk-MC6KTH4X.mjs.map +1 -0
- package/dist/chunk-MRXNTQOX.mjs +55 -0
- package/dist/chunk-MRXNTQOX.mjs.map +1 -0
- package/dist/chunk-N7KB3Z57.mjs +23 -0
- package/dist/chunk-N7KB3Z57.mjs.map +1 -0
- package/dist/chunk-QEXWZWJL.mjs +75 -0
- package/dist/chunk-QEXWZWJL.mjs.map +1 -0
- package/dist/chunk-RSONJDLO.mjs +28 -0
- package/dist/chunk-RSONJDLO.mjs.map +1 -0
- package/dist/chunk-SF56HSZW.mjs +48 -0
- package/dist/chunk-SF56HSZW.mjs.map +1 -0
- package/dist/chunk-TVTG3V4F.mjs +40 -0
- package/dist/chunk-TVTG3V4F.mjs.map +1 -0
- package/dist/chunk-U6NJWGTV.mjs +3 -0
- package/dist/chunk-U6NJWGTV.mjs.map +1 -0
- package/dist/chunk-V6QYUEJR.mjs +47 -0
- package/dist/chunk-V6QYUEJR.mjs.map +1 -0
- package/dist/chunk-VQNV2DHJ.mjs +142 -0
- package/dist/chunk-VQNV2DHJ.mjs.map +1 -0
- package/dist/chunk-VSNDSL6W.mjs +74 -0
- package/dist/chunk-VSNDSL6W.mjs.map +1 -0
- package/dist/chunk-XZFO2YEG.mjs +53 -0
- package/dist/chunk-XZFO2YEG.mjs.map +1 -0
- package/dist/components/chat-components/chat-list.d.ts +8 -0
- package/dist/components/chat-components/chat-list.mjs +13 -0
- package/dist/components/chat-components/chat-list.mjs.map +1 -0
- package/dist/components/chat-components/chat-message-actions.d.ts +8 -0
- package/dist/components/chat-components/chat-message-actions.mjs +8 -0
- package/dist/components/chat-components/chat-message-actions.mjs.map +1 -0
- package/dist/components/chat-components/chat-message.d.ts +8 -0
- package/dist/components/chat-components/chat-message.mjs +11 -0
- package/dist/components/chat-components/chat-message.mjs.map +1 -0
- package/dist/components/chat-components/chat-panel.d.ts +8 -0
- package/dist/components/chat-components/chat-panel.mjs +10 -0
- package/dist/components/chat-components/chat-panel.mjs.map +1 -0
- package/dist/components/chat-components/chat-scroll-anchor.d.ts +6 -0
- package/dist/components/chat-components/chat-scroll-anchor.mjs +5 -0
- package/dist/components/chat-components/chat-scroll-anchor.mjs.map +1 -0
- package/dist/components/chat-components/clear-history.d.ts +9 -0
- package/dist/components/chat-components/clear-history.mjs +81 -0
- package/dist/components/chat-components/clear-history.mjs.map +1 -0
- package/dist/components/chat-components/copilot-chat.d.ts +12 -0
- package/dist/components/chat-components/copilot-chat.mjs +22 -0
- package/dist/components/chat-components/copilot-chat.mjs.map +1 -0
- package/dist/components/chat-components/default-empty-screen.d.ts +8 -0
- package/dist/components/chat-components/default-empty-screen.mjs +8 -0
- package/dist/components/chat-components/default-empty-screen.mjs.map +1 -0
- package/dist/components/chat-components/external-link.d.ts +6 -0
- package/dist/components/chat-components/external-link.mjs +4 -0
- package/dist/components/chat-components/external-link.mjs.map +1 -0
- package/dist/components/chat-components/markdown.d.ts +6 -0
- package/dist/components/chat-components/markdown.mjs +4 -0
- package/dist/components/chat-components/markdown.mjs.map +1 -0
- package/dist/components/chat-components/prompt-form.d.ts +9 -0
- package/dist/components/chat-components/prompt-form.mjs +9 -0
- package/dist/components/chat-components/prompt-form.mjs.map +1 -0
- package/dist/components/chat-components/theme-toggle.d.ts +3 -0
- package/dist/components/chat-components/theme-toggle.mjs +36 -0
- package/dist/components/chat-components/theme-toggle.mjs.map +1 -0
- package/dist/components/chat-components/toaster.d.ts +1 -0
- package/dist/components/chat-components/toaster.mjs +4 -0
- package/dist/components/chat-components/toaster.mjs.map +1 -0
- package/dist/components/chat-components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/chat-components/ui/alert-dialog.mjs +6 -0
- package/dist/components/chat-components/ui/alert-dialog.mjs.map +1 -0
- package/dist/components/chat-components/ui/badge.d.ts +12 -0
- package/dist/components/chat-components/ui/badge.mjs +31 -0
- package/dist/components/chat-components/ui/badge.mjs.map +1 -0
- package/dist/components/chat-components/ui/button.d.ts +14 -0
- package/dist/components/chat-components/ui/button.mjs +5 -0
- package/dist/components/chat-components/ui/button.mjs.map +1 -0
- package/dist/components/chat-components/ui/codeblock.d.ts +14 -0
- package/dist/components/chat-components/ui/codeblock.mjs +8 -0
- package/dist/components/chat-components/ui/codeblock.mjs.map +1 -0
- package/dist/components/chat-components/ui/dialog.d.ts +18 -0
- package/dist/components/chat-components/ui/dialog.mjs +119 -0
- package/dist/components/chat-components/ui/dialog.mjs.map +1 -0
- package/dist/components/chat-components/ui/dropdown-menu.d.ts +24 -0
- package/dist/components/chat-components/ui/dropdown-menu.mjs +84 -0
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +1 -0
- package/dist/components/chat-components/ui/icons.d.ts +33 -0
- package/dist/components/chat-components/ui/icons.mjs +5 -0
- package/dist/components/chat-components/ui/icons.mjs.map +1 -0
- package/dist/components/chat-components/ui/input.d.ts +7 -0
- package/dist/components/chat-components/ui/input.mjs +23 -0
- package/dist/components/chat-components/ui/input.mjs.map +1 -0
- package/dist/components/chat-components/ui/label.d.ts +8 -0
- package/dist/components/chat-components/ui/label.mjs +22 -0
- package/dist/components/chat-components/ui/label.mjs.map +1 -0
- package/dist/components/chat-components/ui/select.d.ts +13 -0
- package/dist/components/chat-components/ui/select.mjs +99 -0
- package/dist/components/chat-components/ui/select.mjs.map +1 -0
- package/dist/components/chat-components/ui/separator.d.ts +6 -0
- package/dist/components/chat-components/ui/separator.mjs +5 -0
- package/dist/components/chat-components/ui/separator.mjs.map +1 -0
- package/dist/components/chat-components/ui/sheet.d.ts +19 -0
- package/dist/components/chat-components/ui/sheet.mjs +109 -0
- package/dist/components/chat-components/ui/sheet.mjs.map +1 -0
- package/dist/components/chat-components/ui/switch.d.ts +6 -0
- package/dist/components/chat-components/ui/switch.mjs +27 -0
- package/dist/components/chat-components/ui/switch.mjs.map +1 -0
- package/dist/components/chat-components/ui/textarea.d.ts +7 -0
- package/dist/components/chat-components/ui/textarea.mjs +22 -0
- package/dist/components/chat-components/ui/textarea.mjs.map +1 -0
- package/dist/components/chat-components/ui/tooltip.d.ts +9 -0
- package/dist/components/chat-components/ui/tooltip.mjs +5 -0
- package/dist/components/chat-components/ui/tooltip.mjs.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.mjs +26 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +8 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +25 -0
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +1 -0
- package/dist/components/sidebar/copilot-sidebar.d.ts +6 -0
- package/dist/components/sidebar/copilot-sidebar.mjs +23 -0
- package/dist/components/sidebar/copilot-sidebar.mjs.map +1 -0
- package/dist/components/sidebar/sidebar-context.d.ts +9 -0
- package/dist/components/sidebar/sidebar-context.mjs +4 -0
- package/dist/components/sidebar/sidebar-context.mjs.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.mjs +3 -0
- package/dist/context/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/use-at-bottom.d.ts +3 -0
- package/dist/hooks/use-at-bottom.mjs +4 -0
- package/dist/hooks/use-at-bottom.mjs.map +1 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
- package/dist/hooks/use-copy-to-clipboard.mjs +4 -0
- package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
- package/dist/hooks/use-enter-submit.d.ts +8 -0
- package/dist/hooks/use-enter-submit.mjs +4 -0
- package/dist/hooks/use-enter-submit.mjs.map +1 -0
- package/dist/index.css +1249 -1
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +9 -36
- package/dist/index.mjs +29 -26
- package/dist/index.mjs.map +1 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.mjs +4 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.mjs +3 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types/types.d.ts +16 -0
- package/dist/types/types.mjs +3 -0
- package/dist/types/types.mjs.map +1 -0
- package/package.json +8 -8
- package/src/components/chat-components/chat-list.tsx +8 -8
- package/src/components/chat-components/chat-message-actions.tsx +14 -14
- package/src/components/chat-components/chat-message.tsx +26 -26
- package/src/components/chat-components/chat-panel.tsx +18 -18
- package/src/components/chat-components/chat-scroll-anchor.tsx +12 -12
- package/src/components/chat-components/clear-history.tsx +22 -22
- package/src/components/chat-components/copilot-chat.tsx +45 -50
- package/src/components/chat-components/default-empty-screen.tsx +24 -22
- package/src/components/chat-components/external-link.tsx +4 -4
- package/src/components/chat-components/markdown.tsx +3 -3
- package/src/components/chat-components/prompt-form.tsx +27 -27
- package/src/components/chat-components/theme-toggle.tsx +11 -11
- package/src/components/chat-components/toaster.tsx +2 -2
- package/src/components/chat-components/ui/alert-dialog.tsx +35 -35
- package/src/components/chat-components/ui/badge.tsx +14 -14
- package/src/components/chat-components/ui/button.tsx +26 -26
- package/src/components/chat-components/ui/codeblock.tsx +70 -70
- package/src/components/chat-components/ui/dialog.tsx +29 -29
- package/src/components/chat-components/ui/dropdown-menu.tsx +35 -35
- package/src/components/chat-components/ui/icons.tsx +96 -96
- package/src/components/chat-components/ui/input.tsx +7 -7
- package/src/components/chat-components/ui/label.tsx +10 -10
- package/src/components/chat-components/ui/select.tsx +30 -30
- package/src/components/chat-components/ui/separator.tsx +10 -10
- package/src/components/chat-components/ui/sheet.tsx +31 -31
- package/src/components/chat-components/ui/switch.tsx +9 -9
- package/src/components/chat-components/ui/textarea.tsx +7 -7
- package/src/components/chat-components/ui/tooltip.tsx +11 -11
- package/src/components/index.ts +6 -6
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +34 -31
- package/src/components/sidebar/copilot-sidebar.tsx +9 -9
- package/src/components/sidebar/sidebar-context.tsx +5 -5
- package/src/context/index.ts +1 -1
- package/src/hooks/index.ts +1 -1
- package/src/hooks/use-at-bottom.tsx +10 -10
- package/src/hooks/use-copy-to-clipboard.tsx +14 -14
- package/src/hooks/use-enter-submit.tsx +9 -9
- package/src/index.tsx +4 -4
- package/src/lib/utils.ts +20 -20
- package/src/types/index.ts +1 -1
- package/src/types/types.ts +10 -10
- package/tsup.config.ts +3 -4
- package/dist/index.js +0 -53
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import { useInView } from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useInView } from "react-intersection-observer";
|
|
5
5
|
|
|
6
|
-
import { useAtBottom } from
|
|
6
|
+
import { useAtBottom } from "../../hooks/use-at-bottom";
|
|
7
7
|
|
|
8
8
|
interface ChatScrollAnchorProps {
|
|
9
|
-
trackVisibility?: boolean
|
|
9
|
+
trackVisibility?: boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function ChatScrollAnchor({ trackVisibility }: ChatScrollAnchorProps) {
|
|
13
|
-
const isAtBottom = useAtBottom()
|
|
13
|
+
const isAtBottom = useAtBottom();
|
|
14
14
|
const { ref, entry, inView } = useInView({
|
|
15
15
|
trackVisibility,
|
|
16
16
|
delay: 100,
|
|
17
|
-
rootMargin:
|
|
18
|
-
})
|
|
17
|
+
rootMargin: "0px 0px -150px 0px",
|
|
18
|
+
});
|
|
19
19
|
|
|
20
20
|
React.useEffect(() => {
|
|
21
21
|
if (isAtBottom && trackVisibility && !inView) {
|
|
22
22
|
entry?.target.scrollIntoView({
|
|
23
|
-
block:
|
|
24
|
-
})
|
|
23
|
+
block: "start",
|
|
24
|
+
});
|
|
25
25
|
}
|
|
26
|
-
}, [inView, entry, isAtBottom, trackVisibility])
|
|
26
|
+
}, [inView, entry, isAtBottom, trackVisibility]);
|
|
27
27
|
|
|
28
|
-
return <div ref={ref} className="h-px w-full"
|
|
28
|
+
return <div ref={ref} className="h-px w-full" />;
|
|
29
29
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import { useRouter } from
|
|
5
|
-
import { toast } from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { toast } from "react-hot-toast";
|
|
6
6
|
|
|
7
|
-
import { ServerActionResult } from "../../types/types"
|
|
8
|
-
import { Button } from
|
|
7
|
+
import { ServerActionResult } from "../../types/types";
|
|
8
|
+
import { Button } from "./ui/button";
|
|
9
9
|
import {
|
|
10
10
|
AlertDialog,
|
|
11
11
|
AlertDialogAction,
|
|
@@ -15,18 +15,18 @@ import {
|
|
|
15
15
|
AlertDialogFooter,
|
|
16
16
|
AlertDialogHeader,
|
|
17
17
|
AlertDialogTitle,
|
|
18
|
-
AlertDialogTrigger
|
|
19
|
-
} from
|
|
20
|
-
import { IconSpinner } from
|
|
18
|
+
AlertDialogTrigger,
|
|
19
|
+
} from "./ui/alert-dialog";
|
|
20
|
+
import { IconSpinner } from "./ui/icons";
|
|
21
21
|
|
|
22
22
|
interface ClearHistoryProps {
|
|
23
|
-
clearChats: () => ServerActionResult<void
|
|
23
|
+
clearChats: () => ServerActionResult<void>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function ClearHistory({ clearChats }: ClearHistoryProps) {
|
|
27
|
-
const [open, setOpen] = React.useState(false)
|
|
28
|
-
const [isPending, startTransition] = React.useTransition()
|
|
29
|
-
const router = useRouter()
|
|
27
|
+
const [open, setOpen] = React.useState(false);
|
|
28
|
+
const [isPending, startTransition] = React.useTransition();
|
|
29
|
+
const router = useRouter();
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<AlertDialog open={open} onOpenChange={setOpen}>
|
|
@@ -49,18 +49,18 @@ export function ClearHistory({ clearChats }: ClearHistoryProps) {
|
|
|
49
49
|
<AlertDialogAction
|
|
50
50
|
disabled={isPending}
|
|
51
51
|
onClick={(event: any) => {
|
|
52
|
-
event.preventDefault()
|
|
52
|
+
event.preventDefault();
|
|
53
53
|
startTransition(async () => {
|
|
54
|
-
const result = await clearChats()
|
|
54
|
+
const result = await clearChats();
|
|
55
55
|
|
|
56
|
-
if (result &&
|
|
57
|
-
toast.error(result.error)
|
|
58
|
-
return
|
|
56
|
+
if (result && "error" in result) {
|
|
57
|
+
toast.error(result.error);
|
|
58
|
+
return;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
setOpen(false)
|
|
62
|
-
router.push(
|
|
63
|
-
})
|
|
61
|
+
setOpen(false);
|
|
62
|
+
router.push("/");
|
|
63
|
+
});
|
|
64
64
|
}}
|
|
65
65
|
>
|
|
66
66
|
{isPending && <IconSpinner className="mr-2 animate-spin" />}
|
|
@@ -69,5 +69,5 @@ export function ClearHistory({ clearChats }: ClearHistoryProps) {
|
|
|
69
69
|
</AlertDialogFooter>
|
|
70
70
|
</AlertDialogContent>
|
|
71
71
|
</AlertDialog>
|
|
72
|
-
)
|
|
72
|
+
);
|
|
73
73
|
}
|
|
@@ -1,61 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import React from
|
|
3
|
+
import React from "react";
|
|
4
4
|
|
|
5
|
-
import { ChatList } from
|
|
6
|
-
import { ChatPanel } from
|
|
7
|
-
import { DefaultEmptyScreen, EmptyScreenProps } from
|
|
8
|
-
import { ChatScrollAnchor } from
|
|
9
|
-
import { UseCopilotChatOptions } from "@copilotkit/react-core"
|
|
10
|
-
import { useCopilotChat } from "@copilotkit/react-core"
|
|
5
|
+
import { ChatList } from "./chat-list";
|
|
6
|
+
import { ChatPanel } from "./chat-panel";
|
|
7
|
+
import { DefaultEmptyScreen, EmptyScreenProps } from "./default-empty-screen";
|
|
8
|
+
import { ChatScrollAnchor } from "./chat-scroll-anchor";
|
|
9
|
+
import { UseCopilotChatOptions } from "@copilotkit/react-core";
|
|
10
|
+
import { useCopilotChat } from "@copilotkit/react-core";
|
|
11
11
|
|
|
12
12
|
interface ChatComponentInjectionsProps {
|
|
13
|
-
EmptyScreen?: React.FC<EmptyScreenProps
|
|
13
|
+
EmptyScreen?: React.FC<EmptyScreenProps>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
interface CopilotChatProps
|
|
17
17
|
extends UseCopilotChatOptions,
|
|
18
18
|
ChatComponentInjectionsProps {}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<div
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{visibleMessages.length ? (
|
|
37
|
-
<div className="pl-0 pr-6">
|
|
38
|
-
<ChatList messages={visibleMessages} />
|
|
39
|
-
<ChatScrollAnchor trackVisibility={isLoading} />
|
|
40
|
-
</div>
|
|
41
|
-
) : (
|
|
42
|
-
<EmptyScreen setInput={setInput} />
|
|
43
|
-
)}
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<div className="flex-shrink-0 w-full">
|
|
47
|
-
<ChatPanel
|
|
48
|
-
id={id}
|
|
49
|
-
isLoading={isLoading}
|
|
50
|
-
stop={stop}
|
|
51
|
-
append={append}
|
|
52
|
-
reload={reload}
|
|
53
|
-
messages={visibleMessages}
|
|
54
|
-
input={input}
|
|
55
|
-
setInput={setInput}
|
|
56
|
-
/>
|
|
20
|
+
export function CopilotChat({
|
|
21
|
+
id,
|
|
22
|
+
initialMessages,
|
|
23
|
+
makeSystemMessage,
|
|
24
|
+
EmptyScreen = DefaultEmptyScreen,
|
|
25
|
+
}: CopilotChatProps) {
|
|
26
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } =
|
|
27
|
+
useCopilotChat({ id, initialMessages, makeSystemMessage });
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="w-full h-full flex flex-col overflow-hidden box-border items-start">
|
|
31
|
+
<div className="pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow">
|
|
32
|
+
{visibleMessages.length ? (
|
|
33
|
+
<div className="pl-0 pr-6">
|
|
34
|
+
<ChatList messages={visibleMessages} />
|
|
35
|
+
<ChatScrollAnchor trackVisibility={isLoading} />
|
|
57
36
|
</div>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
37
|
+
) : (
|
|
38
|
+
<EmptyScreen setInput={setInput} />
|
|
39
|
+
)}
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div className="flex-shrink-0 w-full">
|
|
43
|
+
<ChatPanel
|
|
44
|
+
id={id}
|
|
45
|
+
isLoading={isLoading}
|
|
46
|
+
stop={stop}
|
|
47
|
+
append={append}
|
|
48
|
+
reload={reload}
|
|
49
|
+
messages={visibleMessages}
|
|
50
|
+
input={input}
|
|
51
|
+
setInput={setInput}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
import React from
|
|
3
|
-
import { UseChatHelpers } from
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { UseChatHelpers } from "ai/react";
|
|
4
4
|
|
|
5
|
-
import { Button } from
|
|
6
|
-
import { ExternalLink } from
|
|
7
|
-
import { IconArrowRight } from
|
|
5
|
+
import { Button } from "./ui/button";
|
|
6
|
+
import { ExternalLink } from "./external-link";
|
|
7
|
+
import { IconArrowRight } from "./ui/icons";
|
|
8
8
|
|
|
9
9
|
const exampleMessages = [
|
|
10
10
|
{
|
|
11
|
-
heading:
|
|
12
|
-
message: `What is a "serverless function"
|
|
11
|
+
heading: "Explain technical concepts",
|
|
12
|
+
message: `What is a "serverless function"?`,
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
heading:
|
|
16
|
-
message:
|
|
15
|
+
heading: "Summarize an article",
|
|
16
|
+
message: "Summarize the following article for a 2nd grader: \n",
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
heading:
|
|
20
|
-
message: `Draft an email to my boss about the following: \n
|
|
21
|
-
}
|
|
22
|
-
]
|
|
19
|
+
heading: "Draft an email",
|
|
20
|
+
message: `Draft an email to my boss about the following: \n`,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
23
|
|
|
24
24
|
export interface EmptyScreenProps {
|
|
25
|
-
setInput: React.Dispatch<React.SetStateAction<string
|
|
25
|
+
setInput: React.Dispatch<React.SetStateAction<string>>;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const DefaultEmptyScreen: React.FC<EmptyScreenProps> = props => {
|
|
28
|
+
export const DefaultEmptyScreen: React.FC<EmptyScreenProps> = (props) => {
|
|
29
29
|
return (
|
|
30
30
|
<div className="mx-auto max-w-2xl px-4">
|
|
31
31
|
<div className="rounded-lg border bg-background p-8">
|
|
32
|
-
<h1 className="mb-2 text-lg font-semibold">
|
|
32
|
+
<h1 className="mb-2 text-lg font-semibold">
|
|
33
|
+
Welcome to CopilotKit! 👋
|
|
34
|
+
</h1>
|
|
33
35
|
<p className="mb-2 leading-normal text-muted-foreground">
|
|
34
|
-
This is a Copilot built with{
|
|
36
|
+
This is a Copilot built with{" "}
|
|
35
37
|
<ExternalLink href="https://recursively.ai">
|
|
36
38
|
recursively.ai's
|
|
37
|
-
</ExternalLink>{
|
|
39
|
+
</ExternalLink>{" "}
|
|
38
40
|
<ExternalLink href="https://github.com/RecursivelyAI/CopilotKit">
|
|
39
41
|
CopilotKit
|
|
40
|
-
</ExternalLink>{
|
|
42
|
+
</ExternalLink>{" "}
|
|
41
43
|
.
|
|
42
44
|
</p>
|
|
43
45
|
<p className="leading-normal text-muted-foreground">
|
|
@@ -58,5 +60,5 @@ export const DefaultEmptyScreen: React.FC<EmptyScreenProps> = props => {
|
|
|
58
60
|
</div>
|
|
59
61
|
</div>
|
|
60
62
|
</div>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export function ExternalLink({
|
|
2
2
|
href,
|
|
3
|
-
children
|
|
3
|
+
children,
|
|
4
4
|
}: {
|
|
5
|
-
href: string
|
|
6
|
-
children: React.ReactNode
|
|
5
|
+
href: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
7
|
}) {
|
|
8
8
|
return (
|
|
9
9
|
<a
|
|
@@ -25,5 +25,5 @@ export function ExternalLink({
|
|
|
25
25
|
></path>
|
|
26
26
|
</svg>
|
|
27
27
|
</a>
|
|
28
|
-
)
|
|
28
|
+
);
|
|
29
29
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FC, memo } from
|
|
2
|
-
import ReactMarkdown, { Options } from
|
|
1
|
+
import { FC, memo } from "react";
|
|
2
|
+
import ReactMarkdown, { Options } from "react-markdown";
|
|
3
3
|
|
|
4
4
|
export const MemoizedReactMarkdown: FC<Options> = memo(
|
|
5
5
|
ReactMarkdown,
|
|
6
6
|
(prevProps, nextProps) =>
|
|
7
7
|
prevProps.children === nextProps.children &&
|
|
8
8
|
prevProps.className === nextProps.className
|
|
9
|
-
)
|
|
9
|
+
);
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import TextareaAutosize from
|
|
3
|
-
import { UseChatHelpers } from
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import TextareaAutosize from "react-textarea-autosize";
|
|
3
|
+
import { UseChatHelpers } from "ai/react";
|
|
4
4
|
|
|
5
|
-
import { useEnterSubmit } from
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { Button, buttonVariants } from
|
|
8
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from
|
|
9
|
-
import { IconArrowElbow, IconPlus } from
|
|
10
|
-
import Link from
|
|
5
|
+
import { useEnterSubmit } from "../../hooks/use-enter-submit";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
import { Button, buttonVariants } from "./ui/button";
|
|
8
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
|
|
9
|
+
import { IconArrowElbow, IconPlus } from "./ui/icons";
|
|
10
|
+
import Link from "next/link";
|
|
11
11
|
|
|
12
12
|
export interface PromptProps
|
|
13
|
-
extends Pick<UseChatHelpers,
|
|
14
|
-
onSubmit: (value: string) => Promise<void
|
|
15
|
-
isLoading: boolean
|
|
13
|
+
extends Pick<UseChatHelpers, "input" | "setInput"> {
|
|
14
|
+
onSubmit: (value: string) => Promise<void>;
|
|
15
|
+
isLoading: boolean;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function PromptForm({
|
|
19
19
|
onSubmit,
|
|
20
20
|
input,
|
|
21
21
|
setInput,
|
|
22
|
-
isLoading
|
|
22
|
+
isLoading,
|
|
23
23
|
}: PromptProps) {
|
|
24
|
-
const { formRef, onKeyDown } = useEnterSubmit()
|
|
25
|
-
const inputRef = React.useRef<HTMLTextAreaElement>(null)
|
|
24
|
+
const { formRef, onKeyDown } = useEnterSubmit();
|
|
25
|
+
const inputRef = React.useRef<HTMLTextAreaElement>(null);
|
|
26
26
|
|
|
27
27
|
React.useEffect(() => {
|
|
28
28
|
if (inputRef.current) {
|
|
29
|
-
inputRef.current.focus()
|
|
29
|
+
inputRef.current.focus();
|
|
30
30
|
}
|
|
31
|
-
}, [])
|
|
31
|
+
}, []);
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<form
|
|
35
|
-
onSubmit={async e => {
|
|
36
|
-
e.preventDefault()
|
|
35
|
+
onSubmit={async (e) => {
|
|
36
|
+
e.preventDefault();
|
|
37
37
|
if (!input?.trim()) {
|
|
38
|
-
return
|
|
38
|
+
return;
|
|
39
39
|
}
|
|
40
|
-
setInput(
|
|
41
|
-
await onSubmit(input)
|
|
40
|
+
setInput("");
|
|
41
|
+
await onSubmit(input);
|
|
42
42
|
}}
|
|
43
43
|
ref={formRef}
|
|
44
44
|
>
|
|
@@ -48,8 +48,8 @@ export function PromptForm({
|
|
|
48
48
|
<Link
|
|
49
49
|
href="/"
|
|
50
50
|
className={cn(
|
|
51
|
-
buttonVariants({ size:
|
|
52
|
-
|
|
51
|
+
buttonVariants({ size: "sm", variant: "outline" }),
|
|
52
|
+
"absolute left-0 top-4 h-8 w-8 rounded-full bg-background p-0 sm:left-4"
|
|
53
53
|
)}
|
|
54
54
|
>
|
|
55
55
|
<IconPlus />
|
|
@@ -64,7 +64,7 @@ export function PromptForm({
|
|
|
64
64
|
onKeyDown={onKeyDown}
|
|
65
65
|
rows={1}
|
|
66
66
|
value={input}
|
|
67
|
-
onChange={e => setInput(e.target.value)}
|
|
67
|
+
onChange={(e) => setInput(e.target.value)}
|
|
68
68
|
placeholder="Send a message."
|
|
69
69
|
spellCheck={false}
|
|
70
70
|
className="min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"
|
|
@@ -75,7 +75,7 @@ export function PromptForm({
|
|
|
75
75
|
<Button
|
|
76
76
|
type="submit"
|
|
77
77
|
size="icon"
|
|
78
|
-
disabled={isLoading || input ===
|
|
78
|
+
disabled={isLoading || input === ""}
|
|
79
79
|
className=" bg-slate-300"
|
|
80
80
|
>
|
|
81
81
|
<IconArrowElbow />
|
|
@@ -87,5 +87,5 @@ export function PromptForm({
|
|
|
87
87
|
</div>
|
|
88
88
|
</div>
|
|
89
89
|
</form>
|
|
90
|
-
)
|
|
90
|
+
);
|
|
91
91
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import { useTheme } from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useTheme } from "next-themes";
|
|
5
5
|
|
|
6
|
-
import { Button } from
|
|
7
|
-
import { IconMoon, IconSun } from
|
|
6
|
+
import { Button } from "./ui/button";
|
|
7
|
+
import { IconMoon, IconSun } from "./ui/icons";
|
|
8
8
|
|
|
9
9
|
export function ThemeToggle() {
|
|
10
|
-
const { setTheme, theme } = useTheme()
|
|
11
|
-
const [_, startTransition] = React.useTransition()
|
|
10
|
+
const { setTheme, theme } = useTheme();
|
|
11
|
+
const [_, startTransition] = React.useTransition();
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<Button
|
|
@@ -16,16 +16,16 @@ export function ThemeToggle() {
|
|
|
16
16
|
size="icon"
|
|
17
17
|
onClick={() => {
|
|
18
18
|
startTransition(() => {
|
|
19
|
-
setTheme(theme ===
|
|
20
|
-
})
|
|
19
|
+
setTheme(theme === "light" ? "dark" : "light");
|
|
20
|
+
});
|
|
21
21
|
}}
|
|
22
22
|
>
|
|
23
|
-
{!theme ? null : theme ===
|
|
23
|
+
{!theme ? null : theme === "dark" ? (
|
|
24
24
|
<IconMoon className="transition-all" />
|
|
25
25
|
) : (
|
|
26
26
|
<IconSun className="transition-all" />
|
|
27
27
|
)}
|
|
28
28
|
<span className="sr-only">Toggle theme</span>
|
|
29
29
|
</Button>
|
|
30
|
-
)
|
|
30
|
+
);
|
|
31
31
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
export { Toaster } from
|
|
3
|
+
export { Toaster } from "react-hot-toast";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
|
|
3
|
-
import * as React from
|
|
4
|
-
import * as AlertDialogPrimitive from
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
5
5
|
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { buttonVariants } from
|
|
6
|
+
import { cn } from "../../../lib/utils";
|
|
7
|
+
import { buttonVariants } from "./button";
|
|
8
8
|
|
|
9
|
-
const AlertDialog = AlertDialogPrimitive.Root
|
|
9
|
+
const AlertDialog = AlertDialogPrimitive.Root;
|
|
10
10
|
|
|
11
|
-
const AlertDialogTrigger = AlertDialogPrimitive.Trigger
|
|
11
|
+
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
12
12
|
|
|
13
13
|
const AlertDialogPortal = ({
|
|
14
14
|
className,
|
|
@@ -20,8 +20,8 @@ const AlertDialogPortal = ({
|
|
|
20
20
|
{children}
|
|
21
21
|
</div>
|
|
22
22
|
</AlertDialogPrimitive.Portal>
|
|
23
|
-
)
|
|
24
|
-
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName
|
|
23
|
+
);
|
|
24
|
+
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName;
|
|
25
25
|
|
|
26
26
|
const AlertDialogOverlay = React.forwardRef<
|
|
27
27
|
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
@@ -29,14 +29,14 @@ const AlertDialogOverlay = React.forwardRef<
|
|
|
29
29
|
>(({ className, children, ...props }, ref) => (
|
|
30
30
|
<AlertDialogPrimitive.Overlay
|
|
31
31
|
className={cn(
|
|
32
|
-
|
|
32
|
+
"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in",
|
|
33
33
|
className
|
|
34
34
|
)}
|
|
35
35
|
{...props}
|
|
36
36
|
ref={ref}
|
|
37
37
|
/>
|
|
38
|
-
))
|
|
39
|
-
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
|
|
38
|
+
));
|
|
39
|
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
40
40
|
|
|
41
41
|
const AlertDialogContent = React.forwardRef<
|
|
42
42
|
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
@@ -47,14 +47,14 @@ const AlertDialogContent = React.forwardRef<
|
|
|
47
47
|
<AlertDialogPrimitive.Content
|
|
48
48
|
ref={ref}
|
|
49
49
|
className={cn(
|
|
50
|
-
|
|
50
|
+
"fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full",
|
|
51
51
|
className
|
|
52
52
|
)}
|
|
53
53
|
{...props}
|
|
54
54
|
/>
|
|
55
55
|
</AlertDialogPortal>
|
|
56
|
-
))
|
|
57
|
-
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
|
|
56
|
+
));
|
|
57
|
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
58
58
|
|
|
59
59
|
const AlertDialogHeader = ({
|
|
60
60
|
className,
|
|
@@ -62,13 +62,13 @@ const AlertDialogHeader = ({
|
|
|
62
62
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
63
63
|
<div
|
|
64
64
|
className={cn(
|
|
65
|
-
|
|
65
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
66
66
|
className
|
|
67
67
|
)}
|
|
68
68
|
{...props}
|
|
69
69
|
/>
|
|
70
|
-
)
|
|
71
|
-
AlertDialogHeader.displayName =
|
|
70
|
+
);
|
|
71
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
72
72
|
|
|
73
73
|
const AlertDialogFooter = ({
|
|
74
74
|
className,
|
|
@@ -76,13 +76,13 @@ const AlertDialogFooter = ({
|
|
|
76
76
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
77
77
|
<div
|
|
78
78
|
className={cn(
|
|
79
|
-
|
|
79
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
80
80
|
className
|
|
81
81
|
)}
|
|
82
82
|
{...props}
|
|
83
83
|
/>
|
|
84
|
-
)
|
|
85
|
-
AlertDialogFooter.displayName =
|
|
84
|
+
);
|
|
85
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
86
86
|
|
|
87
87
|
const AlertDialogTitle = React.forwardRef<
|
|
88
88
|
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
@@ -90,11 +90,11 @@ const AlertDialogTitle = React.forwardRef<
|
|
|
90
90
|
>(({ className, ...props }, ref) => (
|
|
91
91
|
<AlertDialogPrimitive.Title
|
|
92
92
|
ref={ref}
|
|
93
|
-
className={cn(
|
|
93
|
+
className={cn("text-lg font-semibold", className)}
|
|
94
94
|
{...props}
|
|
95
95
|
/>
|
|
96
|
-
))
|
|
97
|
-
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
|
|
96
|
+
));
|
|
97
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
98
98
|
|
|
99
99
|
const AlertDialogDescription = React.forwardRef<
|
|
100
100
|
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
@@ -102,12 +102,12 @@ const AlertDialogDescription = React.forwardRef<
|
|
|
102
102
|
>(({ className, ...props }, ref) => (
|
|
103
103
|
<AlertDialogPrimitive.Description
|
|
104
104
|
ref={ref}
|
|
105
|
-
className={cn(
|
|
105
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
106
106
|
{...props}
|
|
107
107
|
/>
|
|
108
|
-
))
|
|
108
|
+
));
|
|
109
109
|
AlertDialogDescription.displayName =
|
|
110
|
-
AlertDialogPrimitive.Description.displayName
|
|
110
|
+
AlertDialogPrimitive.Description.displayName;
|
|
111
111
|
|
|
112
112
|
const AlertDialogAction = React.forwardRef<
|
|
113
113
|
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
@@ -118,8 +118,8 @@ const AlertDialogAction = React.forwardRef<
|
|
|
118
118
|
className={cn(buttonVariants(), className)}
|
|
119
119
|
{...props}
|
|
120
120
|
/>
|
|
121
|
-
))
|
|
122
|
-
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
|
|
121
|
+
));
|
|
122
|
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
123
123
|
|
|
124
124
|
const AlertDialogCancel = React.forwardRef<
|
|
125
125
|
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
@@ -128,14 +128,14 @@ const AlertDialogCancel = React.forwardRef<
|
|
|
128
128
|
<AlertDialogPrimitive.Cancel
|
|
129
129
|
ref={ref}
|
|
130
130
|
className={cn(
|
|
131
|
-
buttonVariants({ variant:
|
|
132
|
-
|
|
131
|
+
buttonVariants({ variant: "outline" }),
|
|
132
|
+
"mt-2 sm:mt-0",
|
|
133
133
|
className
|
|
134
134
|
)}
|
|
135
135
|
{...props}
|
|
136
136
|
/>
|
|
137
|
-
))
|
|
138
|
-
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
|
|
137
|
+
));
|
|
138
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
139
139
|
|
|
140
140
|
export {
|
|
141
141
|
AlertDialog,
|
|
@@ -146,5 +146,5 @@ export {
|
|
|
146
146
|
AlertDialogTitle,
|
|
147
147
|
AlertDialogDescription,
|
|
148
148
|
AlertDialogAction,
|
|
149
|
-
AlertDialogCancel
|
|
150
|
-
}
|
|
149
|
+
AlertDialogCancel,
|
|
150
|
+
};
|