@copilotkit/react-ui 1.8.0-next.5 → 1.8.0-next.7
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 +18 -0
- package/dist/{chunk-FBYETUFL.mjs → chunk-5M7ODWKH.mjs} +6 -12
- package/dist/chunk-5M7ODWKH.mjs.map +1 -0
- package/dist/{chunk-DFHFPZQD.mjs → chunk-EMWOZVCW.mjs} +9 -16
- package/dist/chunk-EMWOZVCW.mjs.map +1 -0
- package/dist/{chunk-Z6YOBQUJ.mjs → chunk-HGA4N4ME.mjs} +8 -13
- package/dist/chunk-HGA4N4ME.mjs.map +1 -0
- package/dist/{chunk-CGVOCLHN.mjs → chunk-P7S3E5UW.mjs} +2 -2
- package/dist/{chunk-6H7IQRIU.mjs → chunk-QTN7AYVL.mjs} +2 -2
- package/dist/{chunk-LYHZXHTJ.mjs → chunk-SNLHKLW3.mjs} +2 -2
- package/dist/{chunk-5JY5QJ2W.mjs → chunk-UN2E3HCK.mjs} +9 -3
- package/dist/chunk-UN2E3HCK.mjs.map +1 -0
- package/dist/{chunk-FFNESJSG.mjs → chunk-Y6OESC5U.mjs} +2 -2
- package/dist/{chunk-QS7UFQFD.mjs → chunk-YGD4IB27.mjs} +2 -2
- package/dist/{chunk-VC4NO5QZ.mjs → chunk-YOEL33HG.mjs} +2 -2
- package/dist/{chunk-GJME6MK4.mjs → chunk-ZY25LVYR.mjs} +2 -2
- package/dist/components/chat/Button.js.map +1 -1
- package/dist/components/chat/Button.mjs +2 -2
- package/dist/components/chat/Chat.d.ts +2 -11
- package/dist/components/chat/Chat.js +67 -76
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +6 -7
- package/dist/components/chat/ChatContext.d.ts +15 -0
- package/dist/components/chat/ChatContext.js +67 -1
- package/dist/components/chat/ChatContext.js.map +1 -1
- package/dist/components/chat/ChatContext.mjs +1 -1
- package/dist/components/chat/Header.js.map +1 -1
- package/dist/components/chat/Header.mjs +2 -2
- package/dist/components/chat/Input.js.map +1 -1
- package/dist/components/chat/Input.mjs +2 -2
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +2 -2
- package/dist/components/chat/Modal.d.ts +1 -1
- package/dist/components/chat/Modal.js +74 -87
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +10 -11
- package/dist/components/chat/Popup.js +76 -89
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +11 -12
- package/dist/components/chat/Sidebar.js +76 -89
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +11 -12
- package/dist/components/chat/Window.js.map +1 -1
- package/dist/components/chat/Window.mjs +2 -2
- package/dist/components/chat/index.d.ts +1 -1
- package/dist/components/chat/index.js +78 -91
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +14 -15
- package/dist/components/chat/messages/AssistantMessage.js +4 -67
- package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
- package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
- package/dist/components/chat/props.d.ts +1 -5
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +78 -91
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +14 -15
- package/dist/index.css +0 -26
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +78 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -15
- package/package.json +4 -4
- package/src/components/chat/Chat.tsx +0 -16
- package/src/components/chat/ChatContext.tsx +25 -0
- package/src/components/chat/Modal.tsx +0 -6
- package/src/components/chat/messages/AssistantMessage.tsx +4 -5
- package/src/components/chat/props.ts +0 -5
- package/src/styles.css +0 -1
- package/dist/chunk-5JY5QJ2W.mjs.map +0 -1
- package/dist/chunk-DFHFPZQD.mjs.map +0 -1
- package/dist/chunk-FBYETUFL.mjs.map +0 -1
- package/dist/chunk-UZTZXMYS.mjs +0 -18
- package/dist/chunk-UZTZXMYS.mjs.map +0 -1
- package/dist/chunk-Z6YOBQUJ.mjs.map +0 -1
- package/dist/components/chat/Response.d.ts +0 -7
- package/dist/components/chat/Response.js +0 -64
- package/dist/components/chat/Response.js.map +0 -1
- package/dist/components/chat/Response.mjs +0 -10
- package/dist/components/chat/Response.mjs.map +0 -1
- package/src/components/chat/Response.tsx +0 -12
- package/src/css/response.css +0 -26
- /package/dist/{chunk-CGVOCLHN.mjs.map → chunk-P7S3E5UW.mjs.map} +0 -0
- /package/dist/{chunk-6H7IQRIU.mjs.map → chunk-QTN7AYVL.mjs.map} +0 -0
- /package/dist/{chunk-LYHZXHTJ.mjs.map → chunk-SNLHKLW3.mjs.map} +0 -0
- /package/dist/{chunk-FFNESJSG.mjs.map → chunk-Y6OESC5U.mjs.map} +0 -0
- /package/dist/{chunk-QS7UFQFD.mjs.map → chunk-YGD4IB27.mjs.map} +0 -0
- /package/dist/{chunk-VC4NO5QZ.mjs.map → chunk-YOEL33HG.mjs.map} +0 -0
- /package/dist/{chunk-GJME6MK4.mjs.map → chunk-ZY25LVYR.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.8.0-next.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5f184b7: - fix: remove response button
|
|
8
|
+
- fix: use customizable assistant message icons
|
|
9
|
+
- @copilotkit/react-core@1.8.0-next.7
|
|
10
|
+
- @copilotkit/runtime-client-gql@1.8.0-next.7
|
|
11
|
+
- @copilotkit/shared@1.8.0-next.7
|
|
12
|
+
|
|
13
|
+
## 1.8.0-next.6
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- @copilotkit/react-core@1.8.0-next.6
|
|
18
|
+
- @copilotkit/runtime-client-gql@1.8.0-next.6
|
|
19
|
+
- @copilotkit/shared@1.8.0-next.6
|
|
20
|
+
|
|
3
21
|
## 1.8.0-next.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -3,13 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-XNQO5AZZ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useChatContext
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
CopyIcon,
|
|
9
|
-
RegenerateIcon,
|
|
10
|
-
ThumbsDownIcon,
|
|
11
|
-
ThumbsUpIcon
|
|
12
|
-
} from "./chunk-ORSMX3SE.mjs";
|
|
6
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
13
7
|
|
|
14
8
|
// src/components/chat/messages/AssistantMessage.tsx
|
|
15
9
|
import { useState } from "react";
|
|
@@ -71,7 +65,7 @@ var AssistantMessage = (props) => {
|
|
|
71
65
|
onClick: handleRegenerate,
|
|
72
66
|
"aria-label": labels.regenerateResponse,
|
|
73
67
|
title: labels.regenerateResponse,
|
|
74
|
-
children:
|
|
68
|
+
children: icons.regenerateIcon
|
|
75
69
|
}
|
|
76
70
|
),
|
|
77
71
|
/* @__PURE__ */ jsx(
|
|
@@ -81,7 +75,7 @@ var AssistantMessage = (props) => {
|
|
|
81
75
|
onClick: handleCopy,
|
|
82
76
|
"aria-label": labels.copyToClipboard,
|
|
83
77
|
title: labels.copyToClipboard,
|
|
84
|
-
children: copied ? /* @__PURE__ */ jsx("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) :
|
|
78
|
+
children: copied ? /* @__PURE__ */ jsx("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
|
|
85
79
|
}
|
|
86
80
|
),
|
|
87
81
|
onThumbsUp && /* @__PURE__ */ jsx(
|
|
@@ -91,7 +85,7 @@ var AssistantMessage = (props) => {
|
|
|
91
85
|
onClick: handleThumbsUp,
|
|
92
86
|
"aria-label": labels.thumbsUp,
|
|
93
87
|
title: labels.thumbsUp,
|
|
94
|
-
children:
|
|
88
|
+
children: icons.thumbsUpIcon
|
|
95
89
|
}
|
|
96
90
|
),
|
|
97
91
|
onThumbsDown && /* @__PURE__ */ jsx(
|
|
@@ -101,7 +95,7 @@ var AssistantMessage = (props) => {
|
|
|
101
95
|
onClick: handleThumbsDown,
|
|
102
96
|
"aria-label": labels.thumbsDown,
|
|
103
97
|
title: labels.thumbsDown,
|
|
104
|
-
children:
|
|
98
|
+
children: icons.thumbsDownIcon
|
|
105
99
|
}
|
|
106
100
|
)
|
|
107
101
|
]
|
|
@@ -115,4 +109,4 @@ var AssistantMessage = (props) => {
|
|
|
115
109
|
export {
|
|
116
110
|
AssistantMessage
|
|
117
111
|
};
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-5M7ODWKH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/messages/AssistantMessage.tsx"],"sourcesContent":["import { AssistantMessageProps } from \"../props\";\nimport { useChatContext } from \"../ChatContext\";\nimport { Markdown } from \"../Markdown\";\nimport { useState } from \"react\";\n\nexport const AssistantMessage = (props: AssistantMessageProps) => {\n const { icons, labels } = useChatContext();\n const {\n message,\n isLoading,\n subComponent,\n onRegenerate,\n onCopy,\n onThumbsUp,\n onThumbsDown,\n isCurrentMessage,\n } = props;\n const [copied, setCopied] = useState(false);\n\n const handleCopy = () => {\n if (message && onCopy) {\n navigator.clipboard.writeText(message);\n setCopied(true);\n onCopy(message);\n setTimeout(() => setCopied(false), 2000);\n } else if (message) {\n navigator.clipboard.writeText(message);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n }\n };\n\n const handleRegenerate = () => {\n if (onRegenerate) {\n onRegenerate();\n }\n };\n\n const handleThumbsUp = () => {\n if (onThumbsUp && message) {\n onThumbsUp(message);\n }\n };\n\n const handleThumbsDown = () => {\n if (onThumbsDown && message) {\n onThumbsDown(message);\n }\n };\n\n const LoadingIcon = () => <span>{icons.activityIcon}</span>;\n\n return (\n <>\n {(message || isLoading) && (\n <div className=\"copilotKitMessage copilotKitAssistantMessage\">\n {message && <Markdown content={message || \"\"} />}\n {isLoading && <LoadingIcon />}\n\n {message && !isLoading && (\n <div\n className={`copilotKitMessageControls ${isCurrentMessage ? \"currentMessage\" : \"\"}`}\n >\n <button\n className=\"copilotKitMessageControlButton\"\n onClick={handleRegenerate}\n aria-label={labels.regenerateResponse}\n title={labels.regenerateResponse}\n >\n {icons.regenerateIcon}\n </button>\n <button\n className=\"copilotKitMessageControlButton\"\n onClick={handleCopy}\n aria-label={labels.copyToClipboard}\n title={labels.copyToClipboard}\n >\n {copied ? (\n <span style={{ fontSize: \"10px\", fontWeight: \"bold\" }}>✓</span>\n ) : (\n icons.copyIcon\n )}\n </button>\n {onThumbsUp && (\n <button\n className=\"copilotKitMessageControlButton\"\n onClick={handleThumbsUp}\n aria-label={labels.thumbsUp}\n title={labels.thumbsUp}\n >\n {icons.thumbsUpIcon}\n </button>\n )}\n {onThumbsDown && (\n <button\n className=\"copilotKitMessageControlButton\"\n onClick={handleThumbsDown}\n aria-label={labels.thumbsDown}\n title={labels.thumbsDown}\n >\n {icons.thumbsDownIcon}\n </button>\n )}\n </div>\n )}\n </div>\n )}\n <div style={{ marginBottom: \"0.5rem\" }}>{subComponent}</div>\n </>\n );\n};\n"],"mappings":";;;;;;;;AAGA,SAAS,gBAAgB;AA+CG,SAGxB,UAHwB,KAUhB,YAVgB;AA7CrB,IAAM,mBAAmB,CAAC,UAAiC;AAChE,QAAM,EAAE,OAAO,OAAO,IAAI,eAAe;AACzC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAE1C,QAAM,aAAa,MAAM;AACvB,QAAI,WAAW,QAA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gBACC,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAY,OAAO;AAAA,gBACnB,OAAO,OAAO;AAAA,gBAEb,gBAAM;AAAA;AAAA,YACT;AAAA,YAED,gBACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAY,OAAO;AAAA,gBACnB,OAAO,OAAO;AAAA,gBAEb,gBAAM;AAAA;AAAA,YACT;AAAA;AAAA;AAAA,MAEJ;AAAA,OAEJ;AAAA,IAEF,oBAAC,SAAI,OAAO,EAAE,cAAc,SAAS,GAAI,wBAAa;AAAA,KACxD;AAEJ;","names":[]}
|
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Window
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P7S3E5UW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Header
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YGD4IB27.mjs";
|
|
7
7
|
import {
|
|
8
8
|
Button
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YOEL33HG.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotChat
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-HGA4N4ME.mjs";
|
|
13
13
|
import {
|
|
14
14
|
UserMessage
|
|
15
15
|
} from "./chunk-HEIDCT7I.mjs";
|
|
16
16
|
import {
|
|
17
17
|
AssistantMessage
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5M7ODWKH.mjs";
|
|
19
19
|
import {
|
|
20
20
|
Input
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-SNLHKLW3.mjs";
|
|
22
22
|
import {
|
|
23
23
|
Messages
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import {
|
|
26
|
-
ResponseButton
|
|
27
|
-
} from "./chunk-UZTZXMYS.mjs";
|
|
24
|
+
} from "./chunk-ZY25LVYR.mjs";
|
|
28
25
|
import {
|
|
29
26
|
ChatContextProvider
|
|
30
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
31
28
|
|
|
32
29
|
// src/components/chat/Modal.tsx
|
|
33
30
|
import React from "react";
|
|
@@ -45,14 +42,12 @@ var CopilotModal = ({
|
|
|
45
42
|
icons,
|
|
46
43
|
labels,
|
|
47
44
|
makeSystemMessage,
|
|
48
|
-
showResponseButton = true,
|
|
49
45
|
onInProgress,
|
|
50
46
|
Window: Window2 = Window,
|
|
51
47
|
Button: Button2 = Button,
|
|
52
48
|
Header: Header2 = Header,
|
|
53
49
|
Messages: Messages2 = Messages,
|
|
54
50
|
Input: Input2 = Input,
|
|
55
|
-
ResponseButton: ResponseButton2 = ResponseButton,
|
|
56
51
|
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
57
52
|
UserMessage: UserMessage2 = UserMessage,
|
|
58
53
|
className,
|
|
@@ -83,11 +78,9 @@ var CopilotModal = ({
|
|
|
83
78
|
onStopGeneration,
|
|
84
79
|
onReloadMessages,
|
|
85
80
|
makeSystemMessage,
|
|
86
|
-
showResponseButton,
|
|
87
81
|
onInProgress,
|
|
88
82
|
Messages: Messages2,
|
|
89
83
|
Input: Input2,
|
|
90
|
-
ResponseButton: ResponseButton2,
|
|
91
84
|
AssistantMessage: AssistantMessage2,
|
|
92
85
|
UserMessage: UserMessage2
|
|
93
86
|
}
|
|
@@ -102,4 +95,4 @@ var CopilotModal = ({
|
|
|
102
95
|
export {
|
|
103
96
|
CopilotModal
|
|
104
97
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
98
|
+
//# sourceMappingURL=chunk-EMWOZVCW.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 className,\n children,\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 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 />\n </Window>\n </div>\n </ChatContextProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AA8FV,cACA,YADA;AAnCD,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA,cAAc;AAAA,EACd,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAAA,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,UAAAC,YAAW;AAAA,EACX,OAAAC,SAAQ;AAAA,EACR,kBAAAC,oBAAmB;AAAA,EACnB,aAAAC,eAAc;AAAA,EACd;AAAA,EACA;AACF,MAAyB;AACvB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,WAAW;AAE5D,QAAM,UAAU,CAAC,SAAkB;AACjC,2CAAY;AACZ,iBAAa,IAAI;AAAA,EACnB;AAEA,SACE,qBAAC,uBAAoB,OAAc,QAAgB,MAAM,WAAW,SACjE;AAAA;AAAA,IACD,qBAAC,SAAI,WACH;AAAA,0BAACL,SAAA,EAAO;AAAA,MACR;AAAA,QAACD;AAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UAEA;AAAA,gCAACE,SAAA,EAAO;AAAA,YACR;AAAA,cAAC;AAAA;AAAA,gBACC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,UAAUC;AAAA,gBACV,OAAOC;AAAA,gBACP,kBAAkBC;AAAA,gBAClB,aAAaC;AAAA;AAAA,YACf;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["Window","Button","Header","Messages","Input","AssistantMessage","UserMessage"]}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
RenderAgentStateMessage
|
|
3
|
-
} from "./chunk-UWWMAJ7R.mjs";
|
|
4
1
|
import {
|
|
5
2
|
RenderResultMessage
|
|
6
3
|
} from "./chunk-WEYDZBT7.mjs";
|
|
@@ -12,27 +9,27 @@ import {
|
|
|
12
9
|
} from "./chunk-HEIDCT7I.mjs";
|
|
13
10
|
import {
|
|
14
11
|
AssistantMessage
|
|
15
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5M7ODWKH.mjs";
|
|
16
13
|
import {
|
|
17
14
|
RenderActionExecutionMessage
|
|
18
15
|
} from "./chunk-XB6QCUPB.mjs";
|
|
16
|
+
import {
|
|
17
|
+
RenderAgentStateMessage
|
|
18
|
+
} from "./chunk-UWWMAJ7R.mjs";
|
|
19
19
|
import {
|
|
20
20
|
Suggestion,
|
|
21
21
|
reloadSuggestions
|
|
22
22
|
} from "./chunk-TOQ7P4DO.mjs";
|
|
23
23
|
import {
|
|
24
24
|
Input
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-SNLHKLW3.mjs";
|
|
26
26
|
import {
|
|
27
27
|
Messages
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import {
|
|
30
|
-
ResponseButton
|
|
31
|
-
} from "./chunk-UZTZXMYS.mjs";
|
|
28
|
+
} from "./chunk-ZY25LVYR.mjs";
|
|
32
29
|
import {
|
|
33
30
|
ChatContext,
|
|
34
31
|
ChatContextProvider
|
|
35
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
36
33
|
import {
|
|
37
34
|
__async,
|
|
38
35
|
__spreadProps,
|
|
@@ -54,7 +51,6 @@ function CopilotChat({
|
|
|
54
51
|
instructions,
|
|
55
52
|
onSubmitMessage,
|
|
56
53
|
makeSystemMessage,
|
|
57
|
-
showResponseButton = true,
|
|
58
54
|
onInProgress,
|
|
59
55
|
onStopGeneration,
|
|
60
56
|
onReloadMessages,
|
|
@@ -68,7 +64,6 @@ function CopilotChat({
|
|
|
68
64
|
RenderAgentStateMessage: RenderAgentStateMessage2 = RenderAgentStateMessage,
|
|
69
65
|
RenderResultMessage: RenderResultMessage2 = RenderResultMessage,
|
|
70
66
|
Input: Input2 = Input,
|
|
71
|
-
ResponseButton: ResponseButton2 = ResponseButton,
|
|
72
67
|
className,
|
|
73
68
|
icons,
|
|
74
69
|
labels,
|
|
@@ -332,4 +327,4 @@ export {
|
|
|
332
327
|
WrappedCopilotChat,
|
|
333
328
|
useCopilotChatLogic
|
|
334
329
|
};
|
|
335
|
-
//# sourceMappingURL=chunk-
|
|
330
|
+
//# sourceMappingURL=chunk-HGA4N4ME.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 { AssistantMessage as DefaultAssistantMessage } from \"./messages/AssistantMessage\";\nimport { UserMessage as DefaultUserMessage } from \"./messages/UserMessage\";\nimport { Suggestion } from \"./Suggestion\";\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 } from \"@copilotkit/runtime-client-gql\";\nimport { randomId } from \"@copilotkit/shared\";\nimport {\n AssistantMessageProps,\n InputProps,\n MessagesProps,\n RenderMessageProps,\n UserMessageProps,\n} from \"./props\";\n\nimport { HintFunction, runAgent, stopAgent } from \"@copilotkit/react-core\";\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?: () => 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: string) => void;\n\n /**\n * A callback function for thumbs down feedback\n */\n onThumbsDown?: (message: string) => void;\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 * 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 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\nexport type OnStopGeneration = (args: OnStopGenerationArguments) => void;\n\nexport type OnReloadMessages = (args: OnReloadMessagesArguments) => void;\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 Messages = DefaultMessages,\n RenderTextMessage = DefaultRenderTextMessage,\n RenderActionExecutionMessage = DefaultRenderActionExecutionMessage,\n RenderAgentStateMessage = DefaultRenderAgentStateMessage,\n RenderResultMessage = DefaultRenderResultMessage,\n Input = DefaultInput,\n className,\n icons,\n labels,\n AssistantMessage = DefaultAssistantMessage,\n UserMessage = DefaultUserMessage,\n}: CopilotChatProps) {\n const { additionalInstructions, setChatInstructions } = useCopilotContext();\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 const chatContext = React.useContext(ChatContext);\n const isVisible = chatContext ? chatContext.open : true;\n\n const handleRegenerate = () => {\n if (onRegenerate) {\n onRegenerate();\n }\n\n reloadMessages();\n };\n\n const handleCopy = (message: string) => {\n if (onCopy) {\n onCopy(message);\n }\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 messages={visibleMessages}\n inProgress={isLoading}\n onRegenerate={handleRegenerate}\n onCopy={handleCopy}\n onThumbsUp={onThumbsUp}\n onThumbsDown={onThumbsDown}\n >\n {currentSuggestions.length > 0 && (\n <div className=\"suggestions\">\n {currentSuggestions.map((suggestion, index) => (\n <Suggestion\n key={index}\n title={suggestion.title}\n message={suggestion.message}\n partial={suggestion.partial}\n className={suggestion.className}\n onClick={(message) => sendMessage(message)}\n />\n ))}\n </div>\n )}\n </Messages>\n <Input\n inProgress={isLoading}\n onSend={sendMessage}\n isVisible={isVisible}\n onStop={stopGeneration}\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 (messageContent: string) => {\n abortSuggestions();\n setCurrentSuggestions([]);\n\n const message: Message = new TextMessage({\n content: messageContent,\n role: Role.User,\n });\n\n if (onSubmitMessage) {\n try {\n await onSubmitMessage(messageContent);\n } catch (error) {\n console.error(\"Error in onSubmitMessage:\", error);\n }\n }\n // this needs to happen after onSubmitMessage, because it will trigger submission\n // of the message to the endpoint. Some users depend on performing some actions\n // before the message is submitted.\n appendMessage(message);\n\n return message;\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() {\n if (onReloadMessages) {\n onReloadMessages({\n messages,\n setMessages,\n stopGeneration: defaultStopGeneration,\n currentAgentName,\n restartCurrentAgent,\n stopCurrentAgent,\n runCurrentAgent,\n setCurrentAgentState,\n });\n } else {\n defaultReloadMessages();\n }\n }\n\n return {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAkB,MAAM,mBAAmB;AAC3C,SAAS,gBAAgB;AASzB,SAAuB,UAAU,iBAAiB;AAgQ9C,SA2DK,UAzCK,KAlBV;AAnFG,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAA,YAAW;AAAA,EACX,mBAAAC,qBAAoB;AAAA,EACpB,8BAAAC,gCAA+B;AAAA,EAC/B,yBAAAC,2BAA0B;AAAA,EAC1B,qBAAAC,uBAAsB;AAAA,EACtB,OAAAC,SAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAAC,oBAAmB;AAAA,EACnB,aAAAC,eAAc;AAChB,GAAqB;AACnB,QAAM,EAAE,wBAAwB,oBAAoB,IAAI,kBAAkB;AAE1E,YAAU,MAAM;AACd,QAAI,EAAC,iEAAwB,SAAQ;AACnC,0BAAoB,gBAAgB,EAAE;AACtC;AAAA,IACF;AAUA,UAAM,iCAAiC;AAAA,MACrC;AAAA,MACA;AAAA,MACA,GAAG,uBAAuB,IAAI,CAAC,gBAAgB,KAAK,aAAa;AAAA,IACnE;AAEA,YAAQ,IAAI,kCAAkC,8BAA8B;AAE5E,wBAAoB,+BAA+B,KAAK,IAAI,KAAK,EAAE;AAAA,EACrE,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AA,EACF;AACA,QAAM,uBAAuB,CAAC,UAAe;AAC3C,QAAI,eAAe,cAAc;AAC/B,qBAAe,iBAAiB,CAAC,oBAAoB;AACnD,eAAO,iCACF,kBADE;AAAA,UAEL,CAAC,eAAe,aAAc,SAAS,GAAG;AAAA,YACxC;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,WAAS,iBAAiB;AACxB,QAAI,kBAAkB;AACpB,uBAAiB;AAAA,QACf;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,4BAAsB;AAAA,IACxB;AAAA,EACF;AACA,WAAS,iBAAiB;AACxB,QAAI,kBAAkB;AACpB,uBAAiB;AAAA,QACf;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,QAChB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,4BAAsB;AAAA,IACxB;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","Input","AssistantMessage","UserMessage","_a"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useChatContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/chat/Window.tsx
|
|
6
6
|
import React, { useCallback, useEffect } from "react";
|
|
@@ -115,4 +115,4 @@ function isMacOS() {
|
|
|
115
115
|
export {
|
|
116
116
|
Window
|
|
117
117
|
};
|
|
118
|
-
//# sourceMappingURL=chunk-
|
|
118
|
+
//# sourceMappingURL=chunk-P7S3E5UW.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EMWOZVCW.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-QTN7AYVL.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-YQFVRDNC.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useChatContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
7
7
|
import {
|
|
8
8
|
usePushToTalk
|
|
9
9
|
} from "./chunk-S5MBUNGN.mjs";
|
|
@@ -100,4 +100,4 @@ var Input = ({ inProgress, onSend, isVisible = false, onStop }) => {
|
|
|
100
100
|
export {
|
|
101
101
|
Input
|
|
102
102
|
};
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
103
|
+
//# sourceMappingURL=chunk-SNLHKLW3.mjs.map
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ActivityIcon,
|
|
3
3
|
CloseIcon,
|
|
4
|
+
CopyIcon,
|
|
4
5
|
HeaderCloseIcon,
|
|
5
6
|
MicrophoneIcon,
|
|
6
7
|
OpenIcon,
|
|
7
8
|
RegenerateIcon,
|
|
8
9
|
SendIcon,
|
|
9
10
|
SpinnerIcon,
|
|
10
|
-
StopIcon
|
|
11
|
+
StopIcon,
|
|
12
|
+
ThumbsDownIcon,
|
|
13
|
+
ThumbsUpIcon
|
|
11
14
|
} from "./chunk-ORSMX3SE.mjs";
|
|
12
15
|
import {
|
|
13
16
|
__spreadValues
|
|
@@ -61,7 +64,10 @@ var ChatContextProvider = ({
|
|
|
61
64
|
spinnerIcon: SpinnerIcon,
|
|
62
65
|
stopIcon: StopIcon,
|
|
63
66
|
regenerateIcon: RegenerateIcon,
|
|
64
|
-
pushToTalkIcon: MicrophoneIcon
|
|
67
|
+
pushToTalkIcon: MicrophoneIcon,
|
|
68
|
+
copyIcon: CopyIcon,
|
|
69
|
+
thumbsUpIcon: ThumbsUpIcon,
|
|
70
|
+
thumbsDownIcon: ThumbsDownIcon
|
|
65
71
|
}), icons),
|
|
66
72
|
[icons]
|
|
67
73
|
);
|
|
@@ -82,4 +88,4 @@ export {
|
|
|
82
88
|
useChatContext,
|
|
83
89
|
ChatContextProvider
|
|
84
90
|
};
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
91
|
+
//# sourceMappingURL=chunk-UN2E3HCK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/ChatContext.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\nimport { ThumbsDownIcon, ThumbsUpIcon } from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n\n /**\n * The icons to use for copy assistant response\n * @default <CopyIcon />\n */\n\n copyIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs up/response approval.\n * @default <ThumbsUpIcon />\n */\n\n thumbsUpIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs down/response rejection.\n * @default <ThumbsDownIcon />\n */\n\n thumbsDownIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n\n /**\n * The label for the copy button.\n * @default \"Copy to clipboard\"\n */\n copyToClipboard?: string;\n\n /**\n * The label for the thumbs up button.\n * @default \"Thumbs up\"\n */\n thumbsUp?: string;\n\n /**\n * The label for the thumbs down button.\n * @default \"Thumbs down\"\n */\n thumbsDown?: string;\n\n /**\n * The text to display when content is copied.\n * @default \"Copied!\"\n */\n copied?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n copyToClipboard: \"Copy to clipboard\",\n thumbsUp: \"Thumbs up\",\n thumbsDown: \"Thumbs down\",\n copied: \"Copied!\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.MicrophoneIcon,\n copyIcon: DefaultIcons.CopyIcon,\n thumbsUpIcon: DefaultIcons.ThumbsUpIcon,\n thumbsDownIcon: DefaultIcons.ThumbsDownIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,SAAS,eAAyB;AA+OhC;AAnFF,IAAM,cAAc,MAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,MAA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6
6
|
__spreadValues
|
|
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
|
|
|
27
27
|
export {
|
|
28
28
|
CopilotSidebar
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-Y6OESC5U.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-GBXUOB6L.mjs";
|
|
4
4
|
import {
|
|
5
5
|
useChatContext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
7
7
|
|
|
8
8
|
// src/components/chat/Header.tsx
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -21,4 +21,4 @@ var Header = ({}) => {
|
|
|
21
21
|
export {
|
|
22
22
|
Header
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-YGD4IB27.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useChatContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/chat/Button.tsx
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -22,4 +22,4 @@ var Button = ({}) => {
|
|
|
22
22
|
export {
|
|
23
23
|
Button
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-YOEL33HG.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useChatContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UN2E3HCK.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/chat/Messages.tsx
|
|
6
6
|
import { useEffect, useMemo, useRef } from "react";
|
|
@@ -190,4 +190,4 @@ export {
|
|
|
190
190
|
Messages,
|
|
191
191
|
useScrollToBottom
|
|
192
192
|
};
|
|
193
|
-
//# sourceMappingURL=chunk-
|
|
193
|
+
//# sourceMappingURL=chunk-ZY25LVYR.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/chat/Button.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import { ButtonProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Button = ({}: ButtonProps) => {\n const { open, setOpen, icons } = useChatContext();\n\n return (\n <div onClick={() => setOpen(!open)}>\n <button\n className={`copilotKitButton ${open ? \"open\" : \"\"}`}\n aria-label={open ? \"Close Chat\" : \"Open Chat\"}\n >\n <div className=\"copilotKitButtonIcon copilotKitButtonIconOpen\">{icons.openIcon}</div>\n <div className=\"copilotKitButtonIcon copilotKitButtonIconClose\">{icons.closeIcon}</div>\n </button>\n </div>\n );\n};\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n\n /**\n * The label for the copy button.\n * @default \"Copy to clipboard\"\n */\n copyToClipboard?: string;\n\n /**\n * The label for the thumbs up button.\n * @default \"Thumbs up\"\n */\n thumbsUp?: string;\n\n /**\n * The label for the thumbs down button.\n * @default \"Thumbs down\"\n */\n thumbsDown?: string;\n\n /**\n * The text to display when content is copied.\n * @default \"Copied!\"\n */\n copied?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n copyToClipboard: \"Copy to clipboard\",\n thumbsUp: \"Thumbs up\",\n thumbsDown: \"Thumbs down\",\n copied: \"Copied!\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.MicrophoneIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;
|
|
1
|
+
{"version":3,"sources":["../../../src/components/chat/Button.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import { ButtonProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\n\nexport const Button = ({}: ButtonProps) => {\n const { open, setOpen, icons } = useChatContext();\n\n return (\n <div onClick={() => setOpen(!open)}>\n <button\n className={`copilotKitButton ${open ? \"open\" : \"\"}`}\n aria-label={open ? \"Close Chat\" : \"Open Chat\"}\n >\n <div className=\"copilotKitButtonIcon copilotKitButtonIconOpen\">{icons.openIcon}</div>\n <div className=\"copilotKitButtonIcon copilotKitButtonIconClose\">{icons.closeIcon}</div>\n </button>\n </div>\n );\n};\n","import React, { useMemo, useState } from \"react\";\nimport * as DefaultIcons from \"./Icons\";\nimport { ThumbsDownIcon, ThumbsUpIcon } from \"./Icons\";\n\n/**\n * Icons for CopilotChat component.\n */\nexport interface CopilotChatIcons {\n /**\n * The icon to use for the open chat button.\n * @default <OpenIcon />\n */\n openIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button.\n * @default <CloseIcon />\n */\n closeIcon?: React.ReactNode;\n\n /**\n * The icon to use for the close chat button in the header.\n * @default <HeaderCloseIcon />\n */\n headerCloseIcon?: React.ReactNode;\n\n /**\n * The icon to use for the send button.\n * @default <SendIcon />\n */\n sendIcon?: React.ReactNode;\n\n /**\n * The icon to use for the activity indicator.\n * @default <ActivityIcon />\n */\n activityIcon?: React.ReactNode;\n\n /**\n * The icon to use for the spinner.\n * @default <SpinnerIcon />\n */\n spinnerIcon?: React.ReactNode;\n\n /**\n * The icon to use for the stop button.\n * @default <StopIcon />\n */\n stopIcon?: React.ReactNode;\n\n /**\n * The icon to use for the regenerate button.\n * @default <RegenerateIcon />\n */\n regenerateIcon?: React.ReactNode;\n\n /**\n * The icons to use for push to talk.\n * @default <PushToTalkIcon />\n */\n\n pushToTalkIcon?: React.ReactNode;\n\n /**\n * The icons to use for copy assistant response\n * @default <CopyIcon />\n */\n\n copyIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs up/response approval.\n * @default <ThumbsUpIcon />\n */\n\n thumbsUpIcon?: React.ReactNode;\n\n /**\n * The icon to use for thumbs down/response rejection.\n * @default <ThumbsDownIcon />\n */\n\n thumbsDownIcon?: React.ReactNode;\n}\n\n/**\n * Labels for CopilotChat component.\n */\nexport interface CopilotChatLabels {\n /**\n * The initial message(s) to display in the chat window.\n */\n initial?: string | string[];\n\n /**\n * The title to display in the header.\n * @default \"CopilotKit\"\n */\n title?: string;\n\n /**\n * The placeholder to display in the input.\n * @default \"Type a message...\"\n */\n placeholder?: string;\n\n /**\n * The message to display when an error occurs.\n * @default \"❌ An error occurred. Please try again.\"\n */\n error?: string;\n\n /**\n * The label to display on the stop button.\n * @default \"Stop generating\"\n */\n stopGenerating?: string;\n\n /**\n * The label to display on the regenerate button.\n * @default \"Regenerate response\"\n */\n regenerateResponse?: string;\n\n /**\n * The label for the copy button.\n * @default \"Copy to clipboard\"\n */\n copyToClipboard?: string;\n\n /**\n * The label for the thumbs up button.\n * @default \"Thumbs up\"\n */\n thumbsUp?: string;\n\n /**\n * The label for the thumbs down button.\n * @default \"Thumbs down\"\n */\n thumbsDown?: string;\n\n /**\n * The text to display when content is copied.\n * @default \"Copied!\"\n */\n copied?: string;\n}\n\ninterface ChatContext {\n labels: Required<CopilotChatLabels>;\n icons: Required<CopilotChatIcons>;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContext = React.createContext<ChatContext | undefined>(undefined);\n\nexport function useChatContext(): ChatContext {\n const context = React.useContext(ChatContext);\n if (context === undefined) {\n throw new Error(\n \"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?\",\n );\n }\n return context;\n}\n\ninterface ChatContextProps {\n // temperature?: number;\n // instructions?: string;\n // maxFeedback?: number;\n labels?: CopilotChatLabels;\n icons?: CopilotChatIcons;\n children?: React.ReactNode;\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const ChatContextProvider = ({\n // temperature,\n // instructions,\n // maxFeedback,\n labels,\n icons,\n children,\n open,\n setOpen,\n}: ChatContextProps) => {\n const memoizedLabels = useMemo(\n () => ({\n ...{\n initial: \"\",\n title: \"CopilotKit\",\n placeholder: \"Type a message...\",\n error: \"❌ An error occurred. Please try again.\",\n stopGenerating: \"Stop generating\",\n regenerateResponse: \"Regenerate response\",\n copyToClipboard: \"Copy to clipboard\",\n thumbsUp: \"Thumbs up\",\n thumbsDown: \"Thumbs down\",\n copied: \"Copied!\",\n },\n ...labels,\n }),\n [labels],\n );\n\n const memoizedIcons = useMemo(\n () => ({\n ...{\n openIcon: DefaultIcons.OpenIcon,\n closeIcon: DefaultIcons.CloseIcon,\n headerCloseIcon: DefaultIcons.HeaderCloseIcon,\n sendIcon: DefaultIcons.SendIcon,\n activityIcon: DefaultIcons.ActivityIcon,\n spinnerIcon: DefaultIcons.SpinnerIcon,\n stopIcon: DefaultIcons.StopIcon,\n regenerateIcon: DefaultIcons.RegenerateIcon,\n pushToTalkIcon: DefaultIcons.MicrophoneIcon,\n copyIcon: DefaultIcons.CopyIcon,\n thumbsUpIcon: DefaultIcons.ThumbsUpIcon,\n thumbsDownIcon: DefaultIcons.ThumbsDownIcon,\n },\n ...icons,\n }),\n [icons],\n );\n\n const context = useMemo(\n () => ({\n labels: memoizedLabels,\n icons: memoizedIcons,\n open,\n setOpen,\n }),\n [memoizedLabels, memoizedIcons, open, setOpen],\n );\n\n return <ChatContext.Provider value={context}>{children}</ChatContext.Provider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AA+OhC;AAnFF,IAAM,cAAc,aAAAA,QAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,aAAAA,QAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;AD9JM,IAAAC,sBAAA;AALC,IAAM,SAAS,CAAC,CAAC,MAAmB;AACzC,QAAM,EAAE,MAAM,SAAS,MAAM,IAAI,eAAe;AAEhD,SACE,6CAAC,SAAI,SAAS,MAAM,QAAQ,CAAC,IAAI,GAC/B;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,oBAAoB,OAAO,SAAS;AAAA,MAC/C,cAAY,OAAO,eAAe;AAAA,MAElC;AAAA,qDAAC,SAAI,WAAU,iDAAiD,gBAAM,UAAS;AAAA,QAC/E,6CAAC,SAAI,WAAU,kDAAkD,gBAAM,WAAU;AAAA;AAAA;AAAA,EACnF,GACF;AAEJ;","names":["React","import_jsx_runtime"]}
|
|
@@ -4,7 +4,7 @@ import React__default from 'react';
|
|
|
4
4
|
import { SystemMessageFunction, HintFunction } from '@copilotkit/react-core';
|
|
5
5
|
import { CopilotChatSuggestion } from '../../types/suggestions.js';
|
|
6
6
|
import { Message } from '@copilotkit/runtime-client-gql';
|
|
7
|
-
import { AssistantMessageProps, UserMessageProps, MessagesProps, RenderMessageProps, InputProps
|
|
7
|
+
import { AssistantMessageProps, UserMessageProps, MessagesProps, RenderMessageProps, InputProps } from './props.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Props for CopilotChat component.
|
|
@@ -66,11 +66,6 @@ interface CopilotChatProps {
|
|
|
66
66
|
* instructions is not enough.
|
|
67
67
|
*/
|
|
68
68
|
makeSystemMessage?: SystemMessageFunction;
|
|
69
|
-
/**
|
|
70
|
-
* Whether to show the response button.
|
|
71
|
-
* @default true
|
|
72
|
-
*/
|
|
73
|
-
showResponseButton?: boolean;
|
|
74
69
|
/**
|
|
75
70
|
* A custom assistant message component to use instead of the default.
|
|
76
71
|
*/
|
|
@@ -103,10 +98,6 @@ interface CopilotChatProps {
|
|
|
103
98
|
* A custom Input component to use instead of the default.
|
|
104
99
|
*/
|
|
105
100
|
Input?: React__default.ComponentType<InputProps>;
|
|
106
|
-
/**
|
|
107
|
-
* A custom ResponseButton component to use instead of the default.
|
|
108
|
-
*/
|
|
109
|
-
ResponseButton?: React__default.ComponentType<ResponseButtonProps>;
|
|
110
101
|
/**
|
|
111
102
|
* A class name to apply to the root element.
|
|
112
103
|
*/
|
|
@@ -153,7 +144,7 @@ interface OnStopGenerationArguments {
|
|
|
153
144
|
type OnReloadMessagesArguments = OnStopGenerationArguments;
|
|
154
145
|
type OnStopGeneration = (args: OnStopGenerationArguments) => void;
|
|
155
146
|
type OnReloadMessages = (args: OnReloadMessagesArguments) => void;
|
|
156
|
-
declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage,
|
|
147
|
+
declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, onInProgress, onStopGeneration, onReloadMessages, onRegenerate, onCopy, onThumbsUp, onThumbsDown, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, Input, className, icons, labels, AssistantMessage, UserMessage, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
157
148
|
declare function WrappedCopilotChat({ children, icons, labels, className, }: {
|
|
158
149
|
children: React__default.ReactNode;
|
|
159
150
|
icons?: CopilotChatIcons;
|