@copilotkit/react-ui 1.9.2-next.10 → 1.9.2-next.2
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 +0 -70
- package/dist/{chunk-HC4XNT4D.mjs → chunk-6HXS43LW.mjs} +2 -2
- package/dist/{chunk-CV7HMDQX.mjs → chunk-6JX4WIAX.mjs} +2 -2
- package/dist/{chunk-COWRPULP.mjs → chunk-725PPN77.mjs} +9 -11
- package/dist/chunk-725PPN77.mjs.map +1 -0
- package/dist/{chunk-2CVOR5KS.mjs → chunk-EMIYIMQ6.mjs} +14 -24
- package/dist/chunk-EMIYIMQ6.mjs.map +1 -0
- package/dist/{chunk-HTWRXRTZ.mjs → chunk-GVKA7RQQ.mjs} +2 -2
- package/dist/{chunk-6CM2HBBL.mjs → chunk-RT4HE74K.mjs} +10 -12
- package/dist/chunk-RT4HE74K.mjs.map +1 -0
- package/dist/{chunk-OHLSW5IM.mjs → chunk-SGFUVPDB.mjs} +7 -7
- package/dist/components/chat/Chat.d.ts +1 -2
- package/dist/components/chat/Chat.js +11 -23
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +6 -6
- package/dist/components/chat/Header.mjs +3 -3
- package/dist/components/chat/Input.d.ts +1 -1
- package/dist/components/chat/Input.js +9 -19
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Modal.js +13 -27
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +15 -15
- package/dist/components/chat/Popup.js +13 -27
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +16 -16
- package/dist/components/chat/Sidebar.js +13 -27
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +16 -16
- package/dist/components/chat/index.js +13 -27
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +19 -19
- package/dist/components/chat/props.d.ts +0 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/dev-console/console.mjs +2 -2
- package/dist/components/dev-console/index.mjs +2 -2
- package/dist/components/index.js +13 -27
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +23 -23
- package/dist/index.js +13 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -24
- package/dist/lib/utils.test.d.ts +2 -0
- package/dist/lib/utils.test.js +9 -0
- package/dist/lib/utils.test.js.map +1 -0
- package/dist/lib/utils.test.mjs +7 -0
- package/dist/lib/utils.test.mjs.map +1 -0
- package/package.json +5 -5
- package/src/components/chat/Chat.tsx +0 -4
- package/src/components/chat/Input.tsx +11 -21
- package/src/components/chat/Modal.tsx +3 -6
- package/src/components/chat/props.ts +0 -1
- package/tsup.config.ts +6 -1
- package/dist/chunk-2CVOR5KS.mjs.map +0 -1
- package/dist/chunk-6CM2HBBL.mjs.map +0 -1
- package/dist/chunk-COWRPULP.mjs.map +0 -1
- /package/dist/{chunk-HC4XNT4D.mjs.map → chunk-6HXS43LW.mjs.map} +0 -0
- /package/dist/{chunk-CV7HMDQX.mjs.map → chunk-6JX4WIAX.mjs.map} +0 -0
- /package/dist/{chunk-HTWRXRTZ.mjs.map → chunk-GVKA7RQQ.mjs.map} +0 -0
- /package/dist/{chunk-OHLSW5IM.mjs.map → chunk-SGFUVPDB.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,75 +1,5 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 1.9.2-next.10
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.10
|
|
8
|
-
- @copilotkit/react-core@1.9.2-next.10
|
|
9
|
-
- @copilotkit/shared@1.9.2-next.10
|
|
10
|
-
|
|
11
|
-
## 1.9.2-next.9
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- Updated dependencies [1d1c51d]
|
|
16
|
-
- @copilotkit/react-core@1.9.2-next.9
|
|
17
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.9
|
|
18
|
-
- @copilotkit/shared@1.9.2-next.9
|
|
19
|
-
|
|
20
|
-
## 1.9.2-next.8
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.8
|
|
25
|
-
- @copilotkit/react-core@1.9.2-next.8
|
|
26
|
-
- @copilotkit/shared@1.9.2-next.8
|
|
27
|
-
|
|
28
|
-
## 1.9.2-next.7
|
|
29
|
-
|
|
30
|
-
### Patch Changes
|
|
31
|
-
|
|
32
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.7
|
|
33
|
-
- @copilotkit/react-core@1.9.2-next.7
|
|
34
|
-
- @copilotkit/shared@1.9.2-next.7
|
|
35
|
-
|
|
36
|
-
## 1.9.2-next.6
|
|
37
|
-
|
|
38
|
-
### Patch Changes
|
|
39
|
-
|
|
40
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.6
|
|
41
|
-
- @copilotkit/react-core@1.9.2-next.6
|
|
42
|
-
- @copilotkit/shared@1.9.2-next.6
|
|
43
|
-
|
|
44
|
-
## 1.9.2-next.5
|
|
45
|
-
|
|
46
|
-
### Patch Changes
|
|
47
|
-
|
|
48
|
-
- abe23c3: - feat: enable hiding stop button
|
|
49
|
-
- @copilotkit/react-core@1.9.2-next.5
|
|
50
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.5
|
|
51
|
-
- @copilotkit/shared@1.9.2-next.5
|
|
52
|
-
|
|
53
|
-
## 1.9.2-next.4
|
|
54
|
-
|
|
55
|
-
### Patch Changes
|
|
56
|
-
|
|
57
|
-
- Updated dependencies [9169ad7]
|
|
58
|
-
- Updated dependencies [9169ad7]
|
|
59
|
-
- @copilotkit/react-core@1.9.2-next.4
|
|
60
|
-
- @copilotkit/shared@1.9.2-next.4
|
|
61
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.4
|
|
62
|
-
|
|
63
|
-
## 1.9.2-next.3
|
|
64
|
-
|
|
65
|
-
### Patch Changes
|
|
66
|
-
|
|
67
|
-
- 35537f1: - fix: memoize nested components to not rerender when content changes
|
|
68
|
-
- Updated dependencies [35537f1]
|
|
69
|
-
- @copilotkit/react-core@1.9.2-next.3
|
|
70
|
-
- @copilotkit/runtime-client-gql@1.9.2-next.3
|
|
71
|
-
- @copilotkit/shared@1.9.2-next.3
|
|
72
|
-
|
|
73
3
|
## 1.9.2-next.2
|
|
74
4
|
|
|
75
5
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-725PPN77.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
|
|
|
18
18
|
export {
|
|
19
19
|
CopilotPopup
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-6HXS43LW.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-725PPN77.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
|
|
|
27
27
|
export {
|
|
28
28
|
CopilotSidebar
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-6JX4WIAX.mjs.map
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Window
|
|
3
3
|
} from "./chunk-C3GSYRC3.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Header
|
|
6
|
+
} from "./chunk-GVKA7RQQ.mjs";
|
|
4
7
|
import {
|
|
5
8
|
Button
|
|
6
9
|
} from "./chunk-UFN2VWSR.mjs";
|
|
7
10
|
import {
|
|
8
11
|
CopilotChat
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-RT4HE74K.mjs";
|
|
10
13
|
import {
|
|
11
14
|
AssistantMessage
|
|
12
15
|
} from "./chunk-L3GZ7TXC.mjs";
|
|
@@ -15,13 +18,10 @@ import {
|
|
|
15
18
|
} from "./chunk-HWMFMBJC.mjs";
|
|
16
19
|
import {
|
|
17
20
|
Input
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-EMIYIMQ6.mjs";
|
|
19
22
|
import {
|
|
20
23
|
Messages
|
|
21
24
|
} from "./chunk-B3D7U7TJ.mjs";
|
|
22
|
-
import {
|
|
23
|
-
Header
|
|
24
|
-
} from "./chunk-HTWRXRTZ.mjs";
|
|
25
25
|
import {
|
|
26
26
|
ChatContextProvider
|
|
27
27
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
} from "./chunk-MRXNTQOX.mjs";
|
|
33
33
|
|
|
34
34
|
// src/components/chat/Modal.tsx
|
|
35
|
-
import React
|
|
35
|
+
import React from "react";
|
|
36
36
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
37
37
|
var CopilotModal = (_a) => {
|
|
38
38
|
var _b = _a, {
|
|
@@ -97,10 +97,8 @@ var CopilotModal = (_a) => {
|
|
|
97
97
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
98
98
|
setOpenState(open);
|
|
99
99
|
};
|
|
100
|
-
const memoizedHeader = useMemo(() => /* @__PURE__ */ jsx(Header2, {}), [Header2]);
|
|
101
|
-
const memoizedChildren = useMemo(() => children, [children]);
|
|
102
100
|
return /* @__PURE__ */ jsxs(ChatContextProvider, { icons, labels, open: openState, setOpen, children: [
|
|
103
|
-
|
|
101
|
+
children,
|
|
104
102
|
/* @__PURE__ */ jsxs("div", { className, children: [
|
|
105
103
|
/* @__PURE__ */ jsx(Button2, {}),
|
|
106
104
|
/* @__PURE__ */ jsxs(
|
|
@@ -110,7 +108,7 @@ var CopilotModal = (_a) => {
|
|
|
110
108
|
shortcut,
|
|
111
109
|
hitEscapeToClose,
|
|
112
110
|
children: [
|
|
113
|
-
|
|
111
|
+
/* @__PURE__ */ jsx(Header2, {}),
|
|
114
112
|
/* @__PURE__ */ jsx(
|
|
115
113
|
CopilotChat,
|
|
116
114
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -141,4 +139,4 @@ var CopilotModal = (_a) => {
|
|
|
141
139
|
export {
|
|
142
140
|
CopilotModal
|
|
143
141
|
};
|
|
144
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-725PPN77.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Modal.tsx"],"sourcesContent":["import React from \"react\";\nimport { ChatContextProvider } from \"./ChatContext\";\nimport { ButtonProps, HeaderProps, WindowProps } from \"./props\";\nimport { Window as DefaultWindow } from \"./Window\";\nimport { Button as DefaultButton } from \"./Button\";\nimport { Header as DefaultHeader } from \"./Header\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { CopilotChat, CopilotChatProps } from \"./Chat\";\nimport { AssistantMessage as DefaultAssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage as DefaultUserMessage } from \"./messages/UserMessage\";\n\nexport interface CopilotModalProps extends CopilotChatProps {\n /**\n * Whether the chat window should be open by default.\n * @default false\n */\n defaultOpen?: boolean;\n\n /**\n * If the chat window should close when the user clicks outside of it.\n * @default true\n */\n clickOutsideToClose?: boolean;\n\n /**\n * If the chat window should close when the user hits the Escape key.\n * @default true\n */\n hitEscapeToClose?: boolean;\n\n /**\n * The shortcut key to open the chat window.\n * Uses Command-[shortcut] on a Mac and Ctrl-[shortcut] on Windows.\n * @default '/'\n */\n shortcut?: string;\n\n /**\n * A callback that gets called when the chat window opens or closes.\n */\n onSetOpen?: (open: boolean) => void;\n\n /**\n * A custom Window component to use instead of the default.\n */\n Window?: React.ComponentType<WindowProps>;\n\n /**\n * A custom Button component to use instead of the default.\n */\n Button?: React.ComponentType<ButtonProps>;\n\n /**\n * A custom Header component to use instead of the default.\n */\n Header?: React.ComponentType<HeaderProps>;\n}\n\nexport const CopilotModal = ({\n instructions,\n defaultOpen = false,\n clickOutsideToClose = true,\n hitEscapeToClose = true,\n onSetOpen,\n onSubmitMessage,\n onStopGeneration,\n onReloadMessages,\n shortcut = \"/\",\n icons,\n labels,\n makeSystemMessage,\n onInProgress,\n Window = DefaultWindow,\n Button = DefaultButton,\n Header = DefaultHeader,\n Messages = DefaultMessages,\n Input = DefaultInput,\n AssistantMessage = DefaultAssistantMessage,\n UserMessage = DefaultUserMessage,\n onThumbsUp,\n onThumbsDown,\n onCopy,\n onRegenerate,\n markdownTagRenderers,\n className,\n children,\n ...props\n}: CopilotModalProps) => {\n const [openState, setOpenState] = React.useState(defaultOpen);\n\n const setOpen = (open: boolean) => {\n onSetOpen?.(open);\n setOpenState(open);\n };\n\n return (\n <ChatContextProvider icons={icons} labels={labels} open={openState} setOpen={setOpen}>\n {children}\n <div className={className}>\n <Button></Button>\n <Window\n clickOutsideToClose={clickOutsideToClose}\n shortcut={shortcut}\n hitEscapeToClose={hitEscapeToClose}\n >\n <Header />\n <CopilotChat\n {...props}\n instructions={instructions}\n onSubmitMessage={onSubmitMessage}\n onStopGeneration={onStopGeneration}\n onReloadMessages={onReloadMessages}\n makeSystemMessage={makeSystemMessage}\n onInProgress={onInProgress}\n Messages={Messages}\n Input={Input}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n onCopy={onCopy}\n onRegenerate={onRegenerate}\n markdownTagRenderers={markdownTagRenderers}\n />\n </Window>\n </div>\n </ChatContextProv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,UAEA;AAAA,gCAACE,SAAA,EAAO;AAAA,YACR;AAAA,cAAC;AAAA,+CACK,QADL;AAAA,gBAEC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAUC;AAAA,gBACV,OAAOC;AAAA,gBACP,kBAAkBC;AAAA,gBAClB,aAAaC;AAAA,gBACb;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA;AAAA,YACF;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["Window","Button","Header","Messages","Input","AssistantMessage","UserMessage"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Textarea_default
|
|
3
|
-
} from "./chunk-YQFVRDNC.mjs";
|
|
4
1
|
import {
|
|
5
2
|
PoweredByTag
|
|
6
3
|
} from "./chunk-CGEAG65D.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Textarea_default
|
|
6
|
+
} from "./chunk-YQFVRDNC.mjs";
|
|
7
7
|
import {
|
|
8
8
|
useChatContext
|
|
9
9
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
@@ -12,19 +12,12 @@ import {
|
|
|
12
12
|
} from "./chunk-S5MBUNGN.mjs";
|
|
13
13
|
|
|
14
14
|
// src/components/chat/Input.tsx
|
|
15
|
-
import {
|
|
15
|
+
import { useRef, useState } from "react";
|
|
16
16
|
import { useCopilotContext } from "@copilotkit/react-core";
|
|
17
17
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
18
|
var MAX_NEWLINES = 6;
|
|
19
|
-
var Input = ({
|
|
20
|
-
|
|
21
|
-
onSend,
|
|
22
|
-
isVisible = false,
|
|
23
|
-
onStop,
|
|
24
|
-
onUpload,
|
|
25
|
-
hideStopButton = false
|
|
26
|
-
}) => {
|
|
27
|
-
var _a, _b;
|
|
19
|
+
var Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }) => {
|
|
20
|
+
var _a;
|
|
28
21
|
const context = useChatContext();
|
|
29
22
|
const copilotContext = useCopilotContext();
|
|
30
23
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
@@ -53,18 +46,15 @@ var Input = ({
|
|
|
53
46
|
inProgress
|
|
54
47
|
});
|
|
55
48
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
56
|
-
const buttonIcon = isInProgress
|
|
49
|
+
const buttonIcon = isInProgress ? context.icons.stopIcon : context.icons.sendIcon;
|
|
57
50
|
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
58
|
-
const canSend =
|
|
51
|
+
const canSend = () => {
|
|
59
52
|
var _a2;
|
|
60
53
|
const interruptEvent = (_a2 = copilotContext.langGraphInterruptAction) == null ? void 0 : _a2.event;
|
|
61
54
|
const interruptInProgress = (interruptEvent == null ? void 0 : interruptEvent.name) === "LangGraphInterruptEvent" && !(interruptEvent == null ? void 0 : interruptEvent.response);
|
|
62
|
-
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interruptInProgress;
|
|
63
|
-
}
|
|
64
|
-
const
|
|
65
|
-
return isInProgress && !hideStopButton;
|
|
66
|
-
}, [isInProgress, hideStopButton]);
|
|
67
|
-
const sendDisabled = !canSend && !canStop;
|
|
55
|
+
return (isInProgress || !isInProgress && text.trim().length > 0) && pushToTalkState === "idle" && !interruptInProgress;
|
|
56
|
+
};
|
|
57
|
+
const sendDisabled = !canSend();
|
|
68
58
|
return /* @__PURE__ */ jsxs("div", { className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`, children: [
|
|
69
59
|
/* @__PURE__ */ jsxs("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
70
60
|
/* @__PURE__ */ jsx(
|
|
@@ -79,7 +69,7 @@ var Input = ({
|
|
|
79
69
|
onKeyDown: (event) => {
|
|
80
70
|
if (event.key === "Enter" && !event.shiftKey) {
|
|
81
71
|
event.preventDefault();
|
|
82
|
-
if (canSend) {
|
|
72
|
+
if (canSend()) {
|
|
83
73
|
send();
|
|
84
74
|
}
|
|
85
75
|
}
|
|
@@ -101,7 +91,7 @@ var Input = ({
|
|
|
101
91
|
"button",
|
|
102
92
|
{
|
|
103
93
|
disabled: sendDisabled,
|
|
104
|
-
onClick: isInProgress
|
|
94
|
+
onClick: isInProgress ? onStop : send,
|
|
105
95
|
"data-copilotkit-in-progress": inProgress,
|
|
106
96
|
"data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
|
|
107
97
|
className: "copilotKitInputControlButton",
|
|
@@ -117,4 +107,4 @@ var Input = ({
|
|
|
117
107
|
export {
|
|
118
108
|
Input
|
|
119
109
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-EMIYIMQ6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Input.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { InputProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport AutoResizingTextarea from \"./Textarea\";\nimport { usePushToTalk } from \"../../hooks/use-push-to-talk\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { PoweredByTag } from \"./PoweredByTag\";\n\nconst MAX_NEWLINES = 6;\n\nexport const Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }: InputProps) => {\n const context = useChatContext();\n const copilotContext = useCopilotContext();\n\n const showPoweredBy = !copilotContext.copilotApiConfig?.publicApiKey;\n\n const pushToTalkConfigured =\n copilotContext.copilotApiConfig.textToSpeechUrl !== undefined &&\n copilotContext.copilotApiConfig.transcribeAudioUrl !== undefined;\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const handleDivClick = (event: React.MouseEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n\n // If the user clicked a button or inside a button, don't focus the textarea\n if (target.closest(\"button\")) return;\n\n // If the user clicked the textarea, do nothing (it's already focused)\n if (target.tagName === \"TEXTAREA\") return;\n\n // Otherwise, focus the textarea\n textareaRef.current?.focus();\n };\n\n const [text, setText] = useState(\"\");\n const send = () => {\n if (inProgress) return;\n onSend(text);\n setText(\"\");\n\n textareaRef.current?.focus();\n };\n\n // tylerslaton:\n //\n // This scrolls CopilotKit into view always. Reading the commit history, it was likely\n // added to fix a bug but it is causing issues now.\n //\n // For the future, if we want this behavior again, we will need to find a way to do it without\n // forcing CopilotKit to always be in view. This code causes this because focusing an element\n // in most browsers will scroll that element into view.\n //\n // useEffect(() => {\n // if (isVisible) {\n // textareaRef.current?.focus();\n // }\n // }, [isVisible]);\n\n const { pushToTalkState, setPushToTalkState } = usePushToTalk({\n sendFunction: onSend,\n inProgress,\n });\n\n const isInProgress = inProgress || pushToTalkState === \"transcribing\";\n const buttonIcon = isInProgress ? context.icons.stopIcon : context.icons.sendIcon;\n const showPushToTalk =\n pushToTalkConfigured &&\n (pushToTalkState === \"idle\" || pushToTalkState === \"recording\") &&\n !inProgress;\n\n const canSend = () => {\n const interruptEvent = copilotContext.langGraphInterruptAction?.event;\n const interruptInProgress =\n interruptEvent?.name === \"LangGraphInterruptEvent\" && !interruptEvent?.response;\n\n return (\n (isInProgress || (!isInProgress && text.trim().length > 0)) &&\n pushToTalkState === \"idle\" &&\n !interruptInProgress\n );\n };\n\n const sendDisabled = !canSend();\n\n return (\n <div className={`copilotKitInputContainer ${showPoweredBy ? \"poweredByContainer\" : \"\"}`}>\n <div className=\"copilotKitInput\" onClick={handleDivClick}>\n <AutoResizingTextarea\n ref={textareaRef}\n placeholder={context.labels.placeholder}\n autoFocus={false}\n maxRows={MAX_NEWLINES}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n if (canSend()) {\n send();\n }\n }\n }}\n />\n <div className=\"copilotKitInputControls\">\n {onUpload && (\n <button onClick={onUpload} className=\"copilotKitInputControlButton\">\n {context.icons.uploadIcon}\n </button>\n )}\n\n <div style={{ flexGrow: 1 }} />\n\n {showPushToTalk && (\n <button\n onClick={() =>\n setPushToTalkState(pushToTalkState === \"idle\" ? \"recording\" : \"transcribing\")\n }\n className={\n pushToTalkState === \"recording\"\n ? \"copilotKitInputControlButton copilotKitPushToTalkRecording\"\n : \"copilotKitInputControlButton\"\n }\n >\n {context.icons.pushToTalkIcon}\n </button>\n )}\n <button\n disabled={sendDisabled}\n onClick={isInProgress ? onStop : send}\n data-copilotkit-in-progress={inProgress}\n data-test-id={inProgress ? \"copilot-chat-request-in-progress\" : \"copilot-chat-ready\"}\n className=\"copilotKitInputControlButton\"\n >\n {buttonIcon}\n </button>\n </div>\n </div>\n <PoweredByTag showPoweredBy={showPoweredBy} />\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAgB,QAAQ,gBAAgB;AAKxC,SAAS,yBAAyB;AAmF1B,cAgBA,YAhBA;AAhFR,IAAM,eAAe;AAEd,IAAM,QAAQ,CAAC,EAAE,YAAY,QAAQ,YAAY,OAAO,QAAQ,SAAS,MAAkB;AAVlG;AAWE,QAAM,UAAU,eAAe;AAC/B,QAAM,iBAAiB,kBAAkB;AAEzC,QAAM,gBAAgB,GAAC,oBAAe,qBAAf,mBAAiC;AAExD,QAAM,uBACJ,eAAe,iBAAiB,oBAAoB,UACpD,eAAe,iBAAiB,uBAAuB;AAEzD,QAAM,cAAc,OAA4B,IAAI;AAEpD,QAAM,iBAAiB,CAAC,UAA4C;AAtBtE,QAAAA;AAuBI,UAAM,SAAS,MAAM;AAGrB,QAAI,OAAO,QAAQ,QAAQ;AAAG;AAG9B,QAAI,OAAO,YAAY;AAAY;AAGnC,KAAAA,MAAA,YAAY,YAAZ,gBAAAA,IAAqB;AAAA,EACvB;AAEA,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,EAAE;AACnC,QAAM,OAAO,MAAM;AApCrB,QAAAA;AAq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GF,oBAAC,SAAI,OAAO,EAAE,UAAU,EAAE,GAAG;AAAA,QAE5B,kBACC;AAAA,UAAC;AAAA;AAAA,YACC,SAAS,MACP,mBAAmB,oBAAoB,SAAS,cAAc,cAAc;AAAA,YAE9E,WACE,oBAAoB,cAChB,+DACA;AAAA,YAGL,kBAAQ,MAAM;AAAA;AAAA,QACjB;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACC,UAAU;AAAA,YACV,SAAS,eAAe,SAAS;AAAA,YACjC,+BAA6B;AAAA,YAC7B,gBAAc,aAAa,qCAAqC;AAAA,YAChE,WAAU;AAAA,YAET;AAAA;AAAA,QACH;AAAA,SACF;AAAA,OACF;AAAA,IACA,oBAAC,gBAAa,eAA8B;AAAA,KAC9C;AAEJ;","names":["_a"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotDevConsole
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SGFUVPDB.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useChatContext
|
|
6
6
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
@@ -29,4 +29,4 @@ var Header = ({}) => {
|
|
|
29
29
|
export {
|
|
30
30
|
Header
|
|
31
31
|
};
|
|
32
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-GVKA7RQQ.mjs.map
|
|
@@ -22,22 +22,22 @@ import {
|
|
|
22
22
|
import {
|
|
23
23
|
Suggestions
|
|
24
24
|
} from "./chunk-QGSPTXOV.mjs";
|
|
25
|
+
import {
|
|
26
|
+
reloadSuggestions
|
|
27
|
+
} from "./chunk-IMBPSLL4.mjs";
|
|
28
|
+
import {
|
|
29
|
+
ImageUploadQueue
|
|
30
|
+
} from "./chunk-PLHTVHUW.mjs";
|
|
25
31
|
import {
|
|
26
32
|
Input
|
|
27
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-EMIYIMQ6.mjs";
|
|
28
34
|
import {
|
|
29
35
|
Messages
|
|
30
36
|
} from "./chunk-B3D7U7TJ.mjs";
|
|
31
|
-
import {
|
|
32
|
-
reloadSuggestions
|
|
33
|
-
} from "./chunk-IMBPSLL4.mjs";
|
|
34
37
|
import {
|
|
35
38
|
ChatContext,
|
|
36
39
|
ChatContextProvider
|
|
37
40
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
38
|
-
import {
|
|
39
|
-
ImageUploadQueue
|
|
40
|
-
} from "./chunk-PLHTVHUW.mjs";
|
|
41
41
|
import {
|
|
42
42
|
__async,
|
|
43
43
|
__spreadProps,
|
|
@@ -81,8 +81,7 @@ function CopilotChat({
|
|
|
81
81
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
82
82
|
UserMessage: UserMessage2 = UserMessage,
|
|
83
83
|
imageUploadsEnabled,
|
|
84
|
-
inputFileAccept = "image/*"
|
|
85
|
-
hideStopButton
|
|
84
|
+
inputFileAccept = "image/*"
|
|
86
85
|
}) {
|
|
87
86
|
const { additionalInstructions, setChatInstructions } = useCopilotContext();
|
|
88
87
|
const [selectedImages, setSelectedImages] = useState([]);
|
|
@@ -265,8 +264,7 @@ function CopilotChat({
|
|
|
265
264
|
onUpload: imageUploadsEnabled ? () => {
|
|
266
265
|
var _a;
|
|
267
266
|
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
268
|
-
} : void 0
|
|
269
|
-
hideStopButton
|
|
267
|
+
} : void 0
|
|
270
268
|
}
|
|
271
269
|
)
|
|
272
270
|
] });
|
|
@@ -471,4 +469,4 @@ export {
|
|
|
471
469
|
WrappedCopilotChat,
|
|
472
470
|
useCopilotChatLogic
|
|
473
471
|
};
|
|
474
|
-
//# sourceMappingURL=chunk-
|
|
472
|
+
//# sourceMappingURL=chunk-RT4HE74K.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Chat.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"/images/CopilotChat.gif\" width=\"500\" />\n *\n * A chatbot panel component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * ## Install Dependencies\n *\n * This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.\n *\n * ```shell npm2yarn \\\"@copilotkit/react-ui\"\\\n * npm install @copilotkit/react-core @copilotkit/react-ui\n * ```\n *\n * ## Usage\n *\n * ```tsx\n * import { CopilotChat } from \"@copilotkit/react-ui\";\n * import \"@copilotkit/react-ui/styles.css\";\n *\n * <CopilotChat\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n *\n * ### Look & Feel\n *\n * By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:\n * ```tsx title=\"YourRootComponent.tsx\"\n * ...\n * import \"@copilotkit/react-ui/styles.css\"; // [!code highlight]\n *\n * export function YourRootComponent() {\n * return (\n * <CopilotKit>\n * ...\n * </CopilotKit>\n * );\n * }\n * ```\n * For more information about how to customize the styles, check out the [Customize Look & Feel](/guides/custom-look-and-feel/customize-built-in-ui-components) guide.\n */\n\nimport {\n ChatContext,\n ChatContextProvider,\n CopilotChatIcons,\n CopilotChatLabels,\n} from \"./ChatContext\";\nimport { Messages as DefaultMessages } from \"./Messages\";\nimport { Input as DefaultInput } from \"./Input\";\nimport { RenderTextMessage as DefaultRenderTextMessage } from \"./messages/RenderTextMessage\";\nimport { RenderActionExecutionMessage as DefaultRenderActionExecutionMessage } from \"./messages/RenderActionExecutionMessage\";\nimport { RenderResultMessage as DefaultRenderResultMessage } from \"./messages/RenderResultMessage\";\nimport { RenderAgentStateMessage as DefaultRenderAgentStateMessage } from \"./messages/RenderAgentStateMessage\";\nimport { RenderImageMessage as DefaultRenderImageMessage } from \"./messages/RenderImageMessage\";\nimport { AssistantMessage as DefaultAssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage as DefaultUserMessage } from \"./messages/UserMessage\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport {\n SystemMessageFunction,\n useCopilotChat,\n useCopilotContext,\n useCopilotMessagesContext,\n} from \"@copilotkit/react-core\";\nimport { reloadSuggestions } from \"./Suggestion\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { Message, Role, TextMessage, ImageMessage } from \"@copilotkit/runtime-client-gql\";\nimport { randomId } from \"@copilotkit/shared\";\nimport {\n AssistantMessageProps,\n ComponentsMap,\n InputProps,\n MessagesProps,\n RenderMessageProps,\n RenderSuggestionsListProps,\n UserMessageProps,\n} from \"./props\";\n\nimport { HintFunction, runAgent, stopAgent } from \"@copilotkit/react-core\";\nimport { ImageUploadQueue } from \"./ImageUploadQueue\";\nimport { Suggestions as DefaultRenderSuggestionsList } from \"./Suggestions\";\n\n/**\n * Props for CopilotChat component.\n */\nexport interface CopilotChatProps {\n /**\n * Custom instructions to be added to the system message. Use this property to\n * provide additional context or guidance to the language model, influencing\n * its responses. These instructions can include specific directions,\n * preferences, or criteria that the model should consider when generating\n * its output, thereby tailoring the conversation more precisely to the\n * user's needs or the application's requirements.\n */\n instructions?: string;\n\n /**\n * A callback that gets called when the in progress state changes.\n */\n onInProgress?: (inProgress: boolean) => void;\n\n /**\n * A callback that gets called when a new message it submitted.\n */\n onSubmitMessage?: (message: string) => void | Promise<void>;\n\n /**\n * A custom stop generation function.\n */\n onStopGeneration?: OnStopGeneration;\n\n /**\n * A custom reload messages function.\n */\n onReloadMessages?: OnReloadMessages;\n\n /**\n * A callback function to regenerate the assistant's response\n */\n onRegenerate?: (messageId: string) => void;\n\n /**\n * A callback function when the message is copied\n */\n onCopy?: (message: string) => void;\n\n /**\n * A callback function for thumbs up feedback\n */\n onThumbsUp?: (message: TextMessage) => void;\n\n /**\n * A callback function for thumbs down feedback\n */\n onThumbsDown?: (message: TextMessage) => void;\n\n /**\n * A list of markdown components to render in assistant message.\n * Useful when you want to render custom elements in the message (e.g a reference tag element)\n */\n markdownTagRenderers?: ComponentsMap;\n\n /**\n * Icons can be used to set custom icons for the chat window.\n */\n icons?: CopilotChatIcons;\n\n /**\n * Labels can be used to set custom labels for the chat window.\n */\n labels?: CopilotChatLabels;\n\n /**\n * Enable image upload button (image inputs only supported on some models)\n */\n imageUploadsEnabled?: boolean;\n\n /**\n * The 'accept' attribute for the file input used for image uploads.\n * Defaults to \"image/*\".\n */\n inputFileAccept?: string;\n\n /**\n * A function that takes in context string and instructions and returns\n * the system message to include in the chat request.\n * Use this to completely override the system message, when providing\n * instructions is not enough.\n */\n makeSystemMessage?: SystemMessageFunction;\n\n /**\n * A custom assistant message component to use instead of the default.\n */\n AssistantMessage?: React.ComponentType<AssistantMessageProps>;\n\n /**\n * A custom user message component to use instead of the default.\n */\n UserMessage?: React.ComponentType<UserMessageProps>;\n\n /**\n * A custom Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\n\n /**\n * A custom RenderTextMessage component to use instead of the default.\n */\n RenderTextMessage?: React.ComponentType<RenderMessageProps>;\n\n /**\n * A custom RenderActionExecutionMessage component to use instead of the default.\n */\n RenderActionExecutionMessage?: React.ComponentType<RenderMessageProps>;\n\n /**\n * A custom RenderAgentStateMessage component to use instead of the default.\n */\n RenderAgentStateMessage?: React.ComponentType<RenderMessageProps>;\n\n /**\n * A custom RenderResultMessage component to use instead of the default.\n */\n RenderResultMessage?: React.ComponentType<RenderMessageProps>;\n\n /**\n * A custom RenderImageMessage component to use instead of the default.\n */\n RenderImageMessage?: React.ComponentType<RenderMessageProps>;\n\n /**\n * A custom suggestions list component to use instead of the default.\n */\n RenderSuggestionsList?: React.ComponentType<RenderSuggestionsListProps>;\n\n /**\n * A custom Input component to use instead of the default.\n */\n Input?: React.ComponentType<InputProps>;\n\n /**\n * A class name to apply to the root element.\n */\n className?: string;\n\n /**\n * Children to render.\n */\n children?: React.ReactNode;\n}\n\ninterface OnStopGenerationArguments {\n /**\n * The name of the currently executing agent.\n */\n currentAgentName: string | undefined;\n\n /**\n * The messages in the chat.\n */\n messages: Message[];\n\n /**\n * Set the messages in the chat.\n */\n setMessages: (messages: Message[]) => void;\n\n /**\n * Stop chat generation.\n */\n stopGeneration: () => void;\n\n /**\n * Restart the currently executing agent.\n */\n restartCurrentAgent: () => void;\n\n /**\n * Stop the currently executing agent.\n */\n stopCurrentAgent: () => void;\n\n /**\n * Run the currently executing agent.\n */\n runCurrentAgent: (hint?: HintFunction) => Promise<void>;\n\n /**\n * Set the state of the currently executing agent.\n */\n setCurrentAgentState: (state: any) => void;\n}\n\nexport type OnReloadMessagesArguments = OnStopGenerationArguments & {\n /**\n * The message on which \"regenerate\" was pressed\n */\n messageId: string;\n};\n\nexport type OnStopGeneration = (args: OnStopGenerationArguments) => void;\n\nexport type OnReloadMessages = (args: OnReloadMessagesArguments) => void;\n\nexport type ImageUpload = {\n contentType: string;\n bytes: string;\n};\n\nexport function CopilotChat({\n instructions,\n onSubmitMessage,\n makeSystemMessage,\n onInProgress,\n onStopGeneration,\n onReloadMessages,\n onRegenerate,\n onCopy,\n onThumbsUp,\n onThumbsDown,\n markdownTagRenderers,\n Messages = DefaultMessages,\n RenderTextMessage = DefaultRenderTextMessage,\n RenderActionExecutionMessage = DefaultRenderActionExecutionMessage,\n RenderAgentStateMessage = DefaultRenderAgentStateMessage,\n RenderResultMessage = DefaultRenderResultMessage,\n RenderImageMessage = DefaultRenderImageMessage,\n RenderSuggestionsList = DefaultRenderSuggestionsList,\n Input = DefaultInput,\n className,\n icons,\n labels,\n AssistantMessage = DefaultAssistantMessage,\n UserMessage = DefaultUserMessage,\n imageUploadsEnabled,\n inputFileAccept = \"image/*\",\n}: CopilotChatProps) {\n const { additionalInstructions, setChatInstructions } = useCopilotContext();\n const [selectedImages, setSelectedImages] = useState<Array<ImageUpload>>([]);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n // Clipboard paste handler\n useEffect(() => {\n if (!imageUploadsEnabled) return;\n\n const handlePaste = async (e: ClipboardEvent) => {\n const target = e.target as HTMLElement;\n if (!target.parentElement?.classList.contains(\"copilotKitInput\")) return;\n\n const items = Array.from(e.clipboardData?.items || []);\n const imageItems = items.filter((item) => item.type.startsWith(\"image/\"));\n\n if (imageItems.length === 0) return;\n\n e.preventDefault(); // Prevent default paste behavior for images\n\n const imagePromises: Promise<ImageUpload | null>[] = imageItems.map((item) => {\n const file = item.getAsFile();\n if (!file) return Promise.resolve(null);\n\n return new Promise<ImageUpload | null>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const base64String = (e.target?.result as string)?.split(\",\")[1];\n if (base64String) {\n resolve({\n contentType: file.type,\n bytes: base64String,\n });\n } else {\n resolve(null);\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n });\n\n try {\n const loadedImages = (await Promise.all(imagePromises)).filter((img) => img !== null);\n setSelectedImages((prev) => [...prev, ...loadedImages]);\n } catch (error) {\n // TODO: Show an error message to the user\n console.error(\"Error processing pasted images:\", error);\n }\n };\n\n document.addEventListener(\"paste\", handlePaste);\n return () => document.removeEventListener(\"paste\", handlePaste);\n }, [imageUploadsEnabled]);\n\n useEffect(() => {\n if (!additionalInstructions?.length) {\n setChatInstructions(instructions || \"\");\n return;\n }\n\n /*\n Will result in a prompt like:\n\n You are a helpful assistant. \n Additionally, follow these instructions:\n - Do not answer questions about the weather.\n - Do not answer questions about the stock market.\"\n */\n const combinedAdditionalInstructions = [\n instructions,\n \"Additionally, follow these instructions:\",\n ...additionalInstructions.map((instruction) => `- ${instruction}`),\n ];\n\n console.log(\"combinedAdditionalInstructions\", combinedAdditionalInstructions);\n\n setChatInstructions(combinedAdditionalInstructions.join(\"\\n\") || \"\");\n }, [instructions, additionalInstructions]);\n\n const {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n } = useCopilotChatLogic(\n makeSystemMessage,\n onInProgress,\n onSubmitMessage,\n onStopGeneration,\n onReloadMessages,\n );\n\n // Wrapper for sendMessage to clear selected images\n const handleSendMessage = (text: string) => {\n const images = selectedImages;\n setSelectedImages([]);\n if (fileInputRef.current) {\n fileInputRef.current.value = \"\";\n }\n\n return sendMessage(text, images);\n };\n\n const chatContext = React.useContext(ChatContext);\n const isVisible = chatContext ? chatContext.open : true;\n\n const handleRegenerate = (messageId: string) => {\n if (onRegenerate) {\n onRegenerate(messageId);\n }\n\n reloadMessages(messageId);\n };\n\n const handleCopy = (message: string) => {\n if (onCopy) {\n onCopy(message);\n }\n };\n\n const handleImageUpload = async (event: React.ChangeEvent<HTMLInputElement>) => {\n if (!event.target.files || event.target.files.length === 0) {\n return;\n }\n\n const files = Array.from(event.target.files).filter((file) => file.type.startsWith(\"image/\"));\n if (files.length === 0) return;\n\n const fileReadPromises = files.map((file) => {\n return new Promise<{ contentType: string; bytes: string }>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = (e) => {\n const base64String = (e.target?.result as string)?.split(\",\")[1] || \"\";\n if (base64String) {\n resolve({\n contentType: file.type,\n bytes: base64String,\n });\n }\n };\n reader.onerror = reject;\n reader.readAsDataURL(file);\n });\n });\n\n try {\n const loadedImages = await Promise.all(fileReadPromises);\n setSelectedImages((prev) => [...prev, ...loadedImages]);\n } catch (error) {\n // TODO: Show an error message to the user\n console.error(\"Error reading files:\", error);\n }\n };\n\n const removeSelectedImage = (index: number) => {\n setSelectedImages((prev) => prev.filter((_, i) => i !== index));\n };\n\n return (\n <WrappedCopilotChat icons={icons} labels={labels} className={className}>\n <Messages\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n RenderTextMessage={RenderTextMessage}\n RenderActionExecutionMessage={RenderActionExecutionMessage}\n RenderAgentStateMessage={RenderAgentStateMessage}\n RenderResultMessage={RenderResultMessage}\n RenderImageMessage={RenderImageMessage}\n messages={visibleMessages}\n inProgress={isLoading}\n onRegenerate={handleRegenerate}\n onCopy={handleCopy}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n markdownTagRenderers={markdownTagRenderers}\n >\n {currentSuggestions.length > 0 && (\n <RenderSuggestionsList\n onSuggestionClick={handleSendMessage}\n suggestions={currentSuggestions}\n />\n )}\n </Messages>\n\n {imageUploadsEnabled && (\n <>\n <ImageUploadQueue images={selectedImages} onRemoveImage={removeSelectedImage} />\n <input\n type=\"file\"\n multiple\n ref={fileInputRef}\n onChange={handleImageUpload}\n accept={inputFileAccept}\n style={{ display: \"none\" }}\n />\n </>\n )}\n\n <Input\n inProgress={isLoading}\n onSend={handleSendMessage}\n isVisible={isVisible}\n onStop={stopGeneration}\n onUpload={imageUploadsEnabled ? () => fileInputRef.current?.click() : undefined}\n />\n </WrappedCopilotChat>\n );\n}\n\nexport function WrappedCopilotChat({\n children,\n icons,\n labels,\n className,\n}: {\n children: React.ReactNode;\n icons?: CopilotChatIcons;\n labels?: CopilotChatLabels;\n className?: string;\n}) {\n const chatContext = React.useContext(ChatContext);\n if (!chatContext) {\n return (\n <ChatContextProvider icons={icons} labels={labels} open={true} setOpen={() => {}}>\n <div className={`copilotKitChat ${className ?? \"\"}`}>{children}</div>\n </ChatContextProvider>\n );\n }\n return <>{children}</>;\n}\n\nconst SUGGESTIONS_DEBOUNCE_TIMEOUT = 1000;\n\nexport const useCopilotChatLogic = (\n makeSystemMessage?: SystemMessageFunction,\n onInProgress?: (isLoading: boolean) => void,\n onSubmitMessage?: (messageContent: string) => Promise<void> | void,\n onStopGeneration?: OnStopGeneration,\n onReloadMessages?: OnReloadMessages,\n) => {\n const {\n visibleMessages,\n appendMessage,\n reloadMessages: defaultReloadMessages,\n stopGeneration: defaultStopGeneration,\n runChatCompletion,\n isLoading,\n } = useCopilotChat({\n id: randomId(),\n makeSystemMessage,\n });\n\n const [currentSuggestions, setCurrentSuggestions] = useState<CopilotChatSuggestion[]>([]);\n const suggestionsAbortControllerRef = useRef<AbortController | null>(null);\n const debounceTimerRef = useRef<any>();\n\n const abortSuggestions = () => {\n suggestionsAbortControllerRef.current?.abort();\n suggestionsAbortControllerRef.current = null;\n };\n\n const generalContext = useCopilotContext();\n const messagesContext = useCopilotMessagesContext();\n const context = { ...generalContext, ...messagesContext };\n\n useEffect(() => {\n onInProgress?.(isLoading);\n\n abortSuggestions();\n\n debounceTimerRef.current = setTimeout(\n () => {\n if (!isLoading && Object.keys(context.chatSuggestionConfiguration).length !== 0) {\n suggestionsAbortControllerRef.current = new AbortController();\n reloadSuggestions(\n context,\n context.chatSuggestionConfiguration,\n setCurrentSuggestions,\n suggestionsAbortControllerRef,\n );\n }\n },\n currentSuggestions.length == 0 ? 0 : SUGGESTIONS_DEBOUNCE_TIMEOUT,\n );\n\n return () => {\n clearTimeout(debounceTimerRef.current);\n };\n }, [\n isLoading,\n context.chatSuggestionConfiguration,\n // hackish way to trigger suggestions reload on reset, but better than moving suggestions to the\n // global context\n visibleMessages.length == 0,\n ]);\n\n const sendMessage = async (\n messageContent: string,\n imagesToUse?: Array<{ contentType: string; bytes: string }>,\n ) => {\n // Use images passed in the call OR the ones from the state (passed via props)\n const images = imagesToUse || [];\n\n abortSuggestions();\n setCurrentSuggestions([]);\n\n let firstMessage: Message | null = null;\n\n // If there's text content, send a text message first\n if (messageContent.trim().length > 0) {\n const textMessage = new TextMessage({\n content: messageContent,\n role: Role.User,\n });\n\n if (onSubmitMessage) {\n try {\n // Call onSubmitMessage only with text, as image handling is internal right now\n await onSubmitMessage(messageContent);\n } catch (error) {\n console.error(\"Error in onSubmitMessage:\", error);\n }\n }\n\n await appendMessage(textMessage, { followUp: images.length === 0 });\n\n if (!firstMessage) {\n firstMessage = textMessage;\n }\n }\n\n // Send image messages\n if (images.length > 0) {\n for (let i = 0; i < images.length; i++) {\n const imageMessage = new ImageMessage({\n format: images[i].contentType.replace(\"image/\", \"\"),\n bytes: images[i].bytes,\n role: Role.User,\n });\n await appendMessage(imageMessage, { followUp: i === images.length - 1 });\n if (!firstMessage) {\n firstMessage = imageMessage;\n }\n }\n }\n\n if (!firstMessage) {\n // Should not happen if send button is properly disabled, but handle just in case\n return new TextMessage({ content: \"\", role: Role.User }); // Return a dummy message\n }\n\n // The hook implicitly triggers API call on appendMessage.\n // We return the first message sent (either text or first image)\n return firstMessage;\n };\n\n const messages = visibleMessages;\n const { setMessages } = messagesContext;\n const currentAgentName = generalContext.agentSession?.agentName;\n const restartCurrentAgent = async (hint?: HintFunction) => {\n if (generalContext.agentSession) {\n generalContext.setAgentSession({\n ...generalContext.agentSession,\n nodeName: undefined,\n threadId: undefined,\n });\n generalContext.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [generalContext.agentSession!.agentName]: {\n ...prevAgentStates[generalContext.agentSession!.agentName],\n threadId: undefined,\n nodeName: undefined,\n runId: undefined,\n },\n };\n });\n }\n };\n const runCurrentAgent = async (hint?: HintFunction) => {\n if (generalContext.agentSession) {\n await runAgent(\n generalContext.agentSession.agentName,\n context,\n appendMessage,\n runChatCompletion,\n hint,\n );\n }\n };\n const stopCurrentAgent = () => {\n if (generalContext.agentSession) {\n stopAgent(generalContext.agentSession.agentName, context);\n }\n };\n const setCurrentAgentState = (state: any) => {\n if (generalContext.agentSession) {\n generalContext.setCoagentStates((prevAgentStates) => {\n return {\n ...prevAgentStates,\n [generalContext.agentSession!.agentName]: {\n state,\n },\n } as any;\n });\n }\n };\n\n function stopGeneration() {\n if (onStopGeneration) {\n onStopGeneration({\n messages,\n setMessages,\n stopGeneration: defaultStopGeneration,\n currentAgentName,\n restartCurrentAgent,\n stopCurrentAgent,\n runCurrentAgent,\n setCurrentAgentState,\n });\n } else {\n defaultStopGeneration();\n }\n }\n function reloadMessages(messageId: string) {\n if (onReloadMessages) {\n onReloadMessages({\n messages,\n setMessages,\n stopGeneration: defaultStopGeneration,\n currentAgentName,\n restartCurrentAgent,\n stopCurrentAgent,\n runCurrentAgent,\n setCurrentAgentState,\n messageId,\n });\n } else {\n defaultReloadMessages(messageId);\n }\n }\n\n return {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,4BAAsB;AAAA,IACxB;AAAA,EACF;AACA,WAAS,eAAe,WAAmB;AACzC,QAAI,kBAAkB;AACpB,uBAAiB;AAAA,QACf;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,4BAAsB,SAAS;AAAA,IACjC;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["Messages","RenderTextMessage","RenderActionExecutionMessage","RenderAgentStateMessage","RenderResultMessage","RenderImageMessage","Input","AssistantMessage","UserMessage","e","_a","_b"]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CheckIcon,
|
|
3
|
+
ChevronDownIcon,
|
|
4
|
+
ExclamationMarkIcon,
|
|
5
|
+
ExclamationMarkTriangleIcon
|
|
6
|
+
} from "./chunk-Q5V6S67N.mjs";
|
|
1
7
|
import {
|
|
2
8
|
getPublishedCopilotKitVersion,
|
|
3
9
|
logActions,
|
|
@@ -8,12 +14,6 @@ import {
|
|
|
8
14
|
import {
|
|
9
15
|
CopilotKitHelpModal
|
|
10
16
|
} from "./chunk-NRA3CFEE.mjs";
|
|
11
|
-
import {
|
|
12
|
-
CheckIcon,
|
|
13
|
-
ChevronDownIcon,
|
|
14
|
-
ExclamationMarkIcon,
|
|
15
|
-
ExclamationMarkTriangleIcon
|
|
16
|
-
} from "./chunk-Q5V6S67N.mjs";
|
|
17
17
|
import {
|
|
18
18
|
SmallSpinnerIcon
|
|
19
19
|
} from "./chunk-XWG3L6QC.mjs";
|
|
@@ -199,4 +199,4 @@ export {
|
|
|
199
199
|
CopilotDevConsole,
|
|
200
200
|
DebugMenuButton
|
|
201
201
|
};
|
|
202
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-SGFUVPDB.mjs.map
|
|
@@ -128,7 +128,6 @@ interface CopilotChatProps {
|
|
|
128
128
|
* Children to render.
|
|
129
129
|
*/
|
|
130
130
|
children?: React__default.ReactNode;
|
|
131
|
-
hideStopButton?: boolean;
|
|
132
131
|
}
|
|
133
132
|
interface OnStopGenerationArguments {
|
|
134
133
|
/**
|
|
@@ -176,7 +175,7 @@ type ImageUpload = {
|
|
|
176
175
|
contentType: string;
|
|
177
176
|
bytes: string;
|
|
178
177
|
};
|
|
179
|
-
declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, onInProgress, onStopGeneration, onReloadMessages, onRegenerate, onCopy, onThumbsUp, onThumbsDown, markdownTagRenderers, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, RenderImageMessage, RenderSuggestionsList, Input, className, icons, labels, AssistantMessage, UserMessage, imageUploadsEnabled, inputFileAccept,
|
|
178
|
+
declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, onInProgress, onStopGeneration, onReloadMessages, onRegenerate, onCopy, onThumbsUp, onThumbsDown, markdownTagRenderers, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, RenderImageMessage, RenderSuggestionsList, Input, className, icons, labels, AssistantMessage, UserMessage, imageUploadsEnabled, inputFileAccept, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
180
179
|
declare function WrappedCopilotChat({ children, icons, labels, className, }: {
|
|
181
180
|
children: React__default.ReactNode;
|
|
182
181
|
icons?: CopilotChatIcons;
|
|
@@ -784,15 +784,8 @@ function PoweredByTag({ showPoweredBy = true }) {
|
|
|
784
784
|
// src/components/chat/Input.tsx
|
|
785
785
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
786
786
|
var MAX_NEWLINES = 6;
|
|
787
|
-
var Input = ({
|
|
788
|
-
|
|
789
|
-
onSend,
|
|
790
|
-
isVisible = false,
|
|
791
|
-
onStop,
|
|
792
|
-
onUpload,
|
|
793
|
-
hideStopButton = false
|
|
794
|
-
}) => {
|
|
795
|
-
var _a, _b;
|
|
787
|
+
var Input = ({ inProgress, onSend, isVisible = false, onStop, onUpload }) => {
|
|
788
|
+
var _a;
|
|
796
789
|
const context = useChatContext();
|
|
797
790
|
const copilotContext = (0, import_react_core3.useCopilotContext)();
|
|
798
791
|
const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
|
|
@@ -821,18 +814,15 @@ var Input = ({
|
|
|
821
814
|
inProgress
|
|
822
815
|
});
|
|
823
816
|
const isInProgress = inProgress || pushToTalkState === "transcribing";
|
|
824
|
-
const buttonIcon = isInProgress
|
|
817
|
+
const buttonIcon = isInProgress ? context.icons.stopIcon : context.icons.sendIcon;
|
|
825
818
|
const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
|
|
826
|
-
const canSend = (
|
|
819
|
+
const canSend = () => {
|
|
827
820
|
var _a2;
|
|
828
821
|
const interruptEvent = (_a2 = copilotContext.langGraphInterruptAction) == null ? void 0 : _a2.event;
|
|
829
822
|
const interruptInProgress = (interruptEvent == null ? void 0 : interruptEvent.name) === "LangGraphInterruptEvent" && !(interruptEvent == null ? void 0 : interruptEvent.response);
|
|
830
|
-
return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interruptInProgress;
|
|
831
|
-
}
|
|
832
|
-
const
|
|
833
|
-
return isInProgress && !hideStopButton;
|
|
834
|
-
}, [isInProgress, hideStopButton]);
|
|
835
|
-
const sendDisabled = !canSend && !canStop;
|
|
823
|
+
return (isInProgress || !isInProgress && text.trim().length > 0) && pushToTalkState === "idle" && !interruptInProgress;
|
|
824
|
+
};
|
|
825
|
+
const sendDisabled = !canSend();
|
|
836
826
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`, children: [
|
|
837
827
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
|
|
838
828
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -847,7 +837,7 @@ var Input = ({
|
|
|
847
837
|
onKeyDown: (event) => {
|
|
848
838
|
if (event.key === "Enter" && !event.shiftKey) {
|
|
849
839
|
event.preventDefault();
|
|
850
|
-
if (canSend) {
|
|
840
|
+
if (canSend()) {
|
|
851
841
|
send();
|
|
852
842
|
}
|
|
853
843
|
}
|
|
@@ -869,7 +859,7 @@ var Input = ({
|
|
|
869
859
|
"button",
|
|
870
860
|
{
|
|
871
861
|
disabled: sendDisabled,
|
|
872
|
-
onClick: isInProgress
|
|
862
|
+
onClick: isInProgress ? onStop : send,
|
|
873
863
|
"data-copilotkit-in-progress": inProgress,
|
|
874
864
|
"data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
|
|
875
865
|
className: "copilotKitInputControlButton",
|
|
@@ -2075,8 +2065,7 @@ function CopilotChat({
|
|
|
2075
2065
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
2076
2066
|
UserMessage: UserMessage2 = UserMessage,
|
|
2077
2067
|
imageUploadsEnabled,
|
|
2078
|
-
inputFileAccept = "image/*"
|
|
2079
|
-
hideStopButton
|
|
2068
|
+
inputFileAccept = "image/*"
|
|
2080
2069
|
}) {
|
|
2081
2070
|
const { additionalInstructions, setChatInstructions } = (0, import_react_core7.useCopilotContext)();
|
|
2082
2071
|
const [selectedImages, setSelectedImages] = (0, import_react9.useState)([]);
|
|
@@ -2259,8 +2248,7 @@ function CopilotChat({
|
|
|
2259
2248
|
onUpload: imageUploadsEnabled ? () => {
|
|
2260
2249
|
var _a;
|
|
2261
2250
|
return (_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
2262
|
-
} : void 0
|
|
2263
|
-
hideStopButton
|
|
2251
|
+
} : void 0
|
|
2264
2252
|
}
|
|
2265
2253
|
)
|
|
2266
2254
|
] });
|