@copilotkit/react-ui 1.8.13-next.2 → 1.8.13-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/{chunk-3R6CEFJE.mjs → chunk-FWKHST6I.mjs} +67 -33
- package/dist/chunk-FWKHST6I.mjs.map +1 -0
- package/dist/{chunk-ZRW27A32.mjs → chunk-IAHSHPRJ.mjs} +12 -13
- package/dist/chunk-IAHSHPRJ.mjs.map +1 -0
- package/dist/{chunk-XZNY26GH.mjs → chunk-IMBPSLL4.mjs} +3 -3
- package/dist/chunk-IMBPSLL4.mjs.map +1 -0
- package/dist/{chunk-756IINQI.mjs → chunk-JU3HNL5N.mjs} +2 -2
- package/dist/{chunk-IQ7DDXDA.mjs → chunk-QEZ3YYLO.mjs} +2 -2
- package/dist/chunk-QGSPTXOV.mjs +24 -0
- package/dist/chunk-QGSPTXOV.mjs.map +1 -0
- package/dist/chunk-SC6JRFAJ.mjs +1 -0
- package/dist/components/chat/Button.d.ts +1 -0
- package/dist/components/chat/Chat.d.ts +6 -2
- package/dist/components/chat/Chat.js +39 -24
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +3 -2
- package/dist/components/chat/Header.d.ts +1 -0
- package/dist/components/chat/Input.d.ts +1 -0
- package/dist/components/chat/Messages.d.ts +1 -0
- package/dist/components/chat/Modal.d.ts +2 -2
- package/dist/components/chat/Modal.js +106 -62
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +4 -3
- package/dist/components/chat/Popup.d.ts +1 -1
- package/dist/components/chat/Popup.js +108 -64
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +5 -4
- package/dist/components/chat/Sidebar.d.ts +1 -1
- package/dist/components/chat/Sidebar.js +108 -64
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +5 -4
- package/dist/components/chat/Suggestion.d.ts +8 -4
- package/dist/components/chat/Suggestion.js +2 -2
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/Suggestions.d.ts +9 -0
- package/dist/components/chat/Suggestions.js +73 -0
- package/dist/components/chat/Suggestions.js.map +1 -0
- package/dist/components/chat/Suggestions.mjs +10 -0
- package/dist/components/chat/Suggestions.mjs.map +1 -0
- package/dist/components/chat/Window.d.ts +1 -0
- package/dist/components/chat/index.d.ts +4 -2
- package/dist/components/chat/index.js +114 -66
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +14 -7
- package/dist/components/chat/messages/AssistantMessage.d.ts +1 -0
- package/dist/components/chat/messages/RenderActionExecutionMessage.d.ts +1 -0
- package/dist/components/chat/messages/RenderAgentStateMessage.d.ts +1 -0
- package/dist/components/chat/messages/RenderImageMessage.d.ts +1 -0
- package/dist/components/chat/messages/RenderResultMessage.d.ts +1 -0
- package/dist/components/chat/messages/RenderTextMessage.d.ts +1 -0
- package/dist/components/chat/messages/UserMessage.d.ts +1 -0
- package/dist/components/chat/props.d.ts +6 -1
- package/dist/components/chat/props.js.map +1 -1
- package/dist/components/index.d.ts +4 -2
- package/dist/components/index.js +114 -66
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +14 -7
- package/dist/index.d.ts +4 -2
- package/dist/index.js +114 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -7
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/chat/Chat.tsx +12 -14
- package/src/components/chat/Modal.tsx +2 -0
- package/src/components/chat/Suggestion.tsx +10 -3
- package/src/components/chat/Suggestions.tsx +20 -0
- package/src/components/chat/index.tsx +2 -0
- package/src/components/chat/props.ts +6 -0
- package/src/types/index.ts +1 -0
- package/dist/chunk-3R6CEFJE.mjs.map +0 -1
- package/dist/chunk-PXEVB7IK.mjs +0 -1
- package/dist/chunk-XZNY26GH.mjs.map +0 -1
- package/dist/chunk-ZRW27A32.mjs.map +0 -1
- /package/dist/{chunk-756IINQI.mjs.map → chunk-JU3HNL5N.mjs.map} +0 -0
- /package/dist/{chunk-IQ7DDXDA.mjs.map → chunk-QEZ3YYLO.mjs.map} +0 -0
- /package/dist/{chunk-PXEVB7IK.mjs.map → chunk-SC6JRFAJ.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
+
## 1.8.13-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f1b81bf: - feat: enable replacing suggestions list
|
|
8
|
+
- @copilotkit/react-core@1.8.13-next.3
|
|
9
|
+
- @copilotkit/runtime-client-gql@1.8.13-next.3
|
|
10
|
+
- @copilotkit/shared@1.8.13-next.3
|
|
11
|
+
|
|
3
12
|
## 1.8.13-next.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-UFN2VWSR.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotChat
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IAHSHPRJ.mjs";
|
|
13
13
|
import {
|
|
14
14
|
AssistantMessage
|
|
15
15
|
} from "./chunk-XMNTLIK5.mjs";
|
|
@@ -25,39 +25,73 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
ChatContextProvider
|
|
27
27
|
} from "./chunk-IEMQ2SQW.mjs";
|
|
28
|
+
import {
|
|
29
|
+
__objRest,
|
|
30
|
+
__spreadProps,
|
|
31
|
+
__spreadValues
|
|
32
|
+
} from "./chunk-MRXNTQOX.mjs";
|
|
28
33
|
|
|
29
34
|
// src/components/chat/Modal.tsx
|
|
30
35
|
import React from "react";
|
|
31
36
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
32
|
-
var CopilotModal = ({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
var CopilotModal = (_a) => {
|
|
38
|
+
var _b = _a, {
|
|
39
|
+
instructions,
|
|
40
|
+
defaultOpen = false,
|
|
41
|
+
clickOutsideToClose = true,
|
|
42
|
+
hitEscapeToClose = true,
|
|
43
|
+
onSetOpen,
|
|
44
|
+
onSubmitMessage,
|
|
45
|
+
onStopGeneration,
|
|
46
|
+
onReloadMessages,
|
|
47
|
+
shortcut = "/",
|
|
48
|
+
icons,
|
|
49
|
+
labels,
|
|
50
|
+
makeSystemMessage,
|
|
51
|
+
onInProgress,
|
|
52
|
+
Window: Window2 = Window,
|
|
53
|
+
Button: Button2 = Button,
|
|
54
|
+
Header: Header2 = Header,
|
|
55
|
+
Messages: Messages2 = Messages,
|
|
56
|
+
Input: Input2 = Input,
|
|
57
|
+
AssistantMessage: AssistantMessage2 = AssistantMessage,
|
|
58
|
+
UserMessage: UserMessage2 = UserMessage,
|
|
59
|
+
onThumbsUp,
|
|
60
|
+
onThumbsDown,
|
|
61
|
+
onCopy,
|
|
62
|
+
onRegenerate,
|
|
63
|
+
markdownTagRenderers,
|
|
64
|
+
className,
|
|
65
|
+
children
|
|
66
|
+
} = _b, props = __objRest(_b, [
|
|
67
|
+
"instructions",
|
|
68
|
+
"defaultOpen",
|
|
69
|
+
"clickOutsideToClose",
|
|
70
|
+
"hitEscapeToClose",
|
|
71
|
+
"onSetOpen",
|
|
72
|
+
"onSubmitMessage",
|
|
73
|
+
"onStopGeneration",
|
|
74
|
+
"onReloadMessages",
|
|
75
|
+
"shortcut",
|
|
76
|
+
"icons",
|
|
77
|
+
"labels",
|
|
78
|
+
"makeSystemMessage",
|
|
79
|
+
"onInProgress",
|
|
80
|
+
"Window",
|
|
81
|
+
"Button",
|
|
82
|
+
"Header",
|
|
83
|
+
"Messages",
|
|
84
|
+
"Input",
|
|
85
|
+
"AssistantMessage",
|
|
86
|
+
"UserMessage",
|
|
87
|
+
"onThumbsUp",
|
|
88
|
+
"onThumbsDown",
|
|
89
|
+
"onCopy",
|
|
90
|
+
"onRegenerate",
|
|
91
|
+
"markdownTagRenderers",
|
|
92
|
+
"className",
|
|
93
|
+
"children"
|
|
94
|
+
]);
|
|
61
95
|
const [openState, setOpenState] = React.useState(defaultOpen);
|
|
62
96
|
const setOpen = (open) => {
|
|
63
97
|
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
@@ -77,7 +111,7 @@ var CopilotModal = ({
|
|
|
77
111
|
/* @__PURE__ */ jsx(Header2, {}),
|
|
78
112
|
/* @__PURE__ */ jsx(
|
|
79
113
|
CopilotChat,
|
|
80
|
-
{
|
|
114
|
+
__spreadProps(__spreadValues({}, props), {
|
|
81
115
|
instructions,
|
|
82
116
|
onSubmitMessage,
|
|
83
117
|
onStopGeneration,
|
|
@@ -93,7 +127,7 @@ var CopilotModal = ({
|
|
|
93
127
|
onCopy,
|
|
94
128
|
onRegenerate,
|
|
95
129
|
markdownTagRenderers
|
|
96
|
-
}
|
|
130
|
+
})
|
|
97
131
|
)
|
|
98
132
|
]
|
|
99
133
|
}
|
|
@@ -105,4 +139,4 @@ var CopilotModal = ({
|
|
|
105
139
|
export {
|
|
106
140
|
CopilotModal
|
|
107
141
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
142
|
+
//# sourceMappingURL=chunk-FWKHST6I.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 </ChatContextProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAoGV,cACA,YADA;AAzCD,IAAM,eAAe,CAAC,OA6BJ;AA7BI,eAC3B;AAAA;AAAA,IACA,cAAc;AAAA,IACd,sBAAsB;AAAA,IACtB,mBAAmB;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAAA,UAAS;AAAA,IACT,QAAAC,UAAS;AAAA,IACT,QAAAC,UAAS;AAAA,IACT,UAAAC,YAAW;AAAA,IACX,OAAAC,SAAQ;AAAA,IACR,kBAAAC,oBAAmB;AAAA,IACnB,aAAAC,eAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAtFF,IA2D6B,IA4BxB,kBA5BwB,IA4BxB;AAAA,IA3BH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,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,+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"]}
|
|
@@ -20,9 +20,11 @@ import {
|
|
|
20
20
|
UserMessage
|
|
21
21
|
} from "./chunk-HWMFMBJC.mjs";
|
|
22
22
|
import {
|
|
23
|
-
|
|
23
|
+
Suggestions
|
|
24
|
+
} from "./chunk-QGSPTXOV.mjs";
|
|
25
|
+
import {
|
|
24
26
|
reloadSuggestions
|
|
25
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-IMBPSLL4.mjs";
|
|
26
28
|
import {
|
|
27
29
|
ImageUploadQueue
|
|
28
30
|
} from "./chunk-PLHTVHUW.mjs";
|
|
@@ -71,6 +73,7 @@ function CopilotChat({
|
|
|
71
73
|
RenderAgentStateMessage: RenderAgentStateMessage2 = RenderAgentStateMessage,
|
|
72
74
|
RenderResultMessage: RenderResultMessage2 = RenderResultMessage,
|
|
73
75
|
RenderImageMessage: RenderImageMessage2 = RenderImageMessage,
|
|
76
|
+
RenderSuggestionsList = Suggestions,
|
|
74
77
|
Input: Input2 = Input,
|
|
75
78
|
className,
|
|
76
79
|
icons,
|
|
@@ -228,17 +231,13 @@ function CopilotChat({
|
|
|
228
231
|
onThumbsUp,
|
|
229
232
|
onThumbsDown,
|
|
230
233
|
markdownTagRenderers,
|
|
231
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ jsx(
|
|
232
|
-
|
|
234
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ jsx(
|
|
235
|
+
RenderSuggestionsList,
|
|
233
236
|
{
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
onClick: (message) => handleSendMessage(message)
|
|
239
|
-
},
|
|
240
|
-
index
|
|
241
|
-
)) })
|
|
237
|
+
onSuggestionClick: handleSendMessage,
|
|
238
|
+
suggestions: currentSuggestions
|
|
239
|
+
}
|
|
240
|
+
)
|
|
242
241
|
}
|
|
243
242
|
),
|
|
244
243
|
imageUploadsEnabled && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -470,4 +469,4 @@ export {
|
|
|
470
469
|
WrappedCopilotChat,
|
|
471
470
|
useCopilotChatLogic
|
|
472
471
|
};
|
|
473
|
-
//# sourceMappingURL=chunk-
|
|
472
|
+
//# sourceMappingURL=chunk-IAHSHPRJ.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: string) => void;\n\n /**\n * A callback function for thumbs down feedback\n */\n onThumbsDown?: (message: string) => 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};\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ACA;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,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"]}
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
import { actionParametersToJsonSchema } from "@copilotkit/shared";
|
|
13
13
|
import { CopilotRequestType } from "@copilotkit/runtime-client-gql";
|
|
14
14
|
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
function Suggestion({ title,
|
|
15
|
+
function Suggestion({ title, onClick, partial, className }) {
|
|
16
16
|
return /* @__PURE__ */ jsx(
|
|
17
17
|
"button",
|
|
18
18
|
{
|
|
19
19
|
disabled: partial,
|
|
20
20
|
onClick: (e) => {
|
|
21
21
|
e.preventDefault();
|
|
22
|
-
onClick(
|
|
22
|
+
onClick();
|
|
23
23
|
},
|
|
24
24
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
25
25
|
"data-test-id": "suggestion",
|
|
@@ -101,4 +101,4 @@ export {
|
|
|
101
101
|
Suggestion,
|
|
102
102
|
reloadSuggestions
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
104
|
+
//# sourceMappingURL=chunk-IMBPSLL4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Suggestion.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\ninterface SuggestionsProps {\n title: string;\n message: string;\n partial?: boolean;\n className?: string;\n onClick: () => void;\n}\n\nexport function Suggestion({ title, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick();\n }}\n className={className || (partial ? \"suggestion loading\" : \"suggestion\")}\n data-test-id=\"suggestion\"\n >\n {partial ? SmallSpinnerIcon : <span>{title}</span>}\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n"],"mappings":";;;;;;;;AAAA;AAAA,EAEE;AAAA,OAGK;AAGP,SAAS,oCAAoC;AAC7C,SAAS,0BAA0B;AAqBC;AAX7B,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,UAAU,GAAqB;AACnF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ;AAAA,MACV;AAAA,MACA,WAAW,cAAc,UAAU,uBAAuB;AAAA,MAC1D,gBAAa;AAAA,MAEZ,oBAAU,mBAAmB,oBAAC,UAAM,iBAAM;AAAA;AAAA,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E,OAAO,QAAQ,IAAI,YAAY,CAAC;AAGxC,kBAAM,UAAU,KAAK,YAAY,SAAS,KAAK,WAAW;AAE1D,2BAAe,KAAK;AAAA,cAClB;AAAA,cACA;AAAA,cACA;AAAA,cACA,WAAW,OAAO;AAAA,YACpB,CAAC;AAAA,UACH;AACA,gCAAsB,CAAC,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAAA,QAC9D;AAAA,MACF,CAAC;AACD,qBAAe,KAAK,GAAG,OAAO,WAAW;AAAA,IAC3C,SAAS,OAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,MAAI,mBAAmB,YAAY,iBAAiB;AAClD,uBAAmB,UAAU;AAAA,EAC/B;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FWKHST6I.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-JU3HNL5N.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FWKHST6I.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-QEZ3YYLO.mjs.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Suggestion
|
|
3
|
+
} from "./chunk-IMBPSLL4.mjs";
|
|
4
|
+
|
|
5
|
+
// src/components/chat/Suggestions.tsx
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
8
|
+
return /* @__PURE__ */ jsx("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ jsx(
|
|
9
|
+
Suggestion,
|
|
10
|
+
{
|
|
11
|
+
title: suggestion.title,
|
|
12
|
+
message: suggestion.message,
|
|
13
|
+
partial: suggestion.partial,
|
|
14
|
+
className: suggestion.className,
|
|
15
|
+
onClick: () => onSuggestionClick(suggestion.message)
|
|
16
|
+
},
|
|
17
|
+
index
|
|
18
|
+
)) });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
Suggestions
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-QGSPTXOV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Suggestions.tsx"],"sourcesContent":["import { Suggestion } from \"./Suggestion\";\nimport React from \"react\";\nimport { RenderSuggestionsListProps } from \"./props\";\n\nexport function Suggestions({ suggestions, onSuggestionClick }: RenderSuggestionsListProps) {\n return (\n <div className=\"suggestions\">\n {suggestions.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={() => onSuggestionClick(suggestion.message)}\n />\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;AAQQ;AAJD,SAAS,YAAY,EAAE,aAAa,kBAAkB,GAA+B;AAC1F,SACE,oBAAC,SAAI,WAAU,eACZ,sBAAY,IAAI,CAAC,YAAY,UAC5B;AAAA,IAAC;AAAA;AAAA,MAEC,OAAO,WAAW;AAAA,MAClB,SAAS,WAAW;AAAA,MACpB,SAAS,WAAW;AAAA,MACpB,WAAW,WAAW;AAAA,MACtB,SAAS,MAAM,kBAAkB,WAAW,OAAO;AAAA;AAAA,IAL9C;AAAA,EAMP,CACD,GACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-SC6JRFAJ.mjs.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ButtonProps } from './props.js';
|
|
3
3
|
import '@copilotkit/runtime-client-gql';
|
|
4
|
+
import '../../types/suggestions.js';
|
|
4
5
|
import 'react';
|
|
5
6
|
|
|
6
7
|
declare const Button: ({}: ButtonProps) => react_jsx_runtime.JSX.Element;
|
|
@@ -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 { ComponentsMap, AssistantMessageProps, UserMessageProps, MessagesProps, RenderMessageProps, InputProps } from './props.js';
|
|
7
|
+
import { ComponentsMap, AssistantMessageProps, UserMessageProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, InputProps } from './props.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Props for CopilotChat component.
|
|
@@ -112,6 +112,10 @@ interface CopilotChatProps {
|
|
|
112
112
|
* A custom RenderImageMessage component to use instead of the default.
|
|
113
113
|
*/
|
|
114
114
|
RenderImageMessage?: React__default.ComponentType<RenderMessageProps>;
|
|
115
|
+
/**
|
|
116
|
+
* A custom suggestions list component to use instead of the default.
|
|
117
|
+
*/
|
|
118
|
+
RenderSuggestionsList?: React__default.ComponentType<RenderSuggestionsListProps>;
|
|
115
119
|
/**
|
|
116
120
|
* A custom Input component to use instead of the default.
|
|
117
121
|
*/
|
|
@@ -171,7 +175,7 @@ type ImageUpload = {
|
|
|
171
175
|
contentType: string;
|
|
172
176
|
bytes: string;
|
|
173
177
|
};
|
|
174
|
-
declare function CopilotChat({ instructions, onSubmitMessage, makeSystemMessage, onInProgress, onStopGeneration, onReloadMessages, onRegenerate, onCopy, onThumbsUp, onThumbsDown, markdownTagRenderers, Messages, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, RenderImageMessage, Input, className, icons, labels, AssistantMessage, UserMessage, imageUploadsEnabled, inputFileAccept, }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
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;
|
|
175
179
|
declare function WrappedCopilotChat({ children, icons, labels, className, }: {
|
|
176
180
|
children: React__default.ReactNode;
|
|
177
181
|
icons?: CopilotChatIcons;
|
|
@@ -1841,19 +1841,23 @@ function RenderImageMessage(_a) {
|
|
|
1841
1841
|
return null;
|
|
1842
1842
|
}
|
|
1843
1843
|
|
|
1844
|
+
// src/components/chat/Chat.tsx
|
|
1845
|
+
var import_react9 = __toESM(require("react"));
|
|
1846
|
+
var import_react_core7 = require("@copilotkit/react-core");
|
|
1847
|
+
|
|
1844
1848
|
// src/components/chat/Suggestion.tsx
|
|
1845
1849
|
var import_react_core6 = require("@copilotkit/react-core");
|
|
1846
1850
|
var import_shared = require("@copilotkit/shared");
|
|
1847
1851
|
var import_runtime_client_gql3 = require("@copilotkit/runtime-client-gql");
|
|
1848
1852
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1849
|
-
function Suggestion({ title,
|
|
1853
|
+
function Suggestion({ title, onClick, partial, className }) {
|
|
1850
1854
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1851
1855
|
"button",
|
|
1852
1856
|
{
|
|
1853
1857
|
disabled: partial,
|
|
1854
1858
|
onClick: (e) => {
|
|
1855
1859
|
e.preventDefault();
|
|
1856
|
-
onClick(
|
|
1860
|
+
onClick();
|
|
1857
1861
|
},
|
|
1858
1862
|
className: className || (partial ? "suggestion loading" : "suggestion"),
|
|
1859
1863
|
"data-test-id": "suggestion",
|
|
@@ -1932,8 +1936,6 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
|
|
|
1932
1936
|
});
|
|
1933
1937
|
|
|
1934
1938
|
// src/components/chat/Chat.tsx
|
|
1935
|
-
var import_react9 = __toESM(require("react"));
|
|
1936
|
-
var import_react_core7 = require("@copilotkit/react-core");
|
|
1937
1939
|
var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
|
|
1938
1940
|
var import_shared2 = require("@copilotkit/shared");
|
|
1939
1941
|
var import_react_core8 = require("@copilotkit/react-core");
|
|
@@ -2016,8 +2018,24 @@ var ImageUploadQueue = ({
|
|
|
2016
2018
|
);
|
|
2017
2019
|
};
|
|
2018
2020
|
|
|
2019
|
-
// src/components/chat/
|
|
2021
|
+
// src/components/chat/Suggestions.tsx
|
|
2020
2022
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2023
|
+
function Suggestions({ suggestions, onSuggestionClick }) {
|
|
2024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2025
|
+
Suggestion,
|
|
2026
|
+
{
|
|
2027
|
+
title: suggestion.title,
|
|
2028
|
+
message: suggestion.message,
|
|
2029
|
+
partial: suggestion.partial,
|
|
2030
|
+
className: suggestion.className,
|
|
2031
|
+
onClick: () => onSuggestionClick(suggestion.message)
|
|
2032
|
+
},
|
|
2033
|
+
index
|
|
2034
|
+
)) });
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
// src/components/chat/Chat.tsx
|
|
2038
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2021
2039
|
function CopilotChat({
|
|
2022
2040
|
instructions,
|
|
2023
2041
|
onSubmitMessage,
|
|
@@ -2036,6 +2054,7 @@ function CopilotChat({
|
|
|
2036
2054
|
RenderAgentStateMessage: RenderAgentStateMessage2 = RenderAgentStateMessage,
|
|
2037
2055
|
RenderResultMessage: RenderResultMessage2 = RenderResultMessage,
|
|
2038
2056
|
RenderImageMessage: RenderImageMessage2 = RenderImageMessage,
|
|
2057
|
+
RenderSuggestionsList = Suggestions,
|
|
2039
2058
|
Input: Input2 = Input,
|
|
2040
2059
|
className,
|
|
2041
2060
|
icons,
|
|
@@ -2175,8 +2194,8 @@ function CopilotChat({
|
|
|
2175
2194
|
const removeSelectedImage = (index) => {
|
|
2176
2195
|
setSelectedImages((prev) => prev.filter((_, i) => i !== index));
|
|
2177
2196
|
};
|
|
2178
|
-
return /* @__PURE__ */ (0,
|
|
2179
|
-
/* @__PURE__ */ (0,
|
|
2197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
|
|
2198
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2180
2199
|
Messages2,
|
|
2181
2200
|
{
|
|
2182
2201
|
AssistantMessage: AssistantMessage2,
|
|
@@ -2193,22 +2212,18 @@ function CopilotChat({
|
|
|
2193
2212
|
onThumbsUp,
|
|
2194
2213
|
onThumbsDown,
|
|
2195
2214
|
markdownTagRenderers,
|
|
2196
|
-
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0,
|
|
2197
|
-
|
|
2215
|
+
children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2216
|
+
RenderSuggestionsList,
|
|
2198
2217
|
{
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
onClick: (message) => handleSendMessage(message)
|
|
2204
|
-
},
|
|
2205
|
-
index
|
|
2206
|
-
)) })
|
|
2218
|
+
onSuggestionClick: handleSendMessage,
|
|
2219
|
+
suggestions: currentSuggestions
|
|
2220
|
+
}
|
|
2221
|
+
)
|
|
2207
2222
|
}
|
|
2208
2223
|
),
|
|
2209
|
-
imageUploadsEnabled && /* @__PURE__ */ (0,
|
|
2210
|
-
/* @__PURE__ */ (0,
|
|
2211
|
-
/* @__PURE__ */ (0,
|
|
2224
|
+
imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
2225
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2212
2227
|
"input",
|
|
2213
2228
|
{
|
|
2214
2229
|
type: "file",
|
|
@@ -2220,7 +2235,7 @@ function CopilotChat({
|
|
|
2220
2235
|
}
|
|
2221
2236
|
)
|
|
2222
2237
|
] }),
|
|
2223
|
-
/* @__PURE__ */ (0,
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2224
2239
|
Input2,
|
|
2225
2240
|
{
|
|
2226
2241
|
inProgress: isLoading,
|
|
@@ -2243,10 +2258,10 @@ function WrappedCopilotChat({
|
|
|
2243
2258
|
}) {
|
|
2244
2259
|
const chatContext = import_react9.default.useContext(ChatContext);
|
|
2245
2260
|
if (!chatContext) {
|
|
2246
|
-
return /* @__PURE__ */ (0,
|
|
2247
|
-
}, children: /* @__PURE__ */ (0,
|
|
2261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
|
|
2262
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
|
|
2248
2263
|
}
|
|
2249
|
-
return /* @__PURE__ */ (0,
|
|
2264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
|
|
2250
2265
|
}
|
|
2251
2266
|
var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
|
|
2252
2267
|
var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage, onStopGeneration, onReloadMessages) => {
|