@copilotkit/react-ui 1.51.4-next.7 → 1.51.4-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +18 -12
- package/dist/{chunk-O72ZB5V3.mjs → chunk-2QEDCM6H.mjs} +22 -12
- package/dist/chunk-2QEDCM6H.mjs.map +1 -0
- package/dist/{chunk-54JAUBUJ.mjs → chunk-6SMTHXVA.mjs} +4 -2
- package/dist/chunk-6SMTHXVA.mjs.map +1 -0
- package/dist/{chunk-IEMQ2SQW.mjs → chunk-6TLDRWAD.mjs} +5 -3
- package/dist/{chunk-IEMQ2SQW.mjs.map → chunk-6TLDRWAD.mjs.map} +1 -1
- package/dist/{chunk-UFN2VWSR.mjs → chunk-72FQQMQ2.mjs} +2 -2
- package/dist/chunk-72FQQMQ2.mjs.map +1 -0
- package/dist/{chunk-ELGRNEAO.mjs → chunk-AOUHT4JR.mjs} +4 -2
- package/dist/chunk-AOUHT4JR.mjs.map +1 -0
- package/dist/{chunk-C3GSYRC3.mjs → chunk-BNJX66OH.mjs} +2 -2
- package/dist/{chunk-NRA3CFEE.mjs → chunk-C27LZFA5.mjs} +2 -2
- package/dist/{chunk-FFJHOZX6.mjs → chunk-C7WM7GM3.mjs} +44 -11
- package/dist/chunk-C7WM7GM3.mjs.map +1 -0
- package/dist/{chunk-6TWQUA2Q.mjs → chunk-CNIC5HO5.mjs} +8 -3
- package/dist/chunk-CNIC5HO5.mjs.map +1 -0
- package/dist/chunk-CQCXH5LY.mjs +143 -0
- package/dist/chunk-CQCXH5LY.mjs.map +1 -0
- package/dist/{chunk-RYUCX3ZK.mjs → chunk-DM2V5WTG.mjs} +4 -2
- package/dist/chunk-DM2V5WTG.mjs.map +1 -0
- package/dist/{chunk-JZ3RFQQ6.mjs → chunk-DSHTRV2R.mjs} +16 -4
- package/dist/chunk-DSHTRV2R.mjs.map +1 -0
- package/dist/{chunk-GDSZGYCE.mjs → chunk-EACIYBQH.mjs} +3 -3
- package/dist/{chunk-XWG3L6QC.mjs → chunk-GBAPANZE.mjs} +76 -11
- package/dist/chunk-GBAPANZE.mjs.map +1 -0
- package/dist/{chunk-Q5V6S67N.mjs → chunk-GFE5ZSPV.mjs} +15 -6
- package/dist/chunk-GFE5ZSPV.mjs.map +1 -0
- package/dist/{chunk-VHKHX7GV.mjs → chunk-HHLX4MQN.mjs} +2 -2
- package/dist/{chunk-WNX755OE.mjs → chunk-ICA2EXIX.mjs} +7 -4
- package/dist/chunk-ICA2EXIX.mjs.map +1 -0
- package/dist/{chunk-QIOJXTIQ.mjs → chunk-IWOCQACI.mjs} +12 -3
- package/dist/chunk-IWOCQACI.mjs.map +1 -0
- package/dist/{chunk-BH6PCAAL.mjs → chunk-JYHRHKV5.mjs} +12 -3
- package/dist/chunk-JYHRHKV5.mjs.map +1 -0
- package/dist/{chunk-IK2BPURM.mjs → chunk-LIXN3OVQ.mjs} +12 -7
- package/dist/chunk-LIXN3OVQ.mjs.map +1 -0
- package/dist/{chunk-PD36EMOZ.mjs → chunk-MC6PY7XH.mjs} +75 -54
- package/dist/chunk-MC6PY7XH.mjs.map +1 -0
- package/dist/{chunk-LYYDXL2G.mjs → chunk-OQWEOBRX.mjs} +3 -3
- package/dist/chunk-OQWEOBRX.mjs.map +1 -0
- package/dist/{chunk-LBR23XXF.mjs → chunk-P34CL4LC.mjs} +4 -4
- package/dist/{chunk-F2CDEOFX.mjs → chunk-PF3QBO7V.mjs} +2 -2
- package/dist/chunk-PF3QBO7V.mjs.map +1 -0
- package/dist/{chunk-7CMZ7YPQ.mjs → chunk-PP2A5RP6.mjs} +2 -2
- package/dist/{chunk-7CMZ7YPQ.mjs.map → chunk-PP2A5RP6.mjs.map} +1 -1
- package/dist/{chunk-RKQM2AE5.mjs → chunk-Q64GLWPQ.mjs} +2 -2
- package/dist/{chunk-RKQM2AE5.mjs.map → chunk-Q64GLWPQ.mjs.map} +1 -1
- package/dist/{chunk-OHGUQZJT.mjs → chunk-T4NNQG6T.mjs} +50 -41
- package/dist/chunk-T4NNQG6T.mjs.map +1 -0
- package/dist/{chunk-DBKRAOH7.mjs → chunk-TGM5PKBF.mjs} +16 -6
- package/dist/chunk-TGM5PKBF.mjs.map +1 -0
- package/dist/{chunk-JY2CSDKN.mjs → chunk-YDJ4YUUF.mjs} +22 -16
- package/dist/chunk-YDJ4YUUF.mjs.map +1 -0
- package/dist/components/chat/Button.js +3 -1
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +3 -3
- package/dist/components/chat/Chat.js +285 -132
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +18 -18
- package/dist/components/chat/ChatContext.js +63 -9
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +2 -2
- package/dist/components/chat/CodeBlock.js +20 -6
- package/dist/components/chat/CodeBlock.js.map +1 -1
- package/dist/components/chat/CodeBlock.mjs +3 -3
- package/dist/components/chat/Header.js +88 -28
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +8 -8
- package/dist/components/chat/Icons.js +75 -10
- package/dist/components/chat/Icons.js.map +1 -1
- package/dist/components/chat/Icons.mjs +1 -1
- package/dist/components/chat/Input.js +90 -62
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +6 -6
- package/dist/components/chat/Markdown.js +34 -8
- package/dist/components/chat/Markdown.js.map +1 -1
- package/dist/components/chat/Markdown.mjs +4 -4
- package/dist/components/chat/Messages.js +59 -16
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +11 -11
- package/dist/components/chat/Modal.js +403 -189
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +27 -27
- package/dist/components/chat/Popup.js +403 -189
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +28 -28
- package/dist/components/chat/PoweredByTag.d.ts +1 -1
- package/dist/components/chat/PoweredByTag.js +3 -1
- package/dist/components/chat/PoweredByTag.js.map +1 -1
- package/dist/components/chat/PoweredByTag.mjs +1 -1
- package/dist/components/chat/Sidebar.js +403 -189
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +28 -28
- package/dist/components/chat/Suggestion.d.ts +1 -1
- package/dist/components/chat/Suggestion.js +13 -2
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +2 -2
- package/dist/components/chat/Suggestions.js +13 -2
- package/dist/components/chat/Suggestions.js.map +1 -1
- package/dist/components/chat/Suggestions.mjs +3 -3
- package/dist/components/chat/Textarea.js +4 -1
- package/dist/components/chat/Textarea.js.map +1 -1
- package/dist/components/chat/Textarea.mjs +1 -1
- package/dist/components/chat/Window.js +3 -1
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +3 -3
- package/dist/components/chat/index.js +403 -189
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +29 -29
- package/dist/components/chat/messages/AssistantMessage.js +37 -9
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +6 -6
- package/dist/components/chat/messages/ErrorMessage.js +65 -31
- package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
- package/dist/components/chat/messages/ErrorMessage.mjs +33 -27
- package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -1
- package/dist/components/chat/messages/ImageRenderer.js +15 -5
- package/dist/components/chat/messages/ImageRenderer.js.map +1 -1
- package/dist/components/chat/messages/ImageRenderer.mjs +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.js +55 -15
- package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
- package/dist/components/chat/messages/LegacyRenderMessage.mjs +10 -10
- package/dist/components/chat/messages/RenderMessage.js +55 -15
- package/dist/components/chat/messages/RenderMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderMessage.mjs +9 -9
- package/dist/components/chat/messages/UserMessage.js +3 -1
- package/dist/components/chat/messages/UserMessage.js.map +1 -1
- package/dist/components/chat/messages/UserMessage.mjs +1 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.js +85 -27
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +6 -6
- package/dist/components/dev-console/icons.js +14 -5
- package/dist/components/dev-console/icons.js.map +1 -1
- package/dist/components/dev-console/icons.mjs +1 -1
- package/dist/components/dev-console/index.js +85 -27
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +6 -6
- package/dist/components/dev-console/utils.js +21 -15
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/help-modal/icons.d.ts +1 -1
- package/dist/components/help-modal/icons.js +11 -2
- package/dist/components/help-modal/icons.js.map +1 -1
- package/dist/components/help-modal/icons.mjs +1 -1
- package/dist/components/help-modal/index.js +8 -1
- package/dist/components/help-modal/index.js.map +1 -1
- package/dist/components/help-modal/index.mjs +2 -2
- package/dist/components/help-modal/modal.js +8 -1
- package/dist/components/help-modal/modal.js.map +1 -1
- package/dist/components/help-modal/modal.mjs +2 -2
- package/dist/components/index.js +403 -189
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +29 -29
- package/dist/hooks/use-copy-to-clipboard.d.ts +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +3 -1
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.mjs +1 -1
- package/dist/hooks/use-push-to-talk.js +17 -10
- package/dist/hooks/use-push-to-talk.js.map +1 -1
- package/dist/hooks/use-push-to-talk.mjs +1 -1
- package/dist/index.js +403 -189
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -34
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/utils.mjs.map +1 -1
- package/package.json +4 -5
- package/src/components/chat/Button.tsx +6 -2
- package/src/components/chat/Chat.tsx +75 -48
- package/src/components/chat/ChatContext.tsx +6 -2
- package/src/components/chat/CodeBlock.tsx +11 -6
- package/src/components/chat/Icons.tsx +45 -10
- package/src/components/chat/Input.tsx +30 -7
- package/src/components/chat/Markdown.tsx +12 -3
- package/src/components/chat/Messages.tsx +24 -8
- package/src/components/chat/Modal.tsx +12 -2
- package/src/components/chat/Popup.tsx +3 -1
- package/src/components/chat/PoweredByTag.tsx +5 -1
- package/src/components/chat/Sidebar.tsx +3 -1
- package/src/components/chat/Suggestion.tsx +6 -1
- package/src/components/chat/Textarea.tsx +15 -3
- package/src/components/chat/messages/AssistantMessage.tsx +12 -4
- package/src/components/chat/messages/ErrorMessage.tsx +3 -1
- package/src/components/chat/messages/ImageRenderer.tsx +17 -5
- package/src/components/chat/messages/LegacyRenderMessage.tsx +4 -1
- package/src/components/chat/messages/UserMessage.tsx +12 -4
- package/src/components/chat/props.ts +13 -3
- package/src/components/dev-console/console.tsx +35 -9
- package/src/components/dev-console/icons.tsx +6 -1
- package/src/components/dev-console/utils.ts +23 -15
- package/src/components/help-modal/icons.tsx +10 -2
- package/src/hooks/use-copy-to-clipboard.tsx +3 -1
- package/src/hooks/use-push-to-talk.tsx +45 -18
- package/src/lib/utils.ts +4 -1
- package/tsconfig.json +1 -1
- package/tsup.config.ts +5 -1
- package/dist/chunk-3W6J75HS.mjs +0 -126
- package/dist/chunk-3W6J75HS.mjs.map +0 -1
- package/dist/chunk-54JAUBUJ.mjs.map +0 -1
- package/dist/chunk-6TWQUA2Q.mjs.map +0 -1
- package/dist/chunk-BH6PCAAL.mjs.map +0 -1
- package/dist/chunk-DBKRAOH7.mjs.map +0 -1
- package/dist/chunk-ELGRNEAO.mjs.map +0 -1
- package/dist/chunk-F2CDEOFX.mjs.map +0 -1
- package/dist/chunk-FFJHOZX6.mjs.map +0 -1
- package/dist/chunk-IK2BPURM.mjs.map +0 -1
- package/dist/chunk-JY2CSDKN.mjs.map +0 -1
- package/dist/chunk-JZ3RFQQ6.mjs.map +0 -1
- package/dist/chunk-LYYDXL2G.mjs.map +0 -1
- package/dist/chunk-O72ZB5V3.mjs.map +0 -1
- package/dist/chunk-OHGUQZJT.mjs.map +0 -1
- package/dist/chunk-PD36EMOZ.mjs.map +0 -1
- package/dist/chunk-Q5V6S67N.mjs.map +0 -1
- package/dist/chunk-QIOJXTIQ.mjs.map +0 -1
- package/dist/chunk-RYUCX3ZK.mjs.map +0 -1
- package/dist/chunk-UFN2VWSR.mjs.map +0 -1
- package/dist/chunk-WNX755OE.mjs.map +0 -1
- package/dist/chunk-XWG3L6QC.mjs.map +0 -1
- /package/dist/{chunk-C3GSYRC3.mjs.map → chunk-BNJX66OH.mjs.map} +0 -0
- /package/dist/{chunk-NRA3CFEE.mjs.map → chunk-C27LZFA5.mjs.map} +0 -0
- /package/dist/{chunk-GDSZGYCE.mjs.map → chunk-EACIYBQH.mjs.map} +0 -0
- /package/dist/{chunk-VHKHX7GV.mjs.map → chunk-HHLX4MQN.mjs.map} +0 -0
- /package/dist/{chunk-LBR23XXF.mjs.map → chunk-P34CL4LC.mjs.map} +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
2
|
import { useDarkMode } from "../../hooks/use-dark-mode";
|
|
3
3
|
|
|
4
|
-
export function PoweredByTag({
|
|
4
|
+
export function PoweredByTag({
|
|
5
|
+
showPoweredBy = true,
|
|
6
|
+
}: {
|
|
7
|
+
showPoweredBy?: boolean;
|
|
8
|
+
}) {
|
|
5
9
|
const [mounted, setMounted] = useState(false);
|
|
6
10
|
const isDark = useDarkMode();
|
|
7
11
|
|
|
@@ -75,7 +75,9 @@ import { CopilotModal, CopilotModalProps } from "./Modal";
|
|
|
75
75
|
export function CopilotSidebar(props: CopilotModalProps) {
|
|
76
76
|
props = {
|
|
77
77
|
...props,
|
|
78
|
-
className: props.className
|
|
78
|
+
className: props.className
|
|
79
|
+
? props.className + " copilotKitSidebar"
|
|
80
|
+
: "copilotKitSidebar",
|
|
79
81
|
};
|
|
80
82
|
const [expandedClassName, setExpandedClassName] = useState(
|
|
81
83
|
props.defaultOpen ? "sidebarExpanded" : "",
|
|
@@ -9,7 +9,12 @@ interface SuggestionsProps {
|
|
|
9
9
|
onClick: () => void;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export function Suggestion({
|
|
12
|
+
export function Suggestion({
|
|
13
|
+
title,
|
|
14
|
+
onClick,
|
|
15
|
+
partial,
|
|
16
|
+
className,
|
|
17
|
+
}: SuggestionsProps) {
|
|
13
18
|
const { isLoading } = useCopilotChatInternal();
|
|
14
19
|
if (!title) return null;
|
|
15
20
|
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
useRef,
|
|
4
|
+
useEffect,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
} from "react";
|
|
2
8
|
|
|
3
9
|
interface AutoResizingTextareaProps {
|
|
4
10
|
maxRows?: number;
|
|
@@ -11,7 +17,10 @@ interface AutoResizingTextareaProps {
|
|
|
11
17
|
autoFocus?: boolean;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
const AutoResizingTextarea = forwardRef<
|
|
20
|
+
const AutoResizingTextarea = forwardRef<
|
|
21
|
+
HTMLTextAreaElement,
|
|
22
|
+
AutoResizingTextareaProps
|
|
23
|
+
>(
|
|
15
24
|
(
|
|
16
25
|
{
|
|
17
26
|
maxRows = 1,
|
|
@@ -28,7 +37,10 @@ const AutoResizingTextarea = forwardRef<HTMLTextAreaElement, AutoResizingTextare
|
|
|
28
37
|
const internalTextareaRef = useRef<HTMLTextAreaElement>(null);
|
|
29
38
|
const [maxHeight, setMaxHeight] = useState<number>(0);
|
|
30
39
|
|
|
31
|
-
useImperativeHandle(
|
|
40
|
+
useImperativeHandle(
|
|
41
|
+
ref,
|
|
42
|
+
() => internalTextareaRef.current as HTMLTextAreaElement,
|
|
43
|
+
);
|
|
32
44
|
|
|
33
45
|
useEffect(() => {
|
|
34
46
|
const calculateMaxHeight = () => {
|
|
@@ -58,10 +58,14 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
|
|
|
58
58
|
|
|
59
59
|
return (
|
|
60
60
|
<>
|
|
61
|
-
{renderBefore ?
|
|
61
|
+
{renderBefore ? (
|
|
62
|
+
<div style={{ marginBottom: "0.5rem" }}>{subComponent}</div>
|
|
63
|
+
) : null}
|
|
62
64
|
{content && (
|
|
63
65
|
<div className="copilotKitMessage copilotKitAssistantMessage">
|
|
64
|
-
{content &&
|
|
66
|
+
{content && (
|
|
67
|
+
<Markdown content={content} components={markdownTagRenderers} />
|
|
68
|
+
)}
|
|
65
69
|
|
|
66
70
|
{content && !isLoading && (
|
|
67
71
|
<div
|
|
@@ -82,7 +86,9 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
|
|
|
82
86
|
title={labels.copyToClipboard}
|
|
83
87
|
>
|
|
84
88
|
{copied ? (
|
|
85
|
-
<span style={{ fontSize: "10px", fontWeight: "bold" }}
|
|
89
|
+
<span style={{ fontSize: "10px", fontWeight: "bold" }}>
|
|
90
|
+
✓
|
|
91
|
+
</span>
|
|
86
92
|
) : (
|
|
87
93
|
icons.copyIcon
|
|
88
94
|
)}
|
|
@@ -115,7 +121,9 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
|
|
|
115
121
|
)}
|
|
116
122
|
</div>
|
|
117
123
|
)}
|
|
118
|
-
{renderAfter ?
|
|
124
|
+
{renderAfter ? (
|
|
125
|
+
<div style={{ marginBottom: "0.5rem" }}>{subComponent}</div>
|
|
126
|
+
) : null}
|
|
119
127
|
{isLoading && <LoadingIcon />}
|
|
120
128
|
</>
|
|
121
129
|
);
|
|
@@ -32,7 +32,9 @@ export const ErrorMessage = (props: ErrorMessageProps) => {
|
|
|
32
32
|
<div className="copilotKitMessage copilotKitAssistantMessage">
|
|
33
33
|
<Markdown content={error.message} />
|
|
34
34
|
|
|
35
|
-
<div
|
|
35
|
+
<div
|
|
36
|
+
className={`copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`}
|
|
37
|
+
>
|
|
36
38
|
<button
|
|
37
39
|
className="copilotKitMessageControlButton"
|
|
38
40
|
onClick={handleRegenerate}
|
|
@@ -5,7 +5,11 @@ import { ImageRendererProps } from "../props";
|
|
|
5
5
|
* Default image rendering component that can be customized by users.
|
|
6
6
|
* Uses CSS classes for styling so users can override styles.
|
|
7
7
|
*/
|
|
8
|
-
export const ImageRenderer: React.FC<ImageRendererProps> = ({
|
|
8
|
+
export const ImageRenderer: React.FC<ImageRendererProps> = ({
|
|
9
|
+
image,
|
|
10
|
+
content,
|
|
11
|
+
className = "",
|
|
12
|
+
}) => {
|
|
9
13
|
const [imageError, setImageError] = useState(false);
|
|
10
14
|
const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
|
|
11
15
|
const altText = content || "User uploaded image";
|
|
@@ -16,9 +20,15 @@ export const ImageRenderer: React.FC<ImageRendererProps> = ({ image, content, cl
|
|
|
16
20
|
|
|
17
21
|
if (imageError) {
|
|
18
22
|
return (
|
|
19
|
-
<div
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
<div
|
|
24
|
+
className={`copilotKitImageRendering copilotKitImageRenderingError ${className}`}
|
|
25
|
+
>
|
|
26
|
+
<div className="copilotKitImageRenderingErrorMessage">
|
|
27
|
+
Failed to load image
|
|
28
|
+
</div>
|
|
29
|
+
{content && (
|
|
30
|
+
<div className="copilotKitImageRenderingContent">{content}</div>
|
|
31
|
+
)}
|
|
22
32
|
</div>
|
|
23
33
|
);
|
|
24
34
|
}
|
|
@@ -31,7 +41,9 @@ export const ImageRenderer: React.FC<ImageRendererProps> = ({ image, content, cl
|
|
|
31
41
|
className="copilotKitImageRenderingImage"
|
|
32
42
|
onError={handleImageError}
|
|
33
43
|
/>
|
|
34
|
-
{content &&
|
|
44
|
+
{content && (
|
|
45
|
+
<div className="copilotKitImageRenderingContent">{content}</div>
|
|
46
|
+
)}
|
|
35
47
|
</div>
|
|
36
48
|
);
|
|
37
49
|
};
|
|
@@ -72,7 +72,10 @@ export const LegacyRenderMessage: React.FC<LegacyRenderMessageProps> = ({
|
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
if (
|
|
75
|
+
if (
|
|
76
|
+
deprecatedMessage.isActionExecutionMessage() &&
|
|
77
|
+
RenderActionExecutionMessage
|
|
78
|
+
) {
|
|
76
79
|
return (
|
|
77
80
|
<RenderActionExecutionMessage
|
|
78
81
|
messages={messages}
|
|
@@ -2,7 +2,9 @@ import { UserMessageProps } from "../props";
|
|
|
2
2
|
|
|
3
3
|
type UserMessageContent = NonNullable<UserMessageProps["message"]>["content"];
|
|
4
4
|
|
|
5
|
-
const getTextContent = (
|
|
5
|
+
const getTextContent = (
|
|
6
|
+
content: UserMessageContent | undefined,
|
|
7
|
+
): string | undefined => {
|
|
6
8
|
if (typeof content === "undefined") {
|
|
7
9
|
return undefined;
|
|
8
10
|
}
|
|
@@ -19,7 +21,10 @@ const getTextContent = (content: UserMessageContent | undefined): string | undef
|
|
|
19
21
|
}
|
|
20
22
|
return undefined;
|
|
21
23
|
})
|
|
22
|
-
.filter(
|
|
24
|
+
.filter(
|
|
25
|
+
(value): value is string =>
|
|
26
|
+
typeof value === "string" && value.length > 0,
|
|
27
|
+
)
|
|
23
28
|
.join(" ")
|
|
24
29
|
.trim() || undefined
|
|
25
30
|
);
|
|
@@ -27,7 +32,8 @@ const getTextContent = (content: UserMessageContent | undefined): string | undef
|
|
|
27
32
|
|
|
28
33
|
export const UserMessage = (props: UserMessageProps) => {
|
|
29
34
|
const { message, ImageRenderer } = props;
|
|
30
|
-
const isImageMessage =
|
|
35
|
+
const isImageMessage =
|
|
36
|
+
message && "image" in message && Boolean(message.image);
|
|
31
37
|
|
|
32
38
|
if (isImageMessage) {
|
|
33
39
|
const imageMessage = message!;
|
|
@@ -42,5 +48,7 @@ export const UserMessage = (props: UserMessageProps) => {
|
|
|
42
48
|
|
|
43
49
|
const content = getTextContent(message?.content);
|
|
44
50
|
|
|
45
|
-
return
|
|
51
|
+
return (
|
|
52
|
+
<div className="copilotKitMessage copilotKitUserMessage">{content}</div>
|
|
53
|
+
);
|
|
46
54
|
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AIMessage,
|
|
3
|
+
Message,
|
|
4
|
+
UserMessage,
|
|
5
|
+
CopilotErrorEvent,
|
|
6
|
+
} from "@copilotkit/shared";
|
|
2
7
|
import { CopilotChatSuggestion } from "../../types/suggestions";
|
|
3
8
|
import { ReactNode } from "react";
|
|
4
9
|
import { ImageData } from "@copilotkit/shared";
|
|
@@ -36,7 +41,10 @@ export interface CopilotObservabilityHooks {
|
|
|
36
41
|
/**
|
|
37
42
|
* Called when feedback is given (thumbs up/down)
|
|
38
43
|
*/
|
|
39
|
-
onFeedbackGiven?: (
|
|
44
|
+
onFeedbackGiven?: (
|
|
45
|
+
messageId: string,
|
|
46
|
+
type: "thumbsUp" | "thumbsDown",
|
|
47
|
+
) => void;
|
|
40
48
|
|
|
41
49
|
/**
|
|
42
50
|
* Called when chat generation starts
|
|
@@ -74,7 +82,9 @@ export interface SuggestionsProps {
|
|
|
74
82
|
onClick: (message: string) => void;
|
|
75
83
|
}
|
|
76
84
|
|
|
77
|
-
export type ComponentsMap<
|
|
85
|
+
export type ComponentsMap<
|
|
86
|
+
T extends Record<string, object> = Record<string, object>,
|
|
87
|
+
> = {
|
|
78
88
|
[K in keyof T]: React.FC<{ children?: ReactNode } & T[K]>;
|
|
79
89
|
};
|
|
80
90
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useCopilotContext,
|
|
5
|
+
useCopilotMessagesContext,
|
|
6
|
+
} from "@copilotkit/react-core";
|
|
4
7
|
import {
|
|
5
8
|
getPublishedCopilotKitVersion,
|
|
6
9
|
logActions,
|
|
@@ -21,7 +24,12 @@ import { COPILOTKIT_VERSION } from "@copilotkit/shared";
|
|
|
21
24
|
import { SmallSpinnerIcon } from "../chat/Icons";
|
|
22
25
|
import { CopilotKitHelpModal } from "../help-modal";
|
|
23
26
|
|
|
24
|
-
type VersionStatus =
|
|
27
|
+
type VersionStatus =
|
|
28
|
+
| "unknown"
|
|
29
|
+
| "checking"
|
|
30
|
+
| "latest"
|
|
31
|
+
| "update-available"
|
|
32
|
+
| "outdated";
|
|
25
33
|
|
|
26
34
|
export function CopilotDevConsole() {
|
|
27
35
|
const currentVersion = COPILOTKIT_VERSION;
|
|
@@ -42,7 +50,9 @@ export function CopilotDevConsole() {
|
|
|
42
50
|
const [versionStatus, setVersionStatus] = useState<VersionStatus>("unknown");
|
|
43
51
|
const [latestVersion, setLatestVersion] = useState<string>("");
|
|
44
52
|
const consoleRef = useRef<HTMLDivElement>(null);
|
|
45
|
-
const [debugButtonMode, setDebugButtonMode] = useState<"full" | "compact">(
|
|
53
|
+
const [debugButtonMode, setDebugButtonMode] = useState<"full" | "compact">(
|
|
54
|
+
"full",
|
|
55
|
+
);
|
|
46
56
|
|
|
47
57
|
const checkForUpdates = (force: boolean = false) => {
|
|
48
58
|
setVersionStatus("checking");
|
|
@@ -90,7 +100,9 @@ export function CopilotDevConsole() {
|
|
|
90
100
|
ref={consoleRef}
|
|
91
101
|
className={
|
|
92
102
|
"copilotKitDevConsole " +
|
|
93
|
-
(versionStatus === "update-available"
|
|
103
|
+
(versionStatus === "update-available"
|
|
104
|
+
? "copilotKitDevConsoleUpgrade"
|
|
105
|
+
: "") +
|
|
94
106
|
(versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : "")
|
|
95
107
|
}
|
|
96
108
|
>
|
|
@@ -171,7 +183,9 @@ function VersionInfo({
|
|
|
171
183
|
<p>
|
|
172
184
|
{currentVersionLabel} {versionIcon}
|
|
173
185
|
</p>
|
|
174
|
-
<button onClick={handleCopyClick}>
|
|
186
|
+
<button onClick={handleCopyClick}>
|
|
187
|
+
{copyStatus || installCommand}
|
|
188
|
+
</button>
|
|
175
189
|
</div>
|
|
176
190
|
);
|
|
177
191
|
}
|
|
@@ -207,12 +221,18 @@ export default function DebugMenuButton({
|
|
|
207
221
|
style={{ zIndex: 40 }}
|
|
208
222
|
>
|
|
209
223
|
<MenuItem>
|
|
210
|
-
<button
|
|
224
|
+
<button
|
|
225
|
+
className="copilotKitDebugMenuItem"
|
|
226
|
+
onClick={() => logReadables(context)}
|
|
227
|
+
>
|
|
211
228
|
Log Readables
|
|
212
229
|
</button>
|
|
213
230
|
</MenuItem>
|
|
214
231
|
<MenuItem>
|
|
215
|
-
<button
|
|
232
|
+
<button
|
|
233
|
+
className="copilotKitDebugMenuItem"
|
|
234
|
+
onClick={() => logActions(context)}
|
|
235
|
+
>
|
|
216
236
|
Log Actions
|
|
217
237
|
</button>
|
|
218
238
|
</MenuItem>
|
|
@@ -225,13 +245,19 @@ export default function DebugMenuButton({
|
|
|
225
245
|
</button>
|
|
226
246
|
</MenuItem>
|
|
227
247
|
<MenuItem>
|
|
228
|
-
<button
|
|
248
|
+
<button
|
|
249
|
+
className="copilotKitDebugMenuItem"
|
|
250
|
+
onClick={() => checkForUpdates(true)}
|
|
251
|
+
>
|
|
229
252
|
Check for Updates
|
|
230
253
|
</button>
|
|
231
254
|
</MenuItem>
|
|
232
255
|
<hr />
|
|
233
256
|
<MenuItem>
|
|
234
|
-
<button
|
|
257
|
+
<button
|
|
258
|
+
className="copilotKitDebugMenuItem"
|
|
259
|
+
onClick={() => setShowDevConsole(false)}
|
|
260
|
+
>
|
|
235
261
|
Hide Dev Console
|
|
236
262
|
</button>
|
|
237
263
|
</MenuItem>
|
|
@@ -65,7 +65,12 @@ export const CheckIcon = (
|
|
|
65
65
|
xmlns="http://www.w3.org/2000/svg"
|
|
66
66
|
>
|
|
67
67
|
<g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
|
|
68
|
-
<g
|
|
68
|
+
<g
|
|
69
|
+
id="Group-2"
|
|
70
|
+
transform="translate(-118, 0)"
|
|
71
|
+
fill="#1BC030"
|
|
72
|
+
fillRule="nonzero"
|
|
73
|
+
>
|
|
69
74
|
<g id="Group" transform="translate(118, 0)">
|
|
70
75
|
<path
|
|
71
76
|
d="M0,7 C0,3.13384615 3.13384615,0 7,0 C10.8661538,0 14,3.13384615 14,7 C14,10.8661538 10.8661538,14 7,14 C3.13384615,14 0,10.8661538 0,7 Z M9.59179487,5.69764103 C9.70905818,5.54139023 9.73249341,5.33388318 9.65303227,5.15541491 C9.57357113,4.97694665 9.40367989,4.85551619 9.20909814,4.83811118 C9.01451638,4.82070616 8.82577109,4.91005717 8.71589744,5.07158974 L6.39261538,8.32389744 L5.22666667,7.15794872 C5.01450582,6.96025518 4.68389046,6.9660885 4.47883563,7.17114332 C4.27378081,7.37619815 4.26794748,7.70681351 4.46564103,7.91897436 L6.08102564,9.53435897 C6.19289944,9.64614839 6.3482622,9.70310251 6.50588106,9.69010587 C6.66349993,9.67710922 6.80743532,9.59547613 6.89948718,9.46687179 L9.59179487,5.69764103 L9.59179487,5.69764103 Z"
|
|
@@ -25,25 +25,31 @@ export async function getPublishedCopilotKitVersion(
|
|
|
25
25
|
return parsedVersion;
|
|
26
26
|
}
|
|
27
27
|
} catch (error) {
|
|
28
|
-
console.error(
|
|
28
|
+
console.error(
|
|
29
|
+
"Failed to parse CopilotKitVersion from localStorage",
|
|
30
|
+
error,
|
|
31
|
+
);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
try {
|
|
33
|
-
const response = await fetch(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
const response = await fetch(
|
|
37
|
+
"https://api.cloud.copilotkit.ai/check-for-updates",
|
|
38
|
+
{
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: {
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
packages: [
|
|
45
|
+
{
|
|
46
|
+
packageName: "@copilotkit/shared",
|
|
47
|
+
packageVersion: current,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}),
|
|
37
51
|
},
|
|
38
|
-
|
|
39
|
-
packages: [
|
|
40
|
-
{
|
|
41
|
-
packageName: "@copilotkit/shared",
|
|
42
|
-
packageVersion: current,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
}),
|
|
46
|
-
});
|
|
52
|
+
);
|
|
47
53
|
|
|
48
54
|
const data = await response.json();
|
|
49
55
|
|
|
@@ -66,7 +72,9 @@ export async function getPublishedCopilotKitVersion(
|
|
|
66
72
|
export function logReadables(context: CopilotContextParams) {
|
|
67
73
|
console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
|
|
68
74
|
|
|
69
|
-
const readables = context
|
|
75
|
+
const readables = context
|
|
76
|
+
.getContextString([], defaultCopilotContextCategories)
|
|
77
|
+
.trim();
|
|
70
78
|
if (readables.length === 0) {
|
|
71
79
|
console.log("No readables found");
|
|
72
80
|
return;
|
|
@@ -35,11 +35,19 @@ export const CloseIcon = () => (
|
|
|
35
35
|
width="20"
|
|
36
36
|
height="20"
|
|
37
37
|
>
|
|
38
|
-
<path
|
|
38
|
+
<path
|
|
39
|
+
strokeLinecap="round"
|
|
40
|
+
strokeLinejoin="round"
|
|
41
|
+
d="M6 18L18 6M6 6l12 12"
|
|
42
|
+
/>
|
|
39
43
|
</svg>
|
|
40
44
|
);
|
|
41
45
|
|
|
42
|
-
export const LoadingSpinnerIcon = ({
|
|
46
|
+
export const LoadingSpinnerIcon = ({
|
|
47
|
+
color = "rgb(107 114 128)",
|
|
48
|
+
}: {
|
|
49
|
+
color?: string;
|
|
50
|
+
}) => (
|
|
43
51
|
<svg
|
|
44
52
|
style={{
|
|
45
53
|
animation: "copilotKitSpinAnimation 1s linear infinite",
|
|
@@ -4,7 +4,9 @@ export interface useCopyToClipboardProps {
|
|
|
4
4
|
timeout?: number;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export function useCopyToClipboard({
|
|
7
|
+
export function useCopyToClipboard({
|
|
8
|
+
timeout = 2000,
|
|
9
|
+
}: useCopyToClipboardProps) {
|
|
8
10
|
const [isCopied, setIsCopied] = React.useState<Boolean>(false);
|
|
9
11
|
|
|
10
12
|
const copyToClipboard = (value: string) => {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useCopilotContext,
|
|
3
|
+
useCopilotMessagesContext,
|
|
4
|
+
} from "@copilotkit/react-core";
|
|
2
5
|
import { gqlToAGUI } from "@copilotkit/runtime-client-gql";
|
|
3
6
|
import { Message } from "@copilotkit/shared";
|
|
4
7
|
import { MutableRefObject, useEffect, useRef, useState } from "react";
|
|
@@ -38,7 +41,9 @@ const startRecording = async (
|
|
|
38
41
|
onStop: () => void,
|
|
39
42
|
) => {
|
|
40
43
|
if (!mediaStreamRef.current || !audioContextRef.current) {
|
|
41
|
-
mediaStreamRef.current = await navigator.mediaDevices.getUserMedia({
|
|
44
|
+
mediaStreamRef.current = await navigator.mediaDevices.getUserMedia({
|
|
45
|
+
audio: true,
|
|
46
|
+
});
|
|
42
47
|
audioContextRef.current = new window.AudioContext();
|
|
43
48
|
await audioContextRef.current.resume();
|
|
44
49
|
}
|
|
@@ -51,13 +56,21 @@ const startRecording = async (
|
|
|
51
56
|
mediaRecorderRef.current.onstop = onStop;
|
|
52
57
|
};
|
|
53
58
|
|
|
54
|
-
const stopRecording = (
|
|
55
|
-
|
|
59
|
+
const stopRecording = (
|
|
60
|
+
mediaRecorderRef: MutableRefObject<MediaRecorder | null>,
|
|
61
|
+
) => {
|
|
62
|
+
if (
|
|
63
|
+
mediaRecorderRef.current &&
|
|
64
|
+
mediaRecorderRef.current.state !== "inactive"
|
|
65
|
+
) {
|
|
56
66
|
mediaRecorderRef.current.stop();
|
|
57
67
|
}
|
|
58
68
|
};
|
|
59
69
|
|
|
60
|
-
const transcribeAudio = async (
|
|
70
|
+
const transcribeAudio = async (
|
|
71
|
+
recordedChunks: Blob[],
|
|
72
|
+
transcribeAudioUrl: string,
|
|
73
|
+
) => {
|
|
61
74
|
const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
|
|
62
75
|
const formData = new FormData();
|
|
63
76
|
formData.append("file", completeBlob, "recording.mp4");
|
|
@@ -75,7 +88,11 @@ const transcribeAudio = async (recordedChunks: Blob[], transcribeAudioUrl: strin
|
|
|
75
88
|
return transcription.text;
|
|
76
89
|
};
|
|
77
90
|
|
|
78
|
-
const playAudioResponse = (
|
|
91
|
+
const playAudioResponse = (
|
|
92
|
+
text: string,
|
|
93
|
+
textToSpeechUrl: string,
|
|
94
|
+
audioContext: AudioContext,
|
|
95
|
+
) => {
|
|
79
96
|
const encodedText = encodeURIComponent(text);
|
|
80
97
|
const url = `${textToSpeechUrl}?text=${encodedText}`;
|
|
81
98
|
|
|
@@ -104,7 +121,8 @@ export const usePushToTalk = ({
|
|
|
104
121
|
sendFunction: SendFunction;
|
|
105
122
|
inProgress: boolean;
|
|
106
123
|
}) => {
|
|
107
|
-
const [pushToTalkState, setPushToTalkState] =
|
|
124
|
+
const [pushToTalkState, setPushToTalkState] =
|
|
125
|
+
useState<PushToTalkState>("idle");
|
|
108
126
|
const mediaStreamRef = useRef<MediaStream | null>(null);
|
|
109
127
|
const audioContextRef = useRef<AudioContext | null>(null);
|
|
110
128
|
const mediaRecorderRef = useRef<MediaRecorder | null>(null);
|
|
@@ -112,7 +130,9 @@ export const usePushToTalk = ({
|
|
|
112
130
|
const generalContext = useCopilotContext();
|
|
113
131
|
const messagesContext = useCopilotMessagesContext();
|
|
114
132
|
const context = { ...generalContext, ...messagesContext };
|
|
115
|
-
const [startReadingFromMessageId, setStartReadingFromMessageId] = useState<
|
|
133
|
+
const [startReadingFromMessageId, setStartReadingFromMessageId] = useState<
|
|
134
|
+
string | null
|
|
135
|
+
>(null);
|
|
116
136
|
|
|
117
137
|
useEffect(() => {
|
|
118
138
|
if (pushToTalkState === "recording") {
|
|
@@ -128,14 +148,15 @@ export const usePushToTalk = ({
|
|
|
128
148
|
} else {
|
|
129
149
|
stopRecording(mediaRecorderRef);
|
|
130
150
|
if (pushToTalkState === "transcribing") {
|
|
131
|
-
transcribeAudio(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
151
|
+
transcribeAudio(
|
|
152
|
+
recordedChunks.current,
|
|
153
|
+
context.copilotApiConfig.transcribeAudioUrl!,
|
|
154
|
+
).then(async (transcription) => {
|
|
155
|
+
recordedChunks.current = [];
|
|
156
|
+
setPushToTalkState("idle");
|
|
157
|
+
const message = await sendFunction(transcription);
|
|
158
|
+
setStartReadingFromMessageId(message.id);
|
|
159
|
+
});
|
|
139
160
|
}
|
|
140
161
|
}
|
|
141
162
|
|
|
@@ -156,8 +177,14 @@ export const usePushToTalk = ({
|
|
|
156
177
|
.slice(lastMessageIndex + 1)
|
|
157
178
|
.filter((message) => message.role === "assistant");
|
|
158
179
|
|
|
159
|
-
const text = messagesAfterLast
|
|
160
|
-
|
|
180
|
+
const text = messagesAfterLast
|
|
181
|
+
.map((message) => message.content)
|
|
182
|
+
.join("\n");
|
|
183
|
+
playAudioResponse(
|
|
184
|
+
text,
|
|
185
|
+
context.copilotApiConfig.textToSpeechUrl!,
|
|
186
|
+
audioContextRef.current!,
|
|
187
|
+
);
|
|
161
188
|
|
|
162
189
|
setStartReadingFromMessageId(null);
|
|
163
190
|
}
|
package/src/lib/utils.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export async function fetcher<JSON = any>(
|
|
1
|
+
export async function fetcher<JSON = any>(
|
|
2
|
+
input: RequestInfo,
|
|
3
|
+
init?: RequestInit,
|
|
4
|
+
): Promise<JSON> {
|
|
2
5
|
const res = await fetch(input, init);
|
|
3
6
|
|
|
4
7
|
if (!res.ok) {
|
package/tsconfig.json
CHANGED
package/tsup.config.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { defineConfig, Options } from "tsup";
|
|
2
2
|
|
|
3
3
|
export default defineConfig((options: Options) => ({
|
|
4
|
-
entry: [
|
|
4
|
+
entry: [
|
|
5
|
+
"src/**/*.{ts,tsx}",
|
|
6
|
+
"!src/**/*.test.{ts,tsx}",
|
|
7
|
+
"!src/**/__tests__/**/*",
|
|
8
|
+
],
|
|
5
9
|
format: ["esm", "cjs"],
|
|
6
10
|
dts: true,
|
|
7
11
|
minify: false,
|