@copilotkit/react-ui 1.0.3 → 1.0.4

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 (56) hide show
  1. package/.turbo/turbo-build.log +44 -44
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +1 -1
  4. package/dist/{chunk-DYXI54LF.mjs → chunk-4Z2WDXSK.mjs} +1 -1
  5. package/dist/chunk-4Z2WDXSK.mjs.map +1 -0
  6. package/dist/{chunk-MHTQKDHI.mjs → chunk-5BL3YDGU.mjs} +4 -4
  7. package/dist/chunk-5BL3YDGU.mjs.map +1 -0
  8. package/dist/{chunk-ADMZDZCJ.mjs → chunk-DYHXNV2B.mjs} +2 -2
  9. package/dist/{chunk-2K5GFKKP.mjs → chunk-OLL5TU65.mjs} +3 -3
  10. package/dist/{chunk-NYDX3JVD.mjs → chunk-QHAVUMXM.mjs} +2 -2
  11. package/dist/{chunk-LTCJCXCP.mjs → chunk-RMK4ADB6.mjs} +3 -3
  12. package/dist/{chunk-LTCJCXCP.mjs.map → chunk-RMK4ADB6.mjs.map} +1 -1
  13. package/dist/components/chat/Chat.js +2 -2
  14. package/dist/components/chat/Chat.js.map +1 -1
  15. package/dist/components/chat/Chat.mjs +2 -2
  16. package/dist/components/chat/Messages.js.map +1 -1
  17. package/dist/components/chat/Messages.mjs +1 -1
  18. package/dist/components/chat/Modal.js +2 -2
  19. package/dist/components/chat/Modal.js.map +1 -1
  20. package/dist/components/chat/Modal.mjs +3 -3
  21. package/dist/components/chat/Popup.js +2 -2
  22. package/dist/components/chat/Popup.js.map +1 -1
  23. package/dist/components/chat/Popup.mjs +4 -4
  24. package/dist/components/chat/Sidebar.js +2 -2
  25. package/dist/components/chat/Sidebar.js.map +1 -1
  26. package/dist/components/chat/Sidebar.mjs +4 -4
  27. package/dist/components/chat/index.js +2 -2
  28. package/dist/components/chat/index.js.map +1 -1
  29. package/dist/components/chat/index.mjs +5 -5
  30. package/dist/components/index.js +2 -2
  31. package/dist/components/index.js.map +1 -1
  32. package/dist/components/index.mjs +5 -5
  33. package/dist/hooks/index.js +2 -2
  34. package/dist/hooks/index.js.map +1 -1
  35. package/dist/hooks/index.mjs +1 -1
  36. package/dist/hooks/use-copilot-chat-suggestions.js +2 -2
  37. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
  38. package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
  39. package/dist/index.js +4 -4
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +6 -6
  42. package/dist/lib/utils.d.ts +1 -2
  43. package/dist/lib/utils.js +2 -9
  44. package/dist/lib/utils.js.map +1 -1
  45. package/dist/lib/utils.mjs +1 -7
  46. package/dist/lib/utils.mjs.map +1 -1
  47. package/package.json +7 -8
  48. package/src/components/chat/Chat.tsx +2 -2
  49. package/src/components/chat/Messages.tsx +0 -1
  50. package/src/hooks/use-copilot-chat-suggestions.tsx +3 -4
  51. package/src/lib/utils.ts +0 -7
  52. package/dist/chunk-DYXI54LF.mjs.map +0 -1
  53. package/dist/chunk-MHTQKDHI.mjs.map +0 -1
  54. /package/dist/{chunk-ADMZDZCJ.mjs.map → chunk-DYHXNV2B.mjs.map} +0 -0
  55. /package/dist/{chunk-2K5GFKKP.mjs.map → chunk-OLL5TU65.mjs.map} +0 -0
  56. /package/dist/{chunk-NYDX3JVD.mjs.map → chunk-QHAVUMXM.mjs.map} +0 -0
@@ -1,5 +1,5 @@
1
1
 
2
- > @copilotkit/react-ui@1.0.3 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-ui
2
+ > @copilotkit/react-ui@1.0.4 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-ui
3
3
  > tsup --clean
4
4
 
5
5
  CLI Building entry: src/index.tsx, src/components/index.ts, src/context/index.ts, src/hooks/index.ts, src/hooks/use-copilot-chat-suggestions.tsx, src/hooks/use-copy-to-clipboard.tsx, src/hooks/use-push-to-talk.tsx, src/lib/utils.test.ts, src/lib/utils.ts, src/types/css.ts, src/types/index.ts, src/types/suggestions.ts, src/components/chat/Button.tsx, src/components/chat/Chat.tsx, src/components/chat/ChatContext.tsx, src/components/chat/CodeBlock.tsx, src/components/chat/Header.tsx, src/components/chat/Icons.tsx, src/components/chat/Input.tsx, src/components/chat/Markdown.tsx, src/components/chat/Messages.tsx, src/components/chat/Modal.tsx, src/components/chat/Popup.tsx, src/components/chat/Response.tsx, src/components/chat/Sidebar.tsx, src/components/chat/Suggestion.tsx, src/components/chat/Textarea.tsx, src/components/chat/Window.tsx, src/components/chat/index.tsx, src/components/chat/props.ts
@@ -18,18 +18,18 @@
18
18
  ESM dist/chunk-EFZPSZWO.mjs 43.00 B
19
19
  ESM dist/chunk-JD7BAH7U.mjs 43.00 B
20
20
  ESM dist/chunk-MRFF7GSQ.mjs 43.00 B
21
- ESM dist/chunk-NYDX3JVD.mjs 1.02 KB
21
+ ESM dist/chunk-QHAVUMXM.mjs 1.02 KB
22
22
  ESM dist/chunk-WB3YULQ4.mjs 43.00 B
23
- ESM dist/chunk-ADMZDZCJ.mjs 573.00 B
24
- ESM dist/chunk-2K5GFKKP.mjs 2.17 KB
23
+ ESM dist/chunk-DYHXNV2B.mjs 573.00 B
24
+ ESM dist/chunk-OLL5TU65.mjs 2.17 KB
25
25
  ESM dist/chunk-B7DNOYVQ.mjs 3.80 KB
26
26
  ESM dist/chunk-SE6DAYSX.mjs 566.00 B
27
27
  ESM dist/chunk-UC3Y7MWX.mjs 825.00 B
28
- ESM dist/chunk-MHTQKDHI.mjs 4.83 KB
28
+ ESM dist/chunk-5BL3YDGU.mjs 4.84 KB
29
29
  ESM dist/chunk-KSCXPA74.mjs 3.75 KB
30
30
  ESM dist/chunk-U6J5DGOE.mjs 2.77 KB
31
31
  ESM dist/chunk-YQFVRDNC.mjs 1.53 KB
32
- ESM dist/chunk-DYXI54LF.mjs 4.59 KB
32
+ ESM dist/chunk-4Z2WDXSK.mjs 4.59 KB
33
33
  ESM dist/chunk-YQ3D5IQV.mjs 2.17 KB
34
34
  ESM dist/chunk-XSUSSWDS.mjs 613.00 B
35
35
  ESM dist/chunk-BJPGMY3I.mjs 1.63 KB
@@ -38,7 +38,7 @@
38
38
  ESM dist/chunk-IU3WTXLQ.mjs 43.00 B
39
39
  ESM dist/chunk-T26KLXLH.mjs 43.00 B
40
40
  ESM dist/hooks/use-copilot-chat-suggestions.mjs 198.00 B
41
- ESM dist/chunk-LTCJCXCP.mjs 713.00 B
41
+ ESM dist/chunk-RMK4ADB6.mjs 729.00 B
42
42
  ESM dist/hooks/use-copy-to-clipboard.mjs 177.00 B
43
43
  ESM dist/chunk-54JAUBUJ.mjs 675.00 B
44
44
  ESM dist/hooks/use-push-to-talk.mjs 290.00 B
@@ -60,7 +60,7 @@
60
60
  ESM dist/components/chat/Modal.mjs 680.00 B
61
61
  ESM dist/components/chat/Popup.mjs 715.00 B
62
62
  ESM dist/components/chat/Response.mjs 232.00 B
63
- ESM dist/lib/utils.mjs 885.00 B
63
+ ESM dist/lib/utils.mjs 730.00 B
64
64
  ESM dist/types/index.mjs 66.00 B
65
65
  ESM dist/types/suggestions.mjs 40.00 B
66
66
  ESM dist/components/chat/Button.mjs 214.00 B
@@ -72,36 +72,36 @@
72
72
  ESM dist/context/index.mjs.map 71.00 B
73
73
  ESM dist/hooks/index.mjs.map 71.00 B
74
74
  ESM dist/lib/utils.test.mjs.map 350.00 B
75
- ESM dist/chunk-EFZPSZWO.mjs.map 71.00 B
76
75
  ESM dist/chunk-JD7BAH7U.mjs.map 71.00 B
77
76
  ESM dist/chunk-MRFF7GSQ.mjs.map 71.00 B
78
- ESM dist/chunk-NYDX3JVD.mjs.map 3.03 KB
77
+ ESM dist/chunk-QHAVUMXM.mjs.map 3.03 KB
79
78
  ESM dist/chunk-WB3YULQ4.mjs.map 71.00 B
80
- ESM dist/chunk-ADMZDZCJ.mjs.map 2.10 KB
81
- ESM dist/chunk-2K5GFKKP.mjs.map 4.36 KB
82
- ESM dist/chunk-B7DNOYVQ.mjs.map 6.70 KB
79
+ ESM dist/chunk-EFZPSZWO.mjs.map 71.00 B
83
80
  ESM dist/chunk-SE6DAYSX.mjs.map 773.00 B
84
81
  ESM dist/chunk-UC3Y7MWX.mjs.map 1.12 KB
85
- ESM dist/chunk-MHTQKDHI.mjs.map 10.98 KB
82
+ ESM dist/chunk-5BL3YDGU.mjs.map 10.99 KB
86
83
  ESM dist/chunk-KSCXPA74.mjs.map 6.16 KB
87
84
  ESM dist/chunk-U6J5DGOE.mjs.map 4.27 KB
88
85
  ESM dist/chunk-YQFVRDNC.mjs.map 2.80 KB
89
- ESM dist/chunk-DYXI54LF.mjs.map 8.24 KB
86
+ ESM dist/chunk-DYHXNV2B.mjs.map 2.10 KB
90
87
  ESM dist/chunk-YQ3D5IQV.mjs.map 3.22 KB
91
88
  ESM dist/chunk-XSUSSWDS.mjs.map 854.00 B
92
89
  ESM dist/chunk-BJPGMY3I.mjs.map 4.85 KB
93
90
  ESM dist/chunk-UPTB2MVO.mjs.map 15.59 KB
94
- ESM dist/chunk-IU3WTXLQ.mjs.map 71.00 B
95
91
  ESM dist/chunk-FZC7X5PK.mjs.map 10.15 KB
92
+ ESM dist/chunk-IU3WTXLQ.mjs.map 71.00 B
96
93
  ESM dist/chunk-T26KLXLH.mjs.map 71.00 B
97
94
  ESM dist/hooks/use-copilot-chat-suggestions.mjs.map 71.00 B
98
- ESM dist/chunk-LTCJCXCP.mjs.map 3.77 KB
95
+ ESM dist/chunk-RMK4ADB6.mjs.map 3.70 KB
99
96
  ESM dist/hooks/use-copy-to-clipboard.mjs.map 71.00 B
100
97
  ESM dist/chunk-54JAUBUJ.mjs.map 1.16 KB
101
98
  ESM dist/hooks/use-push-to-talk.mjs.map 71.00 B
102
99
  ESM dist/chunk-VOBX4JOA.mjs.map 8.53 KB
103
100
  ESM dist/chunk-MRXNTQOX.mjs.map 71.00 B
104
101
  ESM dist/index.css.map 18.25 KB
102
+ ESM dist/chunk-B7DNOYVQ.mjs.map 6.70 KB
103
+ ESM dist/chunk-OLL5TU65.mjs.map 4.36 KB
104
+ ESM dist/chunk-4Z2WDXSK.mjs.map 8.20 KB
105
105
  ESM dist/components/chat/Sidebar.mjs.map 71.00 B
106
106
  ESM dist/types/css.mjs.map 71.00 B
107
107
  ESM dist/components/chat/Suggestion.mjs.map 71.00 B
@@ -117,66 +117,67 @@
117
117
  ESM dist/components/chat/Modal.mjs.map 71.00 B
118
118
  ESM dist/components/chat/Popup.mjs.map 71.00 B
119
119
  ESM dist/components/chat/Response.mjs.map 71.00 B
120
- ESM dist/lib/utils.mjs.map 1.49 KB
120
+ ESM dist/lib/utils.mjs.map 1.24 KB
121
121
  ESM dist/types/index.mjs.map 71.00 B
122
122
  ESM dist/types/suggestions.mjs.map 71.00 B
123
123
  ESM dist/components/chat/Button.mjs.map 71.00 B
124
124
  ESM dist/components/chat/Chat.mjs.map 71.00 B
125
125
  ESM dist/components/chat/ChatContext.mjs.map 71.00 B
126
126
  ESM dist/components/chat/CodeBlock.mjs.map 71.00 B
127
- ESM ⚡️ Build success in 273ms
128
- CJS dist/index.js 56.68 KB
129
- CJS dist/components/index.js 55.92 KB
127
+ ESM ⚡️ Build success in 278ms
128
+ CJS dist/index.js 56.71 KB
129
+ CJS dist/index.css 14.41 KB
130
+ CJS dist/components/index.js 55.94 KB
130
131
  CJS dist/context/index.js 803.00 B
131
- CJS dist/hooks/index.js 1.79 KB
132
- CJS dist/hooks/use-copilot-chat-suggestions.js 1.86 KB
132
+ CJS dist/hooks/index.js 1.80 KB
133
+ CJS dist/hooks/use-copilot-chat-suggestions.js 1.87 KB
133
134
  CJS dist/hooks/use-copy-to-clipboard.js 2.30 KB
134
135
  CJS dist/hooks/use-push-to-talk.js 6.79 KB
135
136
  CJS dist/lib/utils.test.js 182.00 B
136
- CJS dist/lib/utils.js 2.40 KB
137
+ CJS dist/lib/utils.js 2.21 KB
137
138
  CJS dist/types/css.js 789.00 B
138
139
  CJS dist/types/index.js 797.00 B
139
140
  CJS dist/types/suggestions.js 821.00 B
140
141
  CJS dist/components/chat/Button.js 2.91 KB
141
- CJS dist/index.css 14.41 KB
142
- CJS dist/components/chat/Chat.js 47.47 KB
142
+ CJS dist/components/chat/Chat.js 47.49 KB
143
143
  CJS dist/components/chat/ChatContext.js 9.29 KB
144
- CJS dist/components/chat/Header.js 2.63 KB
145
144
  CJS dist/components/chat/CodeBlock.js 14.30 KB
145
+ CJS dist/components/chat/Header.js 2.63 KB
146
146
  CJS dist/components/chat/Icons.js 11.01 KB
147
147
  CJS dist/components/chat/Input.js 11.14 KB
148
148
  CJS dist/components/chat/Markdown.js 16.47 KB
149
149
  CJS dist/components/chat/Messages.js 21.93 KB
150
- CJS dist/components/chat/Modal.js 54.40 KB
150
+ CJS dist/components/chat/Modal.js 54.42 KB
151
+ CJS dist/components/chat/Popup.js 54.86 KB
151
152
  CJS dist/components/chat/Response.js 2.67 KB
152
- CJS dist/components/chat/Popup.js 54.84 KB
153
+ CJS dist/components/chat/Sidebar.js 55.38 KB
153
154
  CJS dist/components/chat/Suggestion.js 6.30 KB
154
155
  CJS dist/components/chat/Textarea.js 2.51 KB
155
156
  CJS dist/components/chat/Window.js 5.46 KB
156
- CJS dist/components/chat/Sidebar.js 55.36 KB
157
+ CJS dist/components/chat/index.js 55.93 KB
157
158
  CJS dist/components/chat/props.js 807.00 B
158
- CJS dist/components/chat/index.js 55.91 KB
159
- CJS dist/index.js.map 97.93 KB
160
- CJS dist/components/index.js.map 94.09 KB
159
+ CJS dist/index.js.map 97.86 KB
160
+ CJS dist/index.css.map 18.25 KB
161
+ CJS dist/components/index.js.map 94.10 KB
161
162
  CJS dist/context/index.js.map 139.00 B
162
- CJS dist/hooks/index.js.map 3.89 KB
163
- CJS dist/hooks/use-copilot-chat-suggestions.js.map 3.80 KB
163
+ CJS dist/hooks/index.js.map 3.82 KB
164
+ CJS dist/hooks/use-copilot-chat-suggestions.js.map 3.74 KB
164
165
  CJS dist/hooks/use-copy-to-clipboard.js.map 1.21 KB
165
166
  CJS dist/hooks/use-push-to-talk.js.map 8.58 KB
166
167
  CJS dist/lib/utils.test.js.map 352.00 B
167
- CJS dist/lib/utils.js.map 1.55 KB
168
+ CJS dist/lib/utils.js.map 1.30 KB
168
169
  CJS dist/types/css.js.map 788.00 B
169
170
  CJS dist/types/index.js.map 182.00 B
170
171
  CJS dist/types/suggestions.js.map 259.00 B
171
172
  CJS dist/components/chat/Button.js.map 5.47 KB
172
- CJS dist/index.css.map 18.25 KB
173
173
  CJS dist/components/chat/Chat.js.map 76.20 KB
174
174
  CJS dist/components/chat/ChatContext.js.map 13.87 KB
175
- CJS dist/components/chat/Header.js.map 5.11 KB
176
175
  CJS dist/components/chat/CodeBlock.js.map 24.33 KB
176
+ CJS dist/components/chat/Header.js.map 5.11 KB
177
177
  CJS dist/components/chat/Icons.js.map 10.27 KB
178
178
  CJS dist/components/chat/Input.js.map 19.45 KB
179
- CJS dist/components/chat/Messages.js.map 40.08 KB
179
+ CJS dist/components/chat/Markdown.js.map 27.58 KB
180
+ CJS dist/components/chat/Messages.js.map 40.05 KB
180
181
  CJS dist/components/chat/Modal.js.map 89.00 KB
181
182
  CJS dist/components/chat/Response.js.map 5.19 KB
182
183
  CJS dist/components/chat/Popup.js.map 91.07 KB
@@ -185,11 +186,10 @@
185
186
  CJS dist/components/chat/Window.js.map 6.76 KB
186
187
  CJS dist/components/chat/Sidebar.js.map 92.01 KB
187
188
  CJS dist/components/chat/props.js.map 1.07 KB
188
- CJS dist/components/chat/index.js.map 94.33 KB
189
- CJS dist/components/chat/Markdown.js.map 27.58 KB
190
- CJS ⚡️ Build success in 320ms
189
+ CJS dist/components/chat/index.js.map 94.34 KB
190
+ CJS ⚡️ Build success in 331ms
191
191
  DTS Build start
192
- DTS ⚡️ Build success in 7766ms
192
+ DTS ⚡️ Build success in 7984ms
193
193
  DTS dist/index.d.ts 699.00 B
194
194
  DTS dist/components/chat/props.d.ts 1019.00 B
195
195
  DTS dist/components/chat/Popup.d.ts 1.78 KB
@@ -206,7 +206,7 @@
206
206
  DTS dist/hooks/use-copy-to-clipboard.d.ts 266.00 B
207
207
  DTS dist/hooks/use-push-to-talk.d.ts 783.00 B
208
208
  DTS dist/lib/utils.test.d.ts 12.00 B
209
- DTS dist/lib/utils.d.ts 263.00 B
209
+ DTS dist/lib/utils.d.ts 194.00 B
210
210
  DTS dist/types/index.d.ts 68.00 B
211
211
  DTS dist/components/chat/Button.d.ts 175.00 B
212
212
  DTS dist/components/chat/CodeBlock.d.ts 392.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # ui
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Remove nanoid
8
+ - Updated dependencies
9
+ - @copilotkit/react-core@1.0.4
10
+ - @copilotkit/runtime-client-gql@1.0.4
11
+ - @copilotkit/shared@1.0.4
12
+
3
13
  ## 1.0.3
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -41,7 +41,7 @@ in-app AI chatbots, AI agents, and AI Textareas.
41
41
  <img src="https://github.com/CopilotKit/CopilotKit/assets/131273140/a4a0fd04-6aee-4e02-9c3e-3f11d60b4e8b" alt="Read the Docs" height="30">
42
42
  </a>
43
43
  &nbsp;&middot;&nbsp;
44
- <a href="https://go.copilotkit.ai/kM4Lo86">
44
+ <a href="https://cloud.copilotkit.ai">
45
45
  <img src="https://github.com/CopilotKit/CopilotKit/assets/131273140/28ca62a8-cf93-4d3f-96b0-dc11bf89b734" alt="Try Copilot Cloud" height="30">
46
46
  </a>
47
47
  </p>
@@ -123,4 +123,4 @@ function makeInitialMessages(initial) {
123
123
  export {
124
124
  Messages
125
125
  };
126
- //# sourceMappingURL=chunk-DYXI54LF.mjs.map
126
+ //# sourceMappingURL=chunk-4Z2WDXSK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Messages.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport { MessagesProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { Markdown } from \"./Markdown\";\nimport { RenderFunctionStatus, useCopilotContext } from \"@copilotkit/react-core\";\nimport {\n MessageStatusCode,\n ActionExecutionMessage,\n Message,\n ResultMessage,\n TextMessage,\n Role,\n} from \"@copilotkit/runtime-client-gql\";\n\nexport const Messages = ({ messages, inProgress, children }: MessagesProps) => {\n const { chatComponentsCache } = useCopilotContext();\n\n const context = useChatContext();\n const initialMessages = useMemo(\n () => makeInitialMessages(context.labels.initial),\n [context.labels.initial],\n );\n messages = [...initialMessages, ...messages];\n\n const functionResults: Record<string, string> = {};\n\n for (let i = 0; i < messages.length; i++) {\n if (messages[i] instanceof ActionExecutionMessage) {\n const id = messages[i].id;\n const resultMessage: ResultMessage | undefined = messages.find(\n (message) => message instanceof ResultMessage && message.actionExecutionId === id,\n ) as ResultMessage | undefined;\n\n if (resultMessage) {\n functionResults[id] = ResultMessage.decodeResult(resultMessage.result || \"\");\n }\n }\n }\n\n const messagesEndRef = React.useRef<HTMLDivElement>(null);\n\n const scrollToBottom = () => {\n if (messagesEndRef.current) {\n messagesEndRef.current.scrollIntoView({\n behavior: \"auto\",\n });\n }\n };\n\n useEffect(() => {\n scrollToBottom();\n }, [messages]);\n\n return (\n <div className=\"copilotKitMessages\">\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1;\n\n if (message instanceof TextMessage && message.role === \"user\") {\n return (\n <div key={index} className=\"copilotKitMessage copilotKitUserMessage\">\n {message.content}\n </div>\n );\n } else if (message instanceof TextMessage && message.role == \"assistant\") {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && !message.content ? (\n context.icons.spinnerIcon\n ) : (\n <Markdown content={message.content} />\n )}\n </div>\n );\n } else if (message instanceof ActionExecutionMessage) {\n if (chatComponentsCache.current !== null && chatComponentsCache.current[message.name]) {\n const render = chatComponentsCache.current[message.name];\n // render a static string\n if (typeof render === \"string\") {\n // when render is static, we show it only when in progress\n if (isCurrentMessage && inProgress) {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.icons.spinnerIcon} <span className=\"inProgressLabel\">{render}</span>\n </div>\n );\n }\n // Done - silent by default to avoid a series of \"done\" messages\n else {\n return null;\n }\n }\n // render is a function\n else {\n const args = message.arguments;\n\n let status: RenderFunctionStatus = \"inProgress\";\n\n if (functionResults[message.id] !== undefined) {\n status = \"complete\";\n } else if (message.status.code !== MessageStatusCode.Pending) {\n status = \"executing\";\n }\n\n const toRender = render({\n status: status as any,\n args,\n result: functionResults[message.id],\n });\n\n // No result and complete: stay silent\n if (!toRender && status === \"complete\") {\n return null;\n }\n\n if (typeof toRender === \"string\") {\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {isCurrentMessage && inProgress && context.icons.spinnerIcon} {toRender}\n </div>\n );\n } else {\n return (\n <div key={index} className=\"copilotKitCustomAssistantMessage\">\n {toRender}\n </div>\n );\n }\n }\n }\n // No render function found- show the default message\n else if (!inProgress || !isCurrentMessage) {\n // Done - silent by default to avoid a series of \"done\" messages\n return null;\n } else {\n // In progress\n return (\n <div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>\n {context.icons.spinnerIcon}\n </div>\n );\n }\n }\n })}\n <footer ref={messagesEndRef}>{children}</footer>\n </div>\n );\n};\n\nfunction makeInitialMessages(initial?: string | string[]): Message[] {\n let initialArray: string[] = [];\n if (initial) {\n if (Array.isArray(initial)) {\n initialArray.push(...initial);\n } else {\n initialArray.push(initial);\n }\n }\n\n return initialArray.map(\n (message) =>\n new TextMessage({\n role: Role.Assistant,\n content: message,\n }),\n );\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,SAAS,WAAW,eAAe;AAI1C,SAA+B,yBAAyB;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgDK,cAsBM,YAtBN;AA9CL,IAAM,WAAW,CAAC,EAAE,UAAU,YAAY,SAAS,MAAqB;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iB,UAAS;AAAA,KACzC;AAEJ;AAEA,SAAS,oBAAoB,SAAwC;AACnE,MAAI,eAAyB,CAAC;AAC9B,MAAI,SAAS;AACX,QAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,mBAAa,KAAK,GAAG,OAAO;AAAA,IAC9B,OAAO;AACL,mBAAa,KAAK,OAAO;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO,aAAa;AAAA,IAClB,CAAC,YACC,IAAI,YAAY;AAAA,MACd,MAAM,KAAK;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACL;AACF;","names":[]}
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-U6J5DGOE.mjs";
8
8
  import {
9
9
  Messages
10
- } from "./chunk-DYXI54LF.mjs";
10
+ } from "./chunk-4Z2WDXSK.mjs";
11
11
  import {
12
12
  ResponseButton
13
13
  } from "./chunk-XSUSSWDS.mjs";
@@ -22,8 +22,8 @@ import {
22
22
  // src/components/chat/Chat.tsx
23
23
  import React, { useEffect, useRef, useState } from "react";
24
24
  import { useCopilotChat, useCopilotContext } from "@copilotkit/react-core";
25
- import { nanoid } from "nanoid";
26
25
  import { Role, TextMessage } from "@copilotkit/runtime-client-gql";
26
+ import { randomId } from "@copilotkit/shared";
27
27
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
28
  function CopilotChat({
29
29
  instructions,
@@ -95,7 +95,7 @@ function WrappedCopilotChat({
95
95
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
96
96
  var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
97
97
  const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = useCopilotChat({
98
- id: nanoid(),
98
+ id: randomId(),
99
99
  makeSystemMessage
100
100
  });
101
101
  const [currentSuggestions, setCurrentSuggestions] = useState([]);
@@ -154,4 +154,4 @@ export {
154
154
  WrappedCopilotChat,
155
155
  useCopilotChatLogic
156
156
  };
157
- //# sourceMappingURL=chunk-MHTQKDHI.mjs.map
157
+ //# sourceMappingURL=chunk-5BL3YDGU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/chat/Chat.tsx"],"sourcesContent":["/**\n * An embeddable chat panel for CopilotKit.\n *\n * <img src=\"/images/CopilotChat/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 * <RequestExample>\n * ```jsx CopilotChat Example\n * import { CopilotChat } from \"@copilotkit/react-ui\";\n *\n * <CopilotChat\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\n * </RequestExample>\n *\n * ## Custom CSS\n *\n * You can customize the colors of the panel by overriding the CSS variables\n * defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).\n *\n * For example, to set the primary color to purple:\n *\n * ```jsx\n * <div style={{ \"--copilot-kit-primary-color\": \"#7D5BA6\" }}>\n * <CopilotPopup />\n * </div>\n * ```\n *\n * To further customize the panel, you can override the CSS classes defined\n * [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).\n *\n * For example:\n *\n * ```css\n * .copilotKitButton {\n * border-radius: 0;\n * }\n * ```\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 { Suggestion } from \"./Suggestion\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { SystemMessageFunction, useCopilotChat, useCopilotContext } from \"@copilotkit/react-core\";\nimport { reloadSuggestions } from \"./Suggestion\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { Message, Role, TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { InputProps, MessagesProps, ResponseButtonProps } from \"./props\";\nimport { randomId } from \"@copilotkit/shared\";\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;\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 Messages component to use instead of the default.\n */\n Messages?: React.ComponentType<MessagesProps>;\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\nexport function CopilotChat({\n instructions,\n onSubmitMessage,\n makeSystemMessage,\n showResponseButton = true,\n onInProgress,\n Messages = DefaultMessages,\n Input = DefaultInput,\n ResponseButton = DefaultResponseButton,\n className,\n icons,\n labels,\n}: CopilotChatProps) {\n const context = useCopilotContext();\n\n useEffect(() => {\n context.setChatInstructions(instructions || \"\");\n }, [instructions]);\n\n const {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n } = useCopilotChatLogic(makeSystemMessage, onInProgress, onSubmitMessage);\n\n const chatContext = React.useContext(ChatContext);\n const isVisible = chatContext ? chatContext.open : true;\n\n return (\n <WrappedCopilotChat icons={icons} labels={labels} className={className}>\n <Messages messages={visibleMessages} inProgress={isLoading}>\n {currentSuggestions.length > 0 && (\n <div>\n <h6>Suggested:</h6>\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 </div>\n )}\n {showResponseButton && visibleMessages.length > 0 && (\n <ResponseButton\n onClick={isLoading ? stopGeneration : reloadMessages}\n inProgress={isLoading}\n />\n )}\n </Messages>\n <Input inProgress={isLoading} onSend={sendMessage} isVisible={isVisible} />\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) => void,\n) => {\n const { visibleMessages, appendMessage, reloadMessages, stopGeneration, 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 context = useCopilotContext();\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 }, [isLoading, context.chatSuggestionConfiguration]);\n\n const sendMessage = async (messageContent: string) => {\n abortSuggestions();\n setCurrentSuggestions([]);\n onSubmitMessage?.(messageContent);\n const message: Message = new TextMessage({\n content: messageContent,\n role: Role.User,\n });\n appendMessage(message);\n return message;\n };\n\n return {\n visibleMessages,\n isLoading,\n currentSuggestions,\n sendMessage,\n stopGeneration,\n reloadMessages,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwDA,OAAO,SAAS,WAAW,QAAQ,gBAAgB;AACnD,SAAgC,gBAAgB,yBAAyB;AAGzE,SAAkB,MAAM,mBAAmB;AAE3C,SAAS,gBAAgB;AA+Gf,SA+CD,UA9CG,KADF;AAnCH,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,qBAAqB;AAAA,EACrB;AAAA,EACA,UAAAA,YAAW;AAAA,EACX,OAAAC,SAAQ;AAAA,EACR,gBAAAC,kBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AACF,GAAqB;AACnB,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,YAAQ,oBAAoB,gBAAgB,EAAE;AAAA,EAChD,GAAG,CAAC,YAAY,CAAC;AAEjB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,oBAAoB,mBAAmB,cAA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,CAAC;AAEH,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAkC,CAAC,CAAC;AACxF,QAAM,gCAAgC,OAA+B,IAAI;AACzE,QAAM,mBAAmB,OAAY;AAErC,QAAM,mBAAmB,MAAM;AAhPjC;AAiPI,wCAA8B,YAA9B,mBAAuC;AACvC,kCAA8B,UAAU;AAAA,EAC1C;AAEA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,iDAAe;AAEf,qBAAiB;AAEjB,qBAAiB,UAAU;AAAA,MACzB,MAAM;AACJ,YAAI,CAAC,aAAa,OAAO,KAAK,QAAQ,2BAA2B,EAAE,WAAW,GAAG;AAC/E,wCAA8B,UAAU,IAAI,gBAAgB;AAC5D;AAAA,YACE;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,mBAAmB,UAAU,IAAI,IAAI;AAAA,IACvC;AAEA,WAAO,MAAM;AACX,mBAAa,iBAAiB,OAAO;AAAA,IACvC;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,2BAA2B,CAAC;AAEnD,QAAM,cAAc,CAAO,mBAA2B;AACpD,qBAAiB;AACjB,0BAAsB,CAAC,CAAC;AACxB,uDAAkB;AAClB,UAAM,UAAmB,IAAI,YAAY;AAAA,MACvC,SAAS;AAAA,MACT,MAAM,KAAK;AAAA,IACb,CAAC;AACD,kBAAc,OAAO;AACrB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["Messages","Input","ResponseButton"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-2K5GFKKP.mjs";
3
+ } from "./chunk-OLL5TU65.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-ADMZDZCJ.mjs.map
21
+ //# sourceMappingURL=chunk-DYHXNV2B.mjs.map
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-UC3Y7MWX.mjs";
10
10
  import {
11
11
  CopilotChat
12
- } from "./chunk-MHTQKDHI.mjs";
12
+ } from "./chunk-5BL3YDGU.mjs";
13
13
  import {
14
14
  Input
15
15
  } from "./chunk-U6J5DGOE.mjs";
16
16
  import {
17
17
  Messages
18
- } from "./chunk-DYXI54LF.mjs";
18
+ } from "./chunk-4Z2WDXSK.mjs";
19
19
  import {
20
20
  ResponseButton
21
21
  } from "./chunk-XSUSSWDS.mjs";
@@ -90,4 +90,4 @@ var CopilotModal = ({
90
90
  export {
91
91
  CopilotModal
92
92
  };
93
- //# sourceMappingURL=chunk-2K5GFKKP.mjs.map
93
+ //# sourceMappingURL=chunk-OLL5TU65.mjs.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "./chunk-2K5GFKKP.mjs";
3
+ } from "./chunk-OLL5TU65.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-NYDX3JVD.mjs.map
30
+ //# sourceMappingURL=chunk-QHAVUMXM.mjs.map
@@ -1,7 +1,7 @@
1
1
  // src/hooks/use-copilot-chat-suggestions.tsx
2
2
  import { useEffect } from "react";
3
- import { nanoid } from "nanoid";
4
3
  import { useCopilotContext } from "@copilotkit/react-core";
4
+ import { randomId } from "@copilotkit/shared";
5
5
  function useCopilotChatSuggestions({
6
6
  instructions,
7
7
  className,
@@ -10,7 +10,7 @@ function useCopilotChatSuggestions({
10
10
  }, dependencies = []) {
11
11
  const context = useCopilotContext();
12
12
  useEffect(() => {
13
- const id = nanoid();
13
+ const id = randomId();
14
14
  context.addChatSuggestionConfiguration(id, {
15
15
  instructions,
16
16
  minSuggestions,
@@ -26,4 +26,4 @@ function useCopilotChatSuggestions({
26
26
  export {
27
27
  useCopilotChatSuggestions
28
28
  };
29
- //# sourceMappingURL=chunk-LTCJCXCP.mjs.map
29
+ //# sourceMappingURL=chunk-RMK4ADB6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * A hook for providing suggestions to the user in the Copilot chat.\n *\n * <Warning>\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without further notice.\n * </Warning>\n *\n * <img src=\"/images/useCopilotChatSuggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * <img referrerPolicy=\"no-referrer-when-downgrade\" src=\"https://static.scarf.sh/a.png?x-pxid=a9b290bb-38f9-4518-ac3b-8f54fdbf43be\" />\n *\n * `useCopilotChatSuggestions` integrates auto-generated chat suggestions into your application in the context of your\n * app's state. It dynamically manages suggestions based on provided configurations and\n * dependencies.\n *\n * <RequestExample>\n * ```jsx useCopilotChatSuggestions Example\n * import { useCopilotChatSuggestions }\n * from \"@copilotkit/react-ui\";\n *\n * useCopilotChatSuggestions({\n * instructions: \"Your instructions for suggestions.\",\n * })\n * ```\n * </RequestExample>\n *\n * ## Basic Setup\n *\n * To incorporate this hook into your React components, start by importing it:\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n * ```\n *\n * Then, use it in your component to initiate suggestion functionality:\n *\n * ```tsx\n * useCopilotChatSuggestions({\n * instructions: \"Your instructions for suggestions.\",\n * });\n * ```\n *\n * ## Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ## Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\n\nimport { useEffect } from \"react\";\nimport { useChatContext } from \"../components\";\nimport { nanoid } from \"nanoid\";\nimport { CopilotChatSuggestionConfiguration, useCopilotContext } from \"@copilotkit/react-core\";\n\ninterface UseCopilotChatSuggestionsConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n const id = nanoid();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, dependencies);\n}\n"],"mappings":";AAiEA,SAAS,iBAAiB;AAE1B,SAAS,cAAc;AACvB,SAA6C,yBAAyB;AAuB/D,SAAS,0BACd;AAAA,EACE;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,UAAM,KAAK,OAAO;AAElB,YAAQ,+BAA+B,IAAI;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,cAAQ,kCAAkC,EAAE;AAAA,IAC9C;AAAA,EACF,GAAG,YAAY;AACjB;","names":[]}
1
+ {"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * A hook for providing suggestions to the user in the Copilot chat.\n *\n * <Warning>\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without further notice.\n * </Warning>\n *\n * <img src=\"/images/useCopilotChatSuggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * <img referrerPolicy=\"no-referrer-when-downgrade\" src=\"https://static.scarf.sh/a.png?x-pxid=a9b290bb-38f9-4518-ac3b-8f54fdbf43be\" />\n *\n * `useCopilotChatSuggestions` integrates auto-generated chat suggestions into your application in the context of your\n * app's state. It dynamically manages suggestions based on provided configurations and\n * dependencies.\n *\n * <RequestExample>\n * ```jsx useCopilotChatSuggestions Example\n * import { useCopilotChatSuggestions }\n * from \"@copilotkit/react-ui\";\n *\n * useCopilotChatSuggestions({\n * instructions: \"Your instructions for suggestions.\",\n * })\n * ```\n * </RequestExample>\n *\n * ## Basic Setup\n *\n * To incorporate this hook into your React components, start by importing it:\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n * ```\n *\n * Then, use it in your component to initiate suggestion functionality:\n *\n * ```tsx\n * useCopilotChatSuggestions({\n * instructions: \"Your instructions for suggestions.\",\n * });\n * ```\n *\n * ## Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\n * ```\n *\n * In the example above, the suggestions are generated based on the given instructions.\n * The hook monitors `appState`, and updates suggestions accordingly whenever it changes.\n *\n * ## Behavior and Lifecycle\n *\n * The hook registers the configuration with the chat context upon component mount and\n * removes it on unmount, ensuring a clean and efficient lifecycle management.\n */\n\nimport { useEffect } from \"react\";\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport { randomId } from \"@copilotkit/shared\";\n\ninterface UseCopilotChatSuggestionsConfiguration {\n /**\n * A prompt or instructions for the GPT to generate suggestions.\n */\n instructions: string;\n /**\n * The minimum number of suggestions to generate. Defaults to `1`.\n * @default 1\n */\n minSuggestions?: number;\n /**\n * The maximum number of suggestions to generate. Defaults to `3`.\n * @default 1\n */\n maxSuggestions?: number;\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n const id = randomId();\n\n context.addChatSuggestionConfiguration(id, {\n instructions,\n minSuggestions,\n maxSuggestions,\n className,\n });\n\n return () => {\n context.removeChatSuggestionConfiguration(id);\n };\n }, dependencies);\n}\n"],"mappings":";AAiEA,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AAuBlB,SAAS,0BACd;AAAA,EACE;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,UAAM,KAAK,SAAS;AAEpB,YAAQ,+BAA+B,IAAI;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,cAAQ,kCAAkC,EAAE;AAAA,IAC9C;AAAA,EACF,GAAG,YAAY;AACjB;","names":[]}
@@ -1283,8 +1283,8 @@ var reloadSuggestions = (context, chatSuggestionConfiguration, setCurrentSuggest
1283
1283
  // src/components/chat/Chat.tsx
1284
1284
  var import_react8 = __toESM(require("react"));
1285
1285
  var import_react_core5 = require("@copilotkit/react-core");
1286
- var import_nanoid = require("nanoid");
1287
1286
  var import_runtime_client_gql4 = require("@copilotkit/runtime-client-gql");
1287
+ var import_shared2 = require("@copilotkit/shared");
1288
1288
  var import_jsx_runtime10 = require("react/jsx-runtime");
1289
1289
  function CopilotChat({
1290
1290
  instructions,
@@ -1356,7 +1356,7 @@ function WrappedCopilotChat({
1356
1356
  var SUGGESTIONS_DEBOUNCE_TIMEOUT = 1e3;
1357
1357
  var useCopilotChatLogic = (makeSystemMessage, onInProgress, onSubmitMessage) => {
1358
1358
  const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } = (0, import_react_core5.useCopilotChat)({
1359
- id: (0, import_nanoid.nanoid)(),
1359
+ id: (0, import_shared2.randomId)(),
1360
1360
  makeSystemMessage
1361
1361
  });
1362
1362
  const [currentSuggestions, setCurrentSuggestions] = (0, import_react8.useState)([]);