@copilotkit/react-ui 1.8.0-next.6 → 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.
Files changed (90) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{chunk-FBYETUFL.mjs → chunk-5M7ODWKH.mjs} +6 -12
  3. package/dist/chunk-5M7ODWKH.mjs.map +1 -0
  4. package/dist/{chunk-DFHFPZQD.mjs → chunk-EMWOZVCW.mjs} +9 -16
  5. package/dist/chunk-EMWOZVCW.mjs.map +1 -0
  6. package/dist/{chunk-Z6YOBQUJ.mjs → chunk-HGA4N4ME.mjs} +8 -13
  7. package/dist/chunk-HGA4N4ME.mjs.map +1 -0
  8. package/dist/{chunk-CGVOCLHN.mjs → chunk-P7S3E5UW.mjs} +2 -2
  9. package/dist/{chunk-6H7IQRIU.mjs → chunk-QTN7AYVL.mjs} +2 -2
  10. package/dist/{chunk-LYHZXHTJ.mjs → chunk-SNLHKLW3.mjs} +2 -2
  11. package/dist/{chunk-5JY5QJ2W.mjs → chunk-UN2E3HCK.mjs} +9 -3
  12. package/dist/chunk-UN2E3HCK.mjs.map +1 -0
  13. package/dist/{chunk-FFNESJSG.mjs → chunk-Y6OESC5U.mjs} +2 -2
  14. package/dist/{chunk-QS7UFQFD.mjs → chunk-YGD4IB27.mjs} +2 -2
  15. package/dist/{chunk-VC4NO5QZ.mjs → chunk-YOEL33HG.mjs} +2 -2
  16. package/dist/{chunk-GJME6MK4.mjs → chunk-ZY25LVYR.mjs} +2 -2
  17. package/dist/components/chat/Button.js.map +1 -1
  18. package/dist/components/chat/Button.mjs +2 -2
  19. package/dist/components/chat/Chat.d.ts +2 -11
  20. package/dist/components/chat/Chat.js +67 -76
  21. package/dist/components/chat/Chat.js.map +1 -1
  22. package/dist/components/chat/Chat.mjs +6 -7
  23. package/dist/components/chat/ChatContext.d.ts +15 -0
  24. package/dist/components/chat/ChatContext.js +67 -1
  25. package/dist/components/chat/ChatContext.js.map +1 -1
  26. package/dist/components/chat/ChatContext.mjs +1 -1
  27. package/dist/components/chat/Header.js.map +1 -1
  28. package/dist/components/chat/Header.mjs +2 -2
  29. package/dist/components/chat/Input.js.map +1 -1
  30. package/dist/components/chat/Input.mjs +2 -2
  31. package/dist/components/chat/Messages.js.map +1 -1
  32. package/dist/components/chat/Messages.mjs +2 -2
  33. package/dist/components/chat/Modal.d.ts +1 -1
  34. package/dist/components/chat/Modal.js +74 -87
  35. package/dist/components/chat/Modal.js.map +1 -1
  36. package/dist/components/chat/Modal.mjs +10 -11
  37. package/dist/components/chat/Popup.js +76 -89
  38. package/dist/components/chat/Popup.js.map +1 -1
  39. package/dist/components/chat/Popup.mjs +11 -12
  40. package/dist/components/chat/Sidebar.js +76 -89
  41. package/dist/components/chat/Sidebar.js.map +1 -1
  42. package/dist/components/chat/Sidebar.mjs +11 -12
  43. package/dist/components/chat/Window.js.map +1 -1
  44. package/dist/components/chat/Window.mjs +2 -2
  45. package/dist/components/chat/index.d.ts +1 -1
  46. package/dist/components/chat/index.js +78 -91
  47. package/dist/components/chat/index.js.map +1 -1
  48. package/dist/components/chat/index.mjs +14 -15
  49. package/dist/components/chat/messages/AssistantMessage.js +4 -67
  50. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  51. package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
  52. package/dist/components/chat/props.d.ts +1 -5
  53. package/dist/components/chat/props.js.map +1 -1
  54. package/dist/components/index.d.ts +1 -1
  55. package/dist/components/index.js +78 -91
  56. package/dist/components/index.js.map +1 -1
  57. package/dist/components/index.mjs +14 -15
  58. package/dist/index.css +0 -26
  59. package/dist/index.css.map +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +78 -91
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +15 -16
  64. package/package.json +4 -4
  65. package/src/components/chat/Chat.tsx +0 -16
  66. package/src/components/chat/ChatContext.tsx +25 -0
  67. package/src/components/chat/Modal.tsx +0 -6
  68. package/src/components/chat/messages/AssistantMessage.tsx +4 -5
  69. package/src/components/chat/props.ts +0 -5
  70. package/src/styles.css +0 -1
  71. package/dist/chunk-5JY5QJ2W.mjs.map +0 -1
  72. package/dist/chunk-DFHFPZQD.mjs.map +0 -1
  73. package/dist/chunk-FBYETUFL.mjs.map +0 -1
  74. package/dist/chunk-UZTZXMYS.mjs +0 -18
  75. package/dist/chunk-UZTZXMYS.mjs.map +0 -1
  76. package/dist/chunk-Z6YOBQUJ.mjs.map +0 -1
  77. package/dist/components/chat/Response.d.ts +0 -7
  78. package/dist/components/chat/Response.js +0 -64
  79. package/dist/components/chat/Response.js.map +0 -1
  80. package/dist/components/chat/Response.mjs +0 -10
  81. package/dist/components/chat/Response.mjs.map +0 -1
  82. package/src/components/chat/Response.tsx +0 -12
  83. package/src/css/response.css +0 -26
  84. /package/dist/{chunk-CGVOCLHN.mjs.map → chunk-P7S3E5UW.mjs.map} +0 -0
  85. /package/dist/{chunk-6H7IQRIU.mjs.map → chunk-QTN7AYVL.mjs.map} +0 -0
  86. /package/dist/{chunk-LYHZXHTJ.mjs.map → chunk-SNLHKLW3.mjs.map} +0 -0
  87. /package/dist/{chunk-FFNESJSG.mjs.map → chunk-Y6OESC5U.mjs.map} +0 -0
  88. /package/dist/{chunk-QS7UFQFD.mjs.map → chunk-YGD4IB27.mjs.map} +0 -0
  89. /package/dist/{chunk-VC4NO5QZ.mjs.map → chunk-YOEL33HG.mjs.map} +0 -0
  90. /package/dist/{chunk-GJME6MK4.mjs.map → chunk-ZY25LVYR.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,18 +1,17 @@
1
1
  "use client";
2
2
  import "./chunk-EFZPSZWO.mjs";
3
- import "./chunk-IU3WTXLQ.mjs";
4
3
  import "./chunk-MMVDU6DF.mjs";
5
4
  import "./chunk-SQMEPWVT.mjs";
6
- import {
7
- CopilotSidebar
8
- } from "./chunk-FFNESJSG.mjs";
9
5
  import "./chunk-WB3YULQ4.mjs";
10
6
  import {
11
7
  CopilotPopup
12
- } from "./chunk-6H7IQRIU.mjs";
13
- import "./chunk-DFHFPZQD.mjs";
14
- import "./chunk-CGVOCLHN.mjs";
15
- import "./chunk-QS7UFQFD.mjs";
8
+ } from "./chunk-QTN7AYVL.mjs";
9
+ import {
10
+ CopilotSidebar
11
+ } from "./chunk-Y6OESC5U.mjs";
12
+ import "./chunk-EMWOZVCW.mjs";
13
+ import "./chunk-P7S3E5UW.mjs";
14
+ import "./chunk-YGD4IB27.mjs";
16
15
  import "./chunk-V7W6IM2V.mjs";
17
16
  import {
18
17
  CopilotDevConsole
@@ -24,11 +23,10 @@ import "./chunk-KXE2JCUH.mjs";
24
23
  import "./chunk-YC4NBUGE.mjs";
25
24
  import "./chunk-BH6PCAAL.mjs";
26
25
  import "./chunk-OTPAZXVR.mjs";
27
- import "./chunk-VC4NO5QZ.mjs";
26
+ import "./chunk-YOEL33HG.mjs";
28
27
  import {
29
28
  CopilotChat
30
- } from "./chunk-Z6YOBQUJ.mjs";
31
- import "./chunk-UWWMAJ7R.mjs";
29
+ } from "./chunk-HGA4N4ME.mjs";
32
30
  import "./chunk-WEYDZBT7.mjs";
33
31
  import "./chunk-7RIBDD4K.mjs";
34
32
  import {
@@ -36,21 +34,22 @@ import {
36
34
  } from "./chunk-HEIDCT7I.mjs";
37
35
  import {
38
36
  AssistantMessage
39
- } from "./chunk-FBYETUFL.mjs";
37
+ } from "./chunk-5M7ODWKH.mjs";
40
38
  import "./chunk-XB6QCUPB.mjs";
39
+ import "./chunk-UWWMAJ7R.mjs";
41
40
  import "./chunk-TOQ7P4DO.mjs";
42
- import "./chunk-LYHZXHTJ.mjs";
41
+ import "./chunk-SNLHKLW3.mjs";
43
42
  import "./chunk-YQFVRDNC.mjs";
44
43
  import {
45
44
  Markdown
46
45
  } from "./chunk-XNQO5AZZ.mjs";
47
- import "./chunk-GJME6MK4.mjs";
48
- import "./chunk-UZTZXMYS.mjs";
46
+ import "./chunk-ZY25LVYR.mjs";
49
47
  import {
50
48
  useChatContext
51
- } from "./chunk-5JY5QJ2W.mjs";
49
+ } from "./chunk-UN2E3HCK.mjs";
52
50
  import "./chunk-PCTCOQK2.mjs";
53
51
  import "./chunk-ORSMX3SE.mjs";
52
+ import "./chunk-IU3WTXLQ.mjs";
54
53
  import "./chunk-T26KLXLH.mjs";
55
54
  import {
56
55
  useCopilotChatSuggestions
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
- "version": "1.8.0-next.6",
12
+ "version": "1.8.0-next.7",
13
13
  "sideEffects": [
14
14
  "**/*.css"
15
15
  ],
@@ -50,9 +50,9 @@
50
50
  "react-syntax-highlighter": "^15.5.0",
51
51
  "remark-gfm": "^3.0.1",
52
52
  "remark-math": "^5.1.1",
53
- "@copilotkit/react-core": "1.8.0-next.6",
54
- "@copilotkit/runtime-client-gql": "1.8.0-next.6",
55
- "@copilotkit/shared": "1.8.0-next.6"
53
+ "@copilotkit/react-core": "1.8.0-next.7",
54
+ "@copilotkit/runtime-client-gql": "1.8.0-next.7",
55
+ "@copilotkit/shared": "1.8.0-next.7"
56
56
  },
57
57
  "keywords": [
58
58
  "copilotkit",
@@ -53,7 +53,6 @@ import {
53
53
  } from "./ChatContext";
54
54
  import { Messages as DefaultMessages } from "./Messages";
55
55
  import { Input as DefaultInput } from "./Input";
56
- import { ResponseButton as DefaultResponseButton } from "./Response";
57
56
  import { RenderTextMessage as DefaultRenderTextMessage } from "./messages/RenderTextMessage";
58
57
  import { RenderActionExecutionMessage as DefaultRenderActionExecutionMessage } from "./messages/RenderActionExecutionMessage";
59
58
  import { RenderResultMessage as DefaultRenderResultMessage } from "./messages/RenderResultMessage";
@@ -77,11 +76,9 @@ import {
77
76
  InputProps,
78
77
  MessagesProps,
79
78
  RenderMessageProps,
80
- ResponseButtonProps,
81
79
  UserMessageProps,
82
80
  } from "./props";
83
81
 
84
- import { CopilotDevConsole } from "../dev-console";
85
82
  import { HintFunction, runAgent, stopAgent } from "@copilotkit/react-core";
86
83
 
87
84
  /**
@@ -156,12 +153,6 @@ export interface CopilotChatProps {
156
153
  */
157
154
  makeSystemMessage?: SystemMessageFunction;
158
155
 
159
- /**
160
- * Whether to show the response button.
161
- * @default true
162
- */
163
- showResponseButton?: boolean;
164
-
165
156
  /**
166
157
  * A custom assistant message component to use instead of the default.
167
158
  */
@@ -202,11 +193,6 @@ export interface CopilotChatProps {
202
193
  */
203
194
  Input?: React.ComponentType<InputProps>;
204
195
 
205
- /**
206
- * A custom ResponseButton component to use instead of the default.
207
- */
208
- ResponseButton?: React.ComponentType<ResponseButtonProps>;
209
-
210
196
  /**
211
197
  * A class name to apply to the root element.
212
198
  */
@@ -270,7 +256,6 @@ export function CopilotChat({
270
256
  instructions,
271
257
  onSubmitMessage,
272
258
  makeSystemMessage,
273
- showResponseButton = true,
274
259
  onInProgress,
275
260
  onStopGeneration,
276
261
  onReloadMessages,
@@ -284,7 +269,6 @@ export function CopilotChat({
284
269
  RenderAgentStateMessage = DefaultRenderAgentStateMessage,
285
270
  RenderResultMessage = DefaultRenderResultMessage,
286
271
  Input = DefaultInput,
287
- ResponseButton = DefaultResponseButton,
288
272
  className,
289
273
  icons,
290
274
  labels,
@@ -1,5 +1,6 @@
1
1
  import React, { useMemo, useState } from "react";
2
2
  import * as DefaultIcons from "./Icons";
3
+ import { ThumbsDownIcon, ThumbsUpIcon } from "./Icons";
3
4
 
4
5
  /**
5
6
  * Icons for CopilotChat component.
@@ -59,6 +60,27 @@ export interface CopilotChatIcons {
59
60
  */
60
61
 
61
62
  pushToTalkIcon?: React.ReactNode;
63
+
64
+ /**
65
+ * The icons to use for copy assistant response
66
+ * @default <CopyIcon />
67
+ */
68
+
69
+ copyIcon?: React.ReactNode;
70
+
71
+ /**
72
+ * The icon to use for thumbs up/response approval.
73
+ * @default <ThumbsUpIcon />
74
+ */
75
+
76
+ thumbsUpIcon?: React.ReactNode;
77
+
78
+ /**
79
+ * The icon to use for thumbs down/response rejection.
80
+ * @default <ThumbsDownIcon />
81
+ */
82
+
83
+ thumbsDownIcon?: React.ReactNode;
62
84
  }
63
85
 
64
86
  /**
@@ -196,6 +218,9 @@ export const ChatContextProvider = ({
196
218
  stopIcon: DefaultIcons.StopIcon,
197
219
  regenerateIcon: DefaultIcons.RegenerateIcon,
198
220
  pushToTalkIcon: DefaultIcons.MicrophoneIcon,
221
+ copyIcon: DefaultIcons.CopyIcon,
222
+ thumbsUpIcon: DefaultIcons.ThumbsUpIcon,
223
+ thumbsDownIcon: DefaultIcons.ThumbsDownIcon,
199
224
  },
200
225
  ...icons,
201
226
  }),
@@ -6,9 +6,7 @@ import { Button as DefaultButton } from "./Button";
6
6
  import { Header as DefaultHeader } from "./Header";
7
7
  import { Messages as DefaultMessages } from "./Messages";
8
8
  import { Input as DefaultInput } from "./Input";
9
- import { ResponseButton as DefaultResponseButton } from "./Response";
10
9
  import { CopilotChat, CopilotChatProps } from "./Chat";
11
- import { Markdown as DefaultRenderer } from "./Markdown";
12
10
  import { AssistantMessage as DefaultAssistantMessage } from "./messages/AssistantMessage";
13
11
  import { UserMessage as DefaultUserMessage } from "./messages/UserMessage";
14
12
 
@@ -72,14 +70,12 @@ export const CopilotModal = ({
72
70
  icons,
73
71
  labels,
74
72
  makeSystemMessage,
75
- showResponseButton = true,
76
73
  onInProgress,
77
74
  Window = DefaultWindow,
78
75
  Button = DefaultButton,
79
76
  Header = DefaultHeader,
80
77
  Messages = DefaultMessages,
81
78
  Input = DefaultInput,
82
- ResponseButton = DefaultResponseButton,
83
79
  AssistantMessage = DefaultAssistantMessage,
84
80
  UserMessage = DefaultUserMessage,
85
81
  className,
@@ -109,11 +105,9 @@ export const CopilotModal = ({
109
105
  onStopGeneration={onStopGeneration}
110
106
  onReloadMessages={onReloadMessages}
111
107
  makeSystemMessage={makeSystemMessage}
112
- showResponseButton={showResponseButton}
113
108
  onInProgress={onInProgress}
114
109
  Messages={Messages}
115
110
  Input={Input}
116
- ResponseButton={ResponseButton}
117
111
  AssistantMessage={AssistantMessage}
118
112
  UserMessage={UserMessage}
119
113
  />
@@ -1,7 +1,6 @@
1
1
  import { AssistantMessageProps } from "../props";
2
2
  import { useChatContext } from "../ChatContext";
3
3
  import { Markdown } from "../Markdown";
4
- import { RegenerateIcon, CopyIcon, ThumbsUpIcon, ThumbsDownIcon } from "../Icons";
5
4
  import { useState } from "react";
6
5
 
7
6
  export const AssistantMessage = (props: AssistantMessageProps) => {
@@ -68,7 +67,7 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
68
67
  aria-label={labels.regenerateResponse}
69
68
  title={labels.regenerateResponse}
70
69
  >
71
- {RegenerateIcon}
70
+ {icons.regenerateIcon}
72
71
  </button>
73
72
  <button
74
73
  className="copilotKitMessageControlButton"
@@ -79,7 +78,7 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
79
78
  {copied ? (
80
79
  <span style={{ fontSize: "10px", fontWeight: "bold" }}>✓</span>
81
80
  ) : (
82
- CopyIcon
81
+ icons.copyIcon
83
82
  )}
84
83
  </button>
85
84
  {onThumbsUp && (
@@ -89,7 +88,7 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
89
88
  aria-label={labels.thumbsUp}
90
89
  title={labels.thumbsUp}
91
90
  >
92
- {ThumbsUpIcon}
91
+ {icons.thumbsUpIcon}
93
92
  </button>
94
93
  )}
95
94
  {onThumbsDown && (
@@ -99,7 +98,7 @@ export const AssistantMessage = (props: AssistantMessageProps) => {
99
98
  aria-label={labels.thumbsDown}
100
99
  title={labels.thumbsDown}
101
100
  >
102
- {ThumbsDownIcon}
101
+ {icons.thumbsDownIcon}
103
102
  </button>
104
103
  )}
105
104
  </div>
@@ -151,8 +151,3 @@ export interface InputProps {
151
151
  isVisible?: boolean;
152
152
  onStop?: () => void;
153
153
  }
154
-
155
- export interface ResponseButtonProps {
156
- onClick: () => void;
157
- inProgress: boolean;
158
- }
package/src/styles.css CHANGED
@@ -7,7 +7,6 @@
7
7
  @import "./css/messages.css";
8
8
  @import "./css/window.css";
9
9
  @import "./css/animations.css";
10
- @import "./css/response.css";
11
10
  @import "./css/markdown.css";
12
11
  @import "./css/suggestions.css";
13
12
  @import "./css/panel.css";
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/ChatContext.tsx"],"sourcesContent":["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,OAAO,SAAS,eAAyB;AAsNhC;AAhFF,IAAM,cAAc,MAAM,cAAuC,MAAS;AAE1E,SAAS,iBAA8B;AAC5C,QAAM,UAAU,MAAM,WAAW,WAAW;AAC5C,MAAI,YAAY,QAAW;AACzB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAaO,IAAM,sBAAsB,CAAC;AAAA;AAAA;AAAA;AAAA,EAIlC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAwB;AACtB,QAAM,iBAAiB;AAAA,IACrB,MAAO,kCACF;AAAA,MACD,SAAS;AAAA,MACT,OAAO;AAAA,MACP,aAAa;AAAA,MACb,OAAO;AAAA,MACP,gBAAgB;AAAA,MAChB,oBAAoB;AAAA,MACpB,iBAAiB;AAAA,MACjB,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,QAAQ;AAAA,IACV,IACG;AAAA,IAEL,CAAC,MAAM;AAAA,EACT;AAEA,QAAM,gBAAgB;AAAA,IACpB,MAAO,kCACF;AAAA,MACD,UAAuB;AAAA,MACvB,WAAwB;AAAA,MACxB,iBAA8B;AAAA,MAC9B,UAAuB;AAAA,MACvB,cAA2B;AAAA,MAC3B,aAA0B;AAAA,MAC1B,UAAuB;AAAA,MACvB,gBAA6B;AAAA,MAC7B,gBAA6B;AAAA,IAC/B,IACG;AAAA,IAEL,CAAC,KAAK;AAAA,EACR;AAEA,QAAM,UAAU;AAAA,IACd,OAAO;AAAA,MACL,QAAQ;AAAA,MACR,OAAO;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB,eAAe,MAAM,OAAO;AAAA,EAC/C;AAEA,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,SAAU,UAAS;AACzD;","names":[]}
@@ -1 +0,0 @@
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 { ResponseButton as DefaultResponseButton } from \"./Response\";\nimport { CopilotChat, CopilotChatProps } from \"./Chat\";\nimport { Markdown as DefaultRenderer } from \"./Markdown\";\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 showResponseButton = true,\n onInProgress,\n Window = DefaultWindow,\n Button = DefaultButton,\n Header = DefaultHeader,\n Messages = DefaultMessages,\n Input = DefaultInput,\n ResponseButton = DefaultResponseButton,\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 showResponseButton={showResponseButton}\n onInProgress={onInProgress}\n Messages={Messages}\n Input={Input}\n ResponseButton={ResponseButton}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n />\n </Window>\n </div>\n </ChatContextProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAkGV,cACA,YADA;AArCD,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,qBAAqB;AAAA,EACrB;AAAA,EACA,QAAAA,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,QAAAC,UAAS;AAAA,EACT,UAAAC,YAAW;AAAA,EACX,OAAAC,SAAQ;AAAA,EACR,gBAAAC,kBAAiB;AAAA,EACjB,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,0BAACN,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;AAAA,gBACA,UAAUC;AAAA,gBACV,OAAOC;AAAA,gBACP,gBAAgBC;AAAA,gBAChB,kBAAkBC;AAAA,gBAClB,aAAaC;AAAA;AAAA,YACf;AAAA;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KACF;AAEJ;","names":["Window","Button","Header","Messages","Input","ResponseButton","AssistantMessage","UserMessage"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/messages/AssistantMessage.tsx"],"sourcesContent":["import { AssistantMessageProps } from \"../props\";\nimport { useChatContext } from \"../ChatContext\";\nimport { Markdown } from \"../Markdown\";\nimport { RegenerateIcon, CopyIcon, ThumbsUpIcon, ThumbsDownIcon } from \"../Icons\";\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 {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 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 {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 {ThumbsDownIcon}\n </button>\n )}\n </div>\n )}\n </div>\n )}\n <div style={{ marginBottom: \"0.5r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AA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAY,OAAO;AAAA,gBACnB,OAAO,OAAO;AAAA,gBAEb;AAAA;AAAA,YACH;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAY,OAAO;AAAA,gBACnB,OAAO,OAAO;AAAA,gBAEb,mBACC,oBAAC,UAAK,OAAO,EAAE,UAAU,QAAQ,YAAY,OAAO,GAAG,oBAAC,IAExD;AAAA;AAAA,YAEJ;AAAA,YACC,cACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAY,OAAO;AAAA,gBACnB,OAAO,OAAO;AAAA,gBAEb;AAAA;AAAA,YACH;AAAA,YAED,gBACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,cAAY,OAAO;AAAA,gBACnB,OAAO,OAAO;AAAA,gBAEb;AAAA;AAAA,YACH;AAAA;AAAA;AAAA,MAEJ;AAAA,OAEJ;AAAA,IAEF,oBAAC,SAAI,OAAO,EAAE,cAAc,SAAS,GAAI,wBAAa;AAAA,KACxD;AAEJ;","names":[]}
@@ -1,18 +0,0 @@
1
- import {
2
- useChatContext
3
- } from "./chunk-5JY5QJ2W.mjs";
4
-
5
- // src/components/chat/Response.tsx
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
- var ResponseButton = ({ onClick, inProgress }) => {
8
- const context = useChatContext();
9
- return /* @__PURE__ */ jsxs("button", { onClick, className: "copilotKitResponseButton", children: [
10
- /* @__PURE__ */ jsx("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
11
- inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
12
- ] });
13
- };
14
-
15
- export {
16
- ResponseButton
17
- };
18
- //# sourceMappingURL=chunk-UZTZXMYS.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/chat/Response.tsx"],"sourcesContent":["import { useChatContext } from \"./ChatContext\";\nimport { ResponseButtonProps } from \"./props\";\n\nexport const ResponseButton = ({ onClick, inProgress }: ResponseButtonProps) => {\n const context = useChatContext();\n return (\n <button onClick={onClick} className=\"copilotKitResponseButton\">\n <span>{inProgress ? context.icons.stopIcon : context.icons.regenerateIcon}</span>\n {inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse}\n </button>\n );\n};\n"],"mappings":";;;;;AAMI,SACE,KADF;AAHG,IAAM,iBAAiB,CAAC,EAAE,SAAS,WAAW,MAA2B;AAC9E,QAAM,UAAU,eAAe;AAC/B,SACE,qBAAC,YAAO,SAAkB,WAAU,4BAClC;AAAA,wBAAC,UAAM,uBAAa,QAAQ,MAAM,WAAW,QAAQ,MAAM,gBAAe;AAAA,IACzE,aAAa,QAAQ,OAAO,iBAAiB,QAAQ,OAAO;AAAA,KAC/D;AAEJ;","names":[]}
@@ -1 +0,0 @@
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 { ResponseButton as DefaultResponseButton } from \"./Response\";\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 ResponseButtonProps,\n UserMessageProps,\n} from \"./props\";\n\nimport { CopilotDevConsole } from \"../dev-console\";\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 * Whether to show the response button.\n * @default true\n */\n showResponseButton?: boolean;\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 custom ResponseButton component to use instead of the default.\n */\n ResponseButton?: React.ComponentType<ResponseButtonProps>;\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 showResponseButton = true,\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 ResponseButton = DefaultResponseButton,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAkB,MAAM,mBAAmB;AAC3C,SAAS,gBAAgB;AAWzB,SAAuB,UAAU,iBAAiB;AA6Q9C,SA2DK,UAzCK,KAlBV;AArFG,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB;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,gBAAAC,kBAAiB;AAAA,EACjB;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,C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A,MACF;AAAA,IACF;AAAA,EACF;AACA,QAAM,mBAAmB,MAAM;AAC7B,QAAI,eAAe,cAAc;AAC/B,gBAAU,eAAe,aAAa,WAAW,OAAO;AAAA,IAC1D;AAAA,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","ResponseButton","AssistantMessage","UserMessage","_a"]}
@@ -1,7 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ResponseButtonProps } from './props.js';
3
- import '@copilotkit/runtime-client-gql';
4
-
5
- declare const ResponseButton: ({ onClick, inProgress }: ResponseButtonProps) => react_jsx_runtime.JSX.Element;
6
-
7
- export { ResponseButton };
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/components/chat/Response.tsx
31
- var Response_exports = {};
32
- __export(Response_exports, {
33
- ResponseButton: () => ResponseButton
34
- });
35
- module.exports = __toCommonJS(Response_exports);
36
-
37
- // src/components/chat/ChatContext.tsx
38
- var import_react = __toESM(require("react"));
39
- var import_jsx_runtime = require("react/jsx-runtime");
40
- var ChatContext = import_react.default.createContext(void 0);
41
- function useChatContext() {
42
- const context = import_react.default.useContext(ChatContext);
43
- if (context === void 0) {
44
- throw new Error(
45
- "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
46
- );
47
- }
48
- return context;
49
- }
50
-
51
- // src/components/chat/Response.tsx
52
- var import_jsx_runtime2 = require("react/jsx-runtime");
53
- var ResponseButton = ({ onClick, inProgress }) => {
54
- const context = useChatContext();
55
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { onClick, className: "copilotKitResponseButton", children: [
56
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
57
- inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
58
- ] });
59
- };
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- ResponseButton
63
- });
64
- //# sourceMappingURL=Response.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/chat/Response.tsx","../../../src/components/chat/ChatContext.tsx"],"sourcesContent":["import { useChatContext } from \"./ChatContext\";\nimport { ResponseButtonProps } from \"./props\";\n\nexport const ResponseButton = ({ onClick, inProgress }: ResponseButtonProps) => {\n const context = useChatContext();\n return (\n <button onClick={onClick} className=\"copilotKitResponseButton\">\n <span>{inProgress ? context.icons.stopIcon : context.icons.regenerateIcon}</span>\n {inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse}\n </button>\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;AAsNhC;AAhFF,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;;;AD1II,IAAAC,sBAAA;AAHG,IAAM,iBAAiB,CAAC,EAAE,SAAS,WAAW,MAA2B;AAC9E,QAAM,UAAU,eAAe;AAC/B,SACE,8CAAC,YAAO,SAAkB,WAAU,4BAClC;AAAA,iDAAC,UAAM,uBAAa,QAAQ,MAAM,WAAW,QAAQ,MAAM,gBAAe;AAAA,IACzE,aAAa,QAAQ,OAAO,iBAAiB,QAAQ,OAAO;AAAA,KAC/D;AAEJ;","names":["React","import_jsx_runtime"]}
@@ -1,10 +0,0 @@
1
- import {
2
- ResponseButton
3
- } from "../../chunk-UZTZXMYS.mjs";
4
- import "../../chunk-5JY5QJ2W.mjs";
5
- import "../../chunk-ORSMX3SE.mjs";
6
- import "../../chunk-MRXNTQOX.mjs";
7
- export {
8
- ResponseButton
9
- };
10
- //# sourceMappingURL=Response.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,12 +0,0 @@
1
- import { useChatContext } from "./ChatContext";
2
- import { ResponseButtonProps } from "./props";
3
-
4
- export const ResponseButton = ({ onClick, inProgress }: ResponseButtonProps) => {
5
- const context = useChatContext();
6
- return (
7
- <button onClick={onClick} className="copilotKitResponseButton">
8
- <span>{inProgress ? context.icons.stopIcon : context.icons.regenerateIcon}</span>
9
- {inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse}
10
- </button>
11
- );
12
- };
@@ -1,26 +0,0 @@
1
- .copilotKitResponseButton {
2
- background-color: var(--copilot-kit-response-button-background-color);
3
- border: 1px solid var(--copilot-kit-separator-color);
4
- border-radius: 4px;
5
- color: var(--copilot-kit-response-button-color);
6
- cursor: pointer;
7
- font-size: 14px;
8
- font-weight: 500;
9
- height: 32px;
10
- line-height: 30px;
11
- margin: 0;
12
- padding: 0 16px;
13
- text-align: center;
14
- text-decoration: none;
15
- text-transform: none;
16
- white-space: nowrap;
17
- margin-top: 15px;
18
- }
19
-
20
- .copilotKitResponseButton:hover {
21
- filter: brightness(95%);
22
- }
23
-
24
- .copilotKitResponseButton > span {
25
- margin-right: 0.5rem;
26
- }