@copilotkit/react-ui 0.0.0-feat-dynamic-copilotcloud-qa-20250117190454 → 0.0.0-feat-langgraph-interrupt-hook-20250203094147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +138 -4
- package/dist/{chunk-34FREWVK.mjs → chunk-6FTRYYR5.mjs} +4 -1
- package/dist/chunk-6FTRYYR5.mjs.map +1 -0
- package/dist/{chunk-PNQVKBPN.mjs → chunk-6TCUJ3B7.mjs} +2 -2
- package/dist/chunk-6TCUJ3B7.mjs.map +1 -0
- package/dist/{chunk-VKVNMHM5.mjs → chunk-7D6TIVZ6.mjs} +3 -3
- package/dist/{chunk-O6JFOQQA.mjs → chunk-NCM42YQL.mjs} +2 -2
- package/dist/{chunk-B23XDGH4.mjs → chunk-PGXWPTAW.mjs} +2 -2
- package/dist/{chunk-I7MG52I5.mjs → chunk-Q77YGF2I.mjs} +5 -5
- package/dist/{chunk-F2W5FD7L.mjs → chunk-VY62BA22.mjs} +2 -2
- package/dist/{chunk-RJCZRKTV.mjs → chunk-WGAZXTUA.mjs} +2 -1
- package/dist/chunk-WGAZXTUA.mjs.map +1 -0
- package/dist/{chunk-P5A3A5FO.mjs → chunk-XB6QCUPB.mjs} +6 -6
- package/dist/{chunk-P5A3A5FO.mjs.map → chunk-XB6QCUPB.mjs.map} +1 -1
- package/dist/{chunk-Z2UZSN3K.mjs → chunk-Z4XPPVZT.mjs} +5 -2
- package/dist/{chunk-Z2UZSN3K.mjs.map → chunk-Z4XPPVZT.mjs.map} +1 -1
- package/dist/components/chat/Chat.js +35 -31
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +6 -6
- package/dist/components/chat/Messages.js +3 -0
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.js +35 -31
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +7 -7
- package/dist/components/chat/Popup.js +35 -31
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +8 -8
- package/dist/components/chat/Sidebar.js +35 -31
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +8 -8
- package/dist/components/chat/Suggestion.js +1 -0
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/index.js +35 -31
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +9 -9
- package/dist/components/chat/messages/RenderActionExecutionMessage.js +5 -5
- package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -1
- package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +1 -1
- package/dist/components/dev-console/console.js +1 -1
- package/dist/components/dev-console/console.js.map +1 -1
- package/dist/components/dev-console/console.mjs +2 -2
- package/dist/components/dev-console/index.js +1 -1
- package/dist/components/dev-console/index.js.map +1 -1
- package/dist/components/dev-console/index.mjs +2 -2
- package/dist/components/dev-console/utils.js +1 -1
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -1
- package/dist/components/index.js +35 -31
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +9 -9
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.d.ts +6 -1
- package/dist/hooks/use-copilot-chat-suggestions.js +4 -1
- package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -1
- package/dist/hooks/use-copilot-chat-suggestions.mjs +1 -1
- package/dist/index.js +41 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/package.json +4 -4
- package/src/components/chat/Messages.tsx +6 -1
- package/src/components/chat/Suggestion.tsx +1 -0
- package/src/components/chat/messages/RenderActionExecutionMessage.tsx +3 -4
- package/src/components/dev-console/utils.ts +1 -1
- package/src/hooks/use-copilot-chat-suggestions.tsx +11 -1
- package/dist/chunk-34FREWVK.mjs.map +0 -1
- package/dist/chunk-PNQVKBPN.mjs.map +0 -1
- package/dist/chunk-RJCZRKTV.mjs.map +0 -1
- /package/dist/{chunk-VKVNMHM5.mjs.map → chunk-7D6TIVZ6.mjs.map} +0 -0
- /package/dist/{chunk-O6JFOQQA.mjs.map → chunk-NCM42YQL.mjs.map} +0 -0
- /package/dist/{chunk-B23XDGH4.mjs.map → chunk-PGXWPTAW.mjs.map} +0 -0
- /package/dist/{chunk-I7MG52I5.mjs.map → chunk-Q77YGF2I.mjs.map} +0 -0
- /package/dist/{chunk-F2W5FD7L.mjs.map → chunk-VY62BA22.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,151 @@
|
|
|
1
1
|
# ui
|
|
2
2
|
|
|
3
|
-
## 0.0.0-feat-
|
|
3
|
+
## 0.0.0-feat-langgraph-interrupt-hook-20250203094147
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 3b1b633: - feat(interrupt): support LG interrupt with useLangGraphInterrupt hook
|
|
8
|
+
- chore(interrupt): add e2e test to interrupt functionality
|
|
9
|
+
- feat(interrupt): add support for multiple interrupts and conditions
|
|
10
|
+
- 66bd0f7: - fix(react-ui): check for updates endpoint to point to production
|
|
11
|
+
- Updated dependencies [3b1b633]
|
|
12
|
+
- Updated dependencies [0bbb4ab]
|
|
13
|
+
- @copilotkit/react-core@0.0.0-feat-langgraph-interrupt-hook-20250203094147
|
|
14
|
+
- @copilotkit/runtime-client-gql@0.0.0-feat-langgraph-interrupt-hook-20250203094147
|
|
15
|
+
- @copilotkit/shared@0.0.0-feat-langgraph-interrupt-hook-20250203094147
|
|
16
|
+
|
|
17
|
+
## 1.5.15-next.3
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- @copilotkit/runtime-client-gql@1.5.15-next.3
|
|
22
|
+
- @copilotkit/react-core@1.5.15-next.3
|
|
23
|
+
- @copilotkit/shared@1.5.15-next.3
|
|
24
|
+
|
|
25
|
+
## 1.5.15-next.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- @copilotkit/runtime-client-gql@1.5.15-next.2
|
|
30
|
+
- @copilotkit/react-core@1.5.15-next.2
|
|
31
|
+
- @copilotkit/shared@1.5.15-next.2
|
|
32
|
+
|
|
33
|
+
## 1.5.15-next.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [0bbb4ab]
|
|
38
|
+
- @copilotkit/runtime-client-gql@1.5.15-next.1
|
|
39
|
+
- @copilotkit/react-core@1.5.15-next.1
|
|
40
|
+
- @copilotkit/shared@1.5.15-next.1
|
|
41
|
+
|
|
42
|
+
## 1.5.15-next.0
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- 66bd0f7: - fix(react-ui): check for updates endpoint to point to production
|
|
47
|
+
- @copilotkit/react-core@1.5.15-next.0
|
|
48
|
+
- @copilotkit/runtime-client-gql@1.5.15-next.0
|
|
49
|
+
- @copilotkit/shared@1.5.15-next.0
|
|
50
|
+
|
|
51
|
+
## 1.5.14
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [0061f65]
|
|
56
|
+
- @copilotkit/react-core@1.5.14
|
|
57
|
+
- @copilotkit/shared@1.5.14
|
|
58
|
+
- @copilotkit/runtime-client-gql@1.5.14
|
|
59
|
+
|
|
60
|
+
## 1.5.14-next.0
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [0061f65]
|
|
65
|
+
- @copilotkit/react-core@1.5.14-next.0
|
|
66
|
+
- @copilotkit/shared@1.5.14-next.0
|
|
67
|
+
- @copilotkit/runtime-client-gql@1.5.14-next.0
|
|
68
|
+
|
|
69
|
+
## 1.5.13
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- @copilotkit/runtime-client-gql@1.5.13
|
|
74
|
+
- @copilotkit/react-core@1.5.13
|
|
75
|
+
- @copilotkit/shared@1.5.13
|
|
76
|
+
|
|
77
|
+
## 1.5.13-next.0
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- @copilotkit/runtime-client-gql@1.5.13-next.0
|
|
82
|
+
- @copilotkit/react-core@1.5.13-next.0
|
|
83
|
+
- @copilotkit/shared@1.5.13-next.0
|
|
84
|
+
|
|
85
|
+
## 1.5.12
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- 6136a57: - fix(errors): add custom error classes to better describe library errors
|
|
90
|
+
- fix(errors): use new errors in error handling
|
|
91
|
+
- chore: add documentation and links to respective errors
|
|
7
92
|
- 86fae3a: - feat(react-ui): add interfaces for full message customization
|
|
8
93
|
|
|
9
94
|
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
|
|
10
95
|
|
|
11
96
|
- Updated dependencies [fb87bcf]
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
97
|
+
- Updated dependencies [926499b]
|
|
98
|
+
- Updated dependencies [6136a57]
|
|
99
|
+
- Updated dependencies [cb43c05]
|
|
100
|
+
- @copilotkit/runtime-client-gql@1.5.12
|
|
101
|
+
- @copilotkit/react-core@1.5.12
|
|
102
|
+
- @copilotkit/shared@1.5.12
|
|
103
|
+
|
|
104
|
+
## 1.5.12-next.7
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies [926499b]
|
|
109
|
+
- @copilotkit/react-core@1.5.12-next.7
|
|
110
|
+
- @copilotkit/runtime-client-gql@1.5.12-next.7
|
|
111
|
+
- @copilotkit/shared@1.5.12-next.7
|
|
112
|
+
|
|
113
|
+
## 1.5.12-next.6
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- 6136a57: - fix(errors): add custom error classes to better describe library errors
|
|
118
|
+
- fix(errors): use new errors in error handling
|
|
119
|
+
- chore: add documentation and links to respective errors
|
|
120
|
+
- Updated dependencies [6136a57]
|
|
121
|
+
- @copilotkit/react-core@1.5.12-next.6
|
|
122
|
+
- @copilotkit/runtime-client-gql@1.5.12-next.6
|
|
123
|
+
- @copilotkit/shared@1.5.12-next.6
|
|
124
|
+
|
|
125
|
+
## 1.5.12-next.5
|
|
126
|
+
|
|
127
|
+
### Patch Changes
|
|
128
|
+
|
|
129
|
+
- @copilotkit/runtime-client-gql@1.5.12-next.5
|
|
130
|
+
- @copilotkit/react-core@1.5.12-next.5
|
|
131
|
+
- @copilotkit/shared@1.5.12-next.5
|
|
132
|
+
|
|
133
|
+
## 1.5.12-next.4
|
|
134
|
+
|
|
135
|
+
### Patch Changes
|
|
136
|
+
|
|
137
|
+
- @copilotkit/runtime-client-gql@1.5.12-next.4
|
|
138
|
+
- @copilotkit/react-core@1.5.12-next.4
|
|
139
|
+
- @copilotkit/shared@1.5.12-next.4
|
|
140
|
+
|
|
141
|
+
## 1.5.12-next.3
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- Updated dependencies [cb43c05]
|
|
146
|
+
- @copilotkit/react-core@1.5.12-next.3
|
|
147
|
+
- @copilotkit/runtime-client-gql@1.5.12-next.3
|
|
148
|
+
- @copilotkit/shared@1.5.12-next.3
|
|
15
149
|
|
|
16
150
|
## 1.5.12-next.2
|
|
17
151
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
// src/components/chat/Messages.tsx
|
|
6
6
|
import { useEffect, useMemo, useRef } from "react";
|
|
7
7
|
import { ResultMessage, TextMessage, Role } from "@copilotkit/runtime-client-gql";
|
|
8
|
+
import { useLangGraphInterruptRender } from "@copilotkit/react-core";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
var Messages = ({
|
|
10
11
|
messages,
|
|
@@ -36,6 +37,7 @@ var Messages = ({
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);
|
|
40
|
+
const interrupt = useLangGraphInterruptRender();
|
|
39
41
|
return /* @__PURE__ */ jsxs("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
|
|
40
42
|
messages.map((message, index) => {
|
|
41
43
|
const isCurrentMessage = index === messages.length - 1;
|
|
@@ -94,6 +96,7 @@ var Messages = ({
|
|
|
94
96
|
);
|
|
95
97
|
}
|
|
96
98
|
}),
|
|
99
|
+
interrupt,
|
|
97
100
|
/* @__PURE__ */ jsx("footer", { ref: messagesEndRef, children })
|
|
98
101
|
] });
|
|
99
102
|
};
|
|
@@ -177,4 +180,4 @@ export {
|
|
|
177
180
|
Messages,
|
|
178
181
|
useScrollToBottom
|
|
179
182
|
};
|
|
180
|
-
//# sourceMappingURL=chunk-
|
|
183
|
+
//# sourceMappingURL=chunk-6FTRYYR5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Messages.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { MessagesProps } from \"./props\";\nimport { useChatContext } from \"./ChatContext\";\nimport { Message, ResultMessage, TextMessage, Role } from \"@copilotkit/runtime-client-gql\";\nimport { useLangGraphInterruptRender } from \"@copilotkit/react-core\";\n\nexport const Messages = ({\n messages,\n inProgress,\n children,\n RenderTextMessage,\n RenderActionExecutionMessage,\n RenderAgentStateMessage,\n RenderResultMessage,\n AssistantMessage,\n UserMessage,\n}: MessagesProps) => {\n const context = useChatContext();\n const initialMessages = useMemo(\n () => makeInitialMessages(context.labels.initial),\n [context.labels.initial],\n );\n\n messages = [...initialMessages, ...messages];\n\n const actionResults: Record<string, string> = {};\n\n for (let i = 0; i < messages.length; i++) {\n if (messages[i].isActionExecutionMessage()) {\n const id = messages[i].id;\n const resultMessage: ResultMessage | undefined = messages.find(\n (message) => message.isResultMessage() && message.actionExecutionId === id,\n ) as ResultMessage | undefined;\n\n if (resultMessage) {\n actionResults[id] = ResultMessage.decodeResult(resultMessage.result || \"\");\n }\n }\n }\n\n const { messagesEndRef, messagesContainerRef } = useScrollToBottom(messages);\n\n const interrupt = useLangGraphInterruptRender();\n\n return (\n <div className=\"copilotKitMessages\" ref={messagesContainerRef}>\n {messages.map((message, index) => {\n const isCurrentMessage = index === messages.length - 1;\n\n if (message.isTextMessage()) {\n return (\n <RenderTextMessage\n key={index}\n message={message}\n inProgress={inProgress}\n index={index}\n isCurrentMessage={isCurrentMessage}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n />\n );\n } else if (message.isActionExecutionMessage()) {\n return (\n <RenderActionExecutionMessage\n key={index}\n message={message}\n inProgress={inProgress}\n index={index}\n isCurrentMessage={isCurrentMessage}\n actionResult={actionResults[message.id]}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n />\n );\n } else if (message.isAgentStateMessage()) {\n return (\n <RenderAgentStateMessage\n key={index}\n message={message}\n inProgress={inProgress}\n index={index}\n isCurrentMessage={isCurrentMessage}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n />\n );\n } else if (message.isResultMessage()) {\n return (\n <RenderResultMessage\n key={index}\n message={message}\n inProgress={inProgress}\n index={index}\n isCurrentMessage={isCurrentMessage}\n AssistantMessage={AssistantMessage}\n UserMessage={UserMessage}\n />\n );\n }\n })}\n {interrupt}\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}\nexport function useScrollToBottom(messages: any[]) {\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const messagesContainerRef = useRef<HTMLDivElement | null>(null);\n const isProgrammaticScrollRef = useRef(false);\n const isUserScrollUpRef = useRef(false);\n\n const scrollToBottom = () => {\n if (messagesEndRef.current) {\n isProgrammaticScrollRef.current = true;\n messagesEndRef.current.scrollIntoView({\n behavior: \"auto\",\n });\n }\n };\n\n const handleScroll = () => {\n if (isProgrammaticScrollRef.current) {\n isProgrammaticScrollRef.current = false;\n return;\n }\n\n if (messagesContainerRef.current) {\n const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;\n isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;\n }\n };\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (container) {\n container.addEventListener(\"scroll\", handleScroll);\n }\n return () => {\n if (container) {\n container.removeEventListener(\"scroll\", handleScroll);\n }\n };\n }, []);\n\n useEffect(() => {\n const container = messagesContainerRef.current;\n if (!container) {\n return;\n }\n\n const mutationObserver = new MutationObserver(() => {\n if (!isUserScrollUpRef.current) {\n scrollToBottom();\n }\n });\n\n mutationObserver.observe(container, {\n childList: true,\n subtree: true,\n characterData: true,\n });\n\n return () => {\n mutationObserver.disconnect();\n };\n }, []);\n\n useEffect(() => {\n isUserScrollUpRef.current = false;\n scrollToBottom();\n }, [messages.filter((m) => m.isTextMessage() && m.role === Role.User).length]);\n\n return { messagesEndRef, messagesContainerRef };\n}\n"],"mappings":";;;;;AAAA,SAAsB,WAAW,SAAS,cAAc;AAGxD,SAAkB,eAAe,aAAa,YAAY;AAC1D,SAAS,mCAAmC;AAyCxC,SAMQ,KANR;AAvCG,IAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqB;AACnB,QAAM,UAAU,eAAe;AAC/B,QAAM,kBAAkB;AAAA,IACtB,MAAM,oBAAoB,QAAQ,OAAO,OAAO;AAAA,IAChD,CAAC,QAAQ,O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BAAU,oBAAoB,UAAU,YAAY;AAAA,MACtD;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,UAAM,YAAY,qBAAqB;AACvC,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AAEA,UAAM,mBAAmB,IAAI,iBAAiB,MAAM;AAClD,UAAI,CAAC,kBAAkB,SAAS;AAC9B,uBAAe;AAAA,MACjB;AAAA,IACF,CAAC;AAED,qBAAiB,QAAQ,WAAW;AAAA,MAClC,WAAW;AAAA,MACX,SAAS;AAAA,MACT,eAAe;AAAA,IACjB,CAAC;AAED,WAAO,MAAM;AACX,uBAAiB,WAAW;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,sBAAkB,UAAU;AAC5B,mBAAe;AAAA,EACjB,GAAG,CAAC,SAAS,OAAO,CAAC,MAAM,EAAE,cAAc,KAAK,EAAE,SAAS,KAAK,IAAI,EAAE,MAAM,CAAC;AAE7E,SAAO,EAAE,gBAAgB,qBAAqB;AAChD;","names":[]}
|
|
@@ -35,7 +35,7 @@ function getPublishedCopilotKitVersion(current, forceCheck = false) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
try {
|
|
38
|
-
const response = yield fetch("https://api.cloud.
|
|
38
|
+
const response = yield fetch("https://api.cloud.copilotkit.ai/check-for-updates", {
|
|
39
39
|
method: "POST",
|
|
40
40
|
headers: {
|
|
41
41
|
"Content-Type": "application/json"
|
|
@@ -143,4 +143,4 @@ export {
|
|
|
143
143
|
logActions,
|
|
144
144
|
logMessages
|
|
145
145
|
};
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-6TCUJ3B7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/dev-console/utils.ts"],"sourcesContent":["import {\n CopilotContextParams,\n CopilotMessagesContextParams,\n defaultCopilotContextCategories,\n} from \"@copilotkit/react-core\";\nimport { CopilotKitVersion } from \"./types\";\nimport { ActionExecutionMessage, ResultMessage, TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { AgentStateMessage } from \"@copilotkit/runtime-client-gql\";\n\nexport function shouldShowDevConsole(showDevConsole: boolean | \"auto\"): boolean {\n if (typeof showDevConsole === \"boolean\") {\n return showDevConsole;\n }\n return (\n getHostname() === \"localhost\" ||\n getHostname() === \"127.0.0.1\" ||\n getHostname() === \"0.0.0.0\" ||\n getHostname() === \"::1\"\n );\n}\n\nfunction getHostname(): string {\n if (typeof window !== \"undefined\" && window.location) {\n return window.location.hostname;\n }\n return \"\";\n}\n\nexport async function getPublishedCopilotKitVersion(\n current: string,\n forceCheck: boolean = false,\n): Promise<CopilotKitVersion> {\n const LOCAL_STORAGE_KEY = \"__copilotkit_version_check__\";\n const serializedVersion = localStorage.getItem(LOCAL_STORAGE_KEY);\n if (serializedVersion && !forceCheck) {\n try {\n const parsedVersion: CopilotKitVersion = JSON.parse(serializedVersion);\n const oneHour = 60 * 60 * 1000;\n const now = new Date().getTime();\n\n if (\n parsedVersion.current === current &&\n now - new Date(parsedVersion.lastChecked).getTime() < oneHour\n ) {\n return parsedVersion;\n }\n } catch (error) {\n console.error(\"Failed to parse CopilotKitVersion from localStorage\", error);\n }\n }\n\n try {\n const response = await fetch(\"https://api.cloud.copilotkit.ai/check-for-updates\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n packages: [\n {\n packageName: \"@copilotkit/shared\",\n packageVersion: current,\n },\n ],\n }),\n });\n\n const data = await response.json();\n\n const version: CopilotKitVersion = {\n current,\n lastChecked: new Date().getTime(),\n latest: data.packages[0].latestVersion,\n severity: data.packages[0].severity,\n advisory: data.packages[0].advisory || null,\n };\n\n localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(version));\n return version;\n } catch (error) {\n console.error(\"Failed to check for updates\", error);\n throw error;\n }\n}\n\nexport function logReadables(context: CopilotContextParams) {\n console.log(\"%cCurrent Readables:\", \"font-size: 16px; font-weight: bold;\");\n\n const readables = context.getContextString([], defaultCopilotContextCategories).trim();\n if (readables.length === 0) {\n console.log(\"No readables found\");\n return;\n }\n console.log(readables);\n}\n\nexport function logActions(context: CopilotContextParams) {\n console.log(\"%cCurrent Actions:\", \"font-size: 16px; font-weight: bold;\");\n\n if (Object.values(context.actions).length === 0) {\n console.log(\"No actions found\");\n return;\n }\n for (const action of Object.values(context.actions)) {\n console.group(action.name);\n console.log(\"name\", action.name);\n console.log(\"description\", action.description);\n console.log(\"parameters\", action.parameters);\n\n console.groupEnd();\n }\n}\n\nexport function logMessages(context: CopilotMessagesContextParams) {\n console.log(\"%cCurrent Messages:\", \"font-size: 16px; font-weight: bold;\");\n\n if (context.messages.length === 0) {\n console.log(\"No messages found\");\n return;\n }\n\n const tableData = context.messages.map((message) => {\n if (message.isTextMessage()) {\n return {\n id: message.id,\n type: \"TextMessage\",\n role: message.role,\n name: undefined,\n scope: undefined,\n content: message.content,\n };\n } else if (message.isActionExecutionMessage()) {\n return {\n id: message.id,\n type: \"ActionExecutionMessage\",\n role: undefined,\n name: message.name,\n scope: message.parentMessageId,\n content: message.arguments,\n };\n } else if (message.isResultMessage()) {\n return {\n id: message.id,\n type: \"ResultMessage\",\n role: undefined,\n name: message.actionName,\n scope: message.actionExecutionId,\n content: message.result,\n };\n } else if (message.isAgentStateMessage()) {\n return {\n id: message.id,\n type: `AgentStateMessage (running: ${message.running})`,\n role: message.role,\n name: undefined,\n scope: message.threadId,\n content: message.state,\n };\n }\n });\n console.table(tableData);\n}\n"],"mappings":";;;;;AAAA;AAAA,EAGE;AAAA,OACK;AAKA,SAAS,qBAAqB,gBAA2C;AAC9E,MAAI,OAAO,mBAAmB,WAAW;AACvC,WAAO;AAAA,EACT;AACA,SACE,YAAY,MAAM,eAClB,YAAY,MAAM,eAClB,YAAY,MAAM,aAClB,YAAY,MAAM;AAEtB;AAEA,SAAS,cAAsB;AAC7B,MAAI,OAA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ACpC,aAAO;AAAA,QACL,IAAI,QAAQ;AAAA,QACZ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf,SAAS,QAAQ;AAAA,MACnB;AAAA,IACF,WAAW,QAAQ,oBAAoB,GAAG;AACxC,aAAO;AAAA,QACL,IAAI,QAAQ;AAAA,QACZ,MAAM,+BAA+B,QAAQ;AAAA,QAC7C,MAAM,QAAQ;AAAA,QACd,MAAM;AAAA,QACN,OAAO,QAAQ;AAAA,QACf,SAAS,QAAQ;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACD,UAAQ,MAAM,SAAS;AACzB;","names":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-RQNJNK2W.mjs";
|
|
10
10
|
import {
|
|
11
11
|
CopilotChat
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Q77YGF2I.mjs";
|
|
13
13
|
import {
|
|
14
14
|
UserMessage
|
|
15
15
|
} from "./chunk-HEIDCT7I.mjs";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-EMQEEXUB.mjs";
|
|
22
22
|
import {
|
|
23
23
|
Messages
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6FTRYYR5.mjs";
|
|
25
25
|
import {
|
|
26
26
|
ResponseButton
|
|
27
27
|
} from "./chunk-3XAXY2Z3.mjs";
|
|
@@ -102,4 +102,4 @@ var CopilotModal = ({
|
|
|
102
102
|
export {
|
|
103
103
|
CopilotModal
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-7D6TIVZ6.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7D6TIVZ6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -18,4 +18,4 @@ function CopilotPopup(props) {
|
|
|
18
18
|
export {
|
|
19
19
|
CopilotPopup
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-NCM42YQL.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CopilotModal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7D6TIVZ6.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__spreadProps,
|
|
6
6
|
__spreadValues
|
|
@@ -27,4 +27,4 @@ function CopilotSidebar(props) {
|
|
|
27
27
|
export {
|
|
28
28
|
CopilotSidebar
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
30
|
+
//# sourceMappingURL=chunk-PGXWPTAW.mjs.map
|
|
@@ -15,20 +15,20 @@ import {
|
|
|
15
15
|
} from "./chunk-3VNMQWGT.mjs";
|
|
16
16
|
import {
|
|
17
17
|
RenderActionExecutionMessage
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-XB6QCUPB.mjs";
|
|
19
19
|
import {
|
|
20
20
|
Suggestion,
|
|
21
21
|
reloadSuggestions
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-WGAZXTUA.mjs";
|
|
23
23
|
import {
|
|
24
24
|
CopilotDevConsole
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-VY62BA22.mjs";
|
|
26
26
|
import {
|
|
27
27
|
Input
|
|
28
28
|
} from "./chunk-EMQEEXUB.mjs";
|
|
29
29
|
import {
|
|
30
30
|
Messages
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-6FTRYYR5.mjs";
|
|
32
32
|
import {
|
|
33
33
|
ResponseButton
|
|
34
34
|
} from "./chunk-3XAXY2Z3.mjs";
|
|
@@ -311,4 +311,4 @@ export {
|
|
|
311
311
|
WrappedCopilotChat,
|
|
312
312
|
useCopilotChatLogic
|
|
313
313
|
};
|
|
314
|
-
//# sourceMappingURL=chunk-
|
|
314
|
+
//# sourceMappingURL=chunk-Q77YGF2I.mjs.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
logMessages,
|
|
5
5
|
logReadables,
|
|
6
6
|
shouldShowDevConsole
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6TCUJ3B7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
CopilotKitHelpModal
|
|
10
10
|
} from "./chunk-TI7SY2RI.mjs";
|
|
@@ -229,4 +229,4 @@ export {
|
|
|
229
229
|
CopilotDevConsole,
|
|
230
230
|
DebugMenuButton
|
|
231
231
|
};
|
|
232
|
-
//# sourceMappingURL=chunk-
|
|
232
|
+
//# sourceMappingURL=chunk-VY62BA22.mjs.map
|
|
@@ -22,6 +22,7 @@ function Suggestion({ title, message, onClick, partial, className }) {
|
|
|
22
22
|
onClick(message);
|
|
23
23
|
},
|
|
24
24
|
className: className || "suggestion",
|
|
25
|
+
"data-test-id": "suggestion",
|
|
25
26
|
children: [
|
|
26
27
|
partial && SmallSpinnerIcon,
|
|
27
28
|
/* @__PURE__ */ jsx("span", { children: title })
|
|
@@ -103,4 +104,4 @@ export {
|
|
|
103
104
|
Suggestion,
|
|
104
105
|
reloadSuggestions
|
|
105
106
|
};
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-WGAZXTUA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/Suggestion.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n CopilotMessagesContextParams,\n} from \"@copilotkit/react-core\";\nimport { SuggestionsProps } from \"./props\";\nimport { SmallSpinnerIcon } from \"./Icons\";\nimport { CopilotChatSuggestion } from \"../../types/suggestions\";\nimport { actionParametersToJsonSchema } from \"@copilotkit/shared\";\nimport { CopilotRequestType } from \"@copilotkit/runtime-client-gql\";\n\nexport function Suggestion({ title, message, onClick, partial, className }: SuggestionsProps) {\n return (\n <button\n disabled={partial}\n onClick={(e) => {\n e.preventDefault();\n onClick(message);\n }}\n className={className || \"suggestion\"}\n data-test-id=\"suggestion\"\n >\n {partial && SmallSpinnerIcon}\n <span>{title}</span>\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams & CopilotMessagesContextParams,\n chatSuggestionConfiguration: { [key: string]: CopilotChatSuggestionConfiguration },\n setCurrentSuggestions: (suggestions: { title: string; message: string }[]) => void,\n abortControllerRef: React.MutableRefObject<AbortController | null>,\n) => {\n const abortController = abortControllerRef.current;\n\n const tools = JSON.stringify(\n Object.values(context.actions).map((action) => ({\n name: action.name,\n description: action.description,\n jsonSchema: JSON.stringify(actionParametersToJsonSchema(action.parameters)),\n })),\n );\n\n const allSuggestions: CopilotChatSuggestion[] = [];\n\n for (const config of Object.values(chatSuggestionConfiguration)) {\n try {\n const numOfSuggestionsInstructions =\n config.minSuggestions === 0\n ? `Produce up to ${config.maxSuggestions} suggestions. ` +\n `If there are no highly relevant suggestions you can think of, provide an empty array.`\n : `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;\n\n const result = await extract({\n context,\n instructions:\n \"Suggest what the user could say next. Provide clear, highly relevant suggestions. Do not literally suggest function calls. \",\n data:\n config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions +\n \"\\n\\n\" +\n \"Available tools: \" +\n tools +\n \"\\n\\n\",\n requestType: CopilotRequestType.Task,\n parameters: [\n {\n name: \"suggestions\",\n type: \"object[]\",\n attributes: [\n {\n name: \"title\",\n description:\n \"The title of the suggestion. This is shown as a button and should be short.\",\n type: \"string\",\n },\n {\n name: \"message\",\n description:\n \"The message to send when the suggestion is clicked. This should be a clear, complete sentence and will be sent as an instruction to the AI.\",\n type: \"string\",\n },\n ],\n },\n ],\n include: {\n messages: true,\n readable: true,\n },\n abortSignal: abortController?.signal,\n stream: ({ status, args }) => {\n const suggestions = args.suggestions || [];\n const newSuggestions: CopilotChatSuggestion[] = [];\n for (let i = 0; i < suggestions.length; i++) {\n // if GPT provides too many suggestions, limit the number of suggestions\n if (config.maxSuggestions !== undefined && i >= config.maxSuggestions) {\n break;\n }\n const { title, message } = suggestions[i];\n\n // If this is the last suggestion and the status is not complete, mark it as partial\n const partial = i == suggestions.length - 1 && status !== \"complete\";\n\n newSuggestions.push({\n title,\n message,\n partial,\n className: config.className,\n });\n }\n setCurrentSuggestions([...allSuggestions, ...newSuggestions]);\n },\n });\n allSuggestions.push(...result.suggestions);\n } catch (error) {\n console.error(\"Error loading suggestions\", error);\n }\n }\n\n if (abortControllerRef.current === abortController) {\n abortControllerRef.current = null;\n }\n};\n"],"mappings":";;;;;;;;AAAA;AAAA,EAEE;AAAA,OAGK;AAIP,SAAS,oCAAoC;AAC7C,SAAS,0BAA0B;AAI/B,SAUE,KAVF;AAFG,SAAS,WAAW,EAAE,OAAO,SAAS,SAAS,SAAS,UAAU,GAAqB;AAC5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,SAAS,CAAC,MAAM;AACd,UAAE,eAAe;AACjB,gBAAQ,OAAO;AAAA,MACjB;AAAA,MACA,WAAW,aAAa;AAAA,MACxB,gBAAa;AAAA,MAEZ;AAAA,mBAAW;AAAA,QACZ,oBAAC,UAAM,iBAAM;AAAA;AAAA;AAAA,EACf;AAEJ;AAEO,IAAM,oBAAoB,CAC/B,SACA,6BACA,uBACA,uBACG;AACH,QAAM,kBAAkB,mBAAmB;AAE3C,QAAM,QAAQ,KAAK;AAAA,IACjB,OAAO,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,YAAY;AAAA,MAC9C,MAAM,OAAO;AAAA,MACb,aAAa,OAAO;AAAA,MACpB,YAAY,KAAK,UAAU,6BAA6B,OAAO,UAAU,CAAC;AAAA,IAC5E,EAAE;AAAA,EACJ;AAEA,QAA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,OAAP;AACA,cAAQ,MAAM,6BAA6B,KAAK;AAAA,IAClD;AAAA,EACF;AAEA,MAAI,mBAAmB,YAAY,iBAAiB;AAClD,uBAAmB,UAAU;AAAA,EAC/B;AACF;","names":[]}
|
|
@@ -76,13 +76,13 @@ function RenderActionExecutionMessage(props) {
|
|
|
76
76
|
"data-message-role": "assistant",
|
|
77
77
|
isLoading: false,
|
|
78
78
|
isGenerating: false,
|
|
79
|
-
subComponent: /* @__PURE__ */ jsxs("div", { children: [
|
|
79
|
+
subComponent: /* @__PURE__ */ jsxs("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
|
|
80
80
|
/* @__PURE__ */ jsxs("b", { children: [
|
|
81
|
-
"\u274C Error executing render
|
|
82
|
-
message.name
|
|
81
|
+
"\u274C Error executing render function for action ",
|
|
82
|
+
message.name,
|
|
83
|
+
":"
|
|
83
84
|
] }),
|
|
84
|
-
/* @__PURE__ */ jsx("
|
|
85
|
-
e instanceof Error ? e.message : String(e)
|
|
85
|
+
/* @__PURE__ */ jsx("pre", { children: e instanceof Error ? e.message : String(e) })
|
|
86
86
|
] })
|
|
87
87
|
},
|
|
88
88
|
index
|
|
@@ -109,4 +109,4 @@ function RenderActionExecutionMessage(props) {
|
|
|
109
109
|
export {
|
|
110
110
|
RenderActionExecutionMessage
|
|
111
111
|
};
|
|
112
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-XB6QCUPB.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/messages/RenderActionExecutionMessage.tsx"],"sourcesContent":["import { MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { RenderMessageProps } from \"../props\";\nimport { RenderFunctionStatus, useCopilotContext } from \"@copilotkit/react-core\";\n\nexport function RenderActionExecutionMessage(props: RenderMessageProps) {\n const { chatComponentsCache } = useCopilotContext();\n const { message, inProgress, index, isCurrentMessage, actionResult, AssistantMessage } = props;\n\n if (message.isActionExecutionMessage()) {\n if (\n chatComponentsCache.current !== null &&\n (chatComponentsCache.current.actions[message.name] ||\n chatComponentsCache.current.actions[\"*\"])\n ) {\n const render =\n chatComponentsCache.current.actions[message.name] ||\n chatComponentsCache.current.actions[\"*\"];\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 <AssistantMessage\n rawData={message}\n key={index}\n data-message-role=\"assistant\"\n isLoading={false}\n isGenerating={true}\n message={render}\n />\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 (actionResult !== undefined) {\n status = \"complete\";\n } else if (message.status.code !== MessageStatusCode.Pending) {\n status = \"executing\";\n }\n\n try {\n const toRender = render({\n status: status as any,\n args,\n result: actionResult,\n name: message.name,\n });\n // No result and complete: stay silent\n if (!toRender && status === \"complete\") {\n return null;\n }\n if (typeof toRender === \"string\") {\n return (\n <AssistantMessage\n rawData={message}\n data-message-role=\"assistant\"\n key={index}\n isLoading={false}\n isGenerating={false}\n message={toRender}\n />\n );\n } else {\n return (\n <AssistantMessage\n rawData={message}\n data-message-role=\"action-render\"\n key={index}\n isLoading={false}\n isGenerating={false}\n subComponent={toRender}\n />\n );\n }\n } catch (e) {\n console.error(`Error executing render function for action ${message.name}: ${e}`);\n return (\n <AssistantMessage\n rawData={message}\n data-message-role=\"assistant\"\n key={index}\n isLoading={false}\n isGenerating={false}\n subComponent={\n <div>\n <b>❌ Error executing render
|
|
1
|
+
{"version":3,"sources":["../src/components/chat/messages/RenderActionExecutionMessage.tsx"],"sourcesContent":["import { MessageStatusCode } from \"@copilotkit/runtime-client-gql\";\nimport { RenderMessageProps } from \"../props\";\nimport { RenderFunctionStatus, useCopilotContext } from \"@copilotkit/react-core\";\n\nexport function RenderActionExecutionMessage(props: RenderMessageProps) {\n const { chatComponentsCache } = useCopilotContext();\n const { message, inProgress, index, isCurrentMessage, actionResult, AssistantMessage } = props;\n\n if (message.isActionExecutionMessage()) {\n if (\n chatComponentsCache.current !== null &&\n (chatComponentsCache.current.actions[message.name] ||\n chatComponentsCache.current.actions[\"*\"])\n ) {\n const render =\n chatComponentsCache.current.actions[message.name] ||\n chatComponentsCache.current.actions[\"*\"];\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 <AssistantMessage\n rawData={message}\n key={index}\n data-message-role=\"assistant\"\n isLoading={false}\n isGenerating={true}\n message={render}\n />\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 (actionResult !== undefined) {\n status = \"complete\";\n } else if (message.status.code !== MessageStatusCode.Pending) {\n status = \"executing\";\n }\n\n try {\n const toRender = render({\n status: status as any,\n args,\n result: actionResult,\n name: message.name,\n });\n // No result and complete: stay silent\n if (!toRender && status === \"complete\") {\n return null;\n }\n if (typeof toRender === \"string\") {\n return (\n <AssistantMessage\n rawData={message}\n data-message-role=\"assistant\"\n key={index}\n isLoading={false}\n isGenerating={false}\n message={toRender}\n />\n );\n } else {\n return (\n <AssistantMessage\n rawData={message}\n data-message-role=\"action-render\"\n key={index}\n isLoading={false}\n isGenerating={false}\n subComponent={toRender}\n />\n );\n }\n } catch (e) {\n console.error(`Error executing render function for action ${message.name}: ${e}`);\n return (\n <AssistantMessage\n rawData={message}\n data-message-role=\"assistant\"\n key={index}\n isLoading={false}\n isGenerating={false}\n subComponent={\n <div className=\"copilotKitMessage copilotKitAssistantMessage\">\n <b>❌ Error executing render function for action {message.name}:</b>\n <pre>{e instanceof Error ? e.message : String(e)}</pre>\n </div>\n }\n />\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 <AssistantMessage\n r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B,WAAW;AAAA,gBACX,cAAc;AAAA,gBACd,SAAS;AAAA;AAAA,cAHJ;AAAA,YAIP;AAAA,UAEJ,OAAO;AACL,mBACE;AAAA,cAAC;AAAA;AAAA,gBACC,SAAS;AAAA,gBACT,qBAAkB;AAAA,gBAElB,WAAW;AAAA,gBACX,cAAc;AAAA,gBACd,cAAc;AAAA;AAAA,cAHT;AAAA,YAIP;AAAA,UAEJ;AAAA,QACF,SAAS,GAAP;AACA,kBAAQ,MAAM,8CAA8C,QAAQ,SAAS,GAAG;AAChF,iBACE;AAAA,YAAC;AAAA;AAAA,cACC,SAAS;AAAA,cACT,qBAAkB;AAAA,cAElB,WAAW;AAAA,cACX,cAAc;AAAA,cACd,cACE,qBAAC,SAAI,WAAU,gDACb;AAAA,qCAAC,OAAE;AAAA;AAAA,kBAA8C,QAAQ;AAAA,kBAAK;AAAA,mBAAC;AAAA,gBAC/D,oBAAC,SAAK,uBAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,GAAE;AAAA,iBACnD;AAAA;AAAA,YAPG;AAAA,UASP;AAAA,QAEJ;AAAA,MACF;AAAA,IACF,WAES,CAAC,cAAc,CAAC,kBAAkB;AAEzC,aAAO;AAAA,IACT,OAAO;AAEL,aACE;AAAA,QAAC;AAAA;AAAA,UACC,SAAS;AAAA,UAET,qBAAkB;AAAA,UAClB,WAAW;AAAA,UACX,cAAc;AAAA;AAAA,QAHT;AAAA,MAIP;AAAA,IAEJ;AAAA,EACF;AACF;","names":[]}
|
|
@@ -3,6 +3,7 @@ import { useEffect } from "react";
|
|
|
3
3
|
import { useCopilotContext } from "@copilotkit/react-core";
|
|
4
4
|
import { randomId } from "@copilotkit/shared";
|
|
5
5
|
function useCopilotChatSuggestions({
|
|
6
|
+
available = "enabled",
|
|
6
7
|
instructions,
|
|
7
8
|
className,
|
|
8
9
|
minSuggestions = 1,
|
|
@@ -10,6 +11,8 @@ function useCopilotChatSuggestions({
|
|
|
10
11
|
}, dependencies = []) {
|
|
11
12
|
const context = useCopilotContext();
|
|
12
13
|
useEffect(() => {
|
|
14
|
+
if (available === "disabled")
|
|
15
|
+
return;
|
|
13
16
|
const id = randomId();
|
|
14
17
|
context.addChatSuggestionConfiguration(id, {
|
|
15
18
|
instructions,
|
|
@@ -20,10 +23,10 @@ function useCopilotChatSuggestions({
|
|
|
20
23
|
return () => {
|
|
21
24
|
context.removeChatSuggestionConfiguration(id);
|
|
22
25
|
};
|
|
23
|
-
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className]);
|
|
26
|
+
}, [...dependencies, instructions, minSuggestions, maxSuggestions, className, available]);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
export {
|
|
27
30
|
useCopilotChatSuggestions
|
|
28
31
|
};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
32
|
+
//# sourceMappingURL=chunk-Z4XPPVZT.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\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 * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\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, instructions, minSuggestions, maxSuggestions, className]);\n}\n"],"mappings":";AA6DA,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-copilot-chat-suggestions.tsx"],"sourcesContent":["/**\n * <Callout type=\"warning\">\n * useCopilotChatSuggestions is experimental. The interface is not final and\n * can change without notice.\n * </Callout>\n *\n * `useCopilotReadable` is a React hook that provides app-state and other information\n * to the Copilot. Optionally, the hook can also handle hierarchical state within your\n * application, passing these parent-child relationships to the Copilot.\n *\n * <br/>\n * <img src=\"/images/use-copilot-chat-suggestions/use-copilot-chat-suggestions.gif\" width=\"500\" />\n *\n * ## Usage\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 * ### Simple Usage\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * const [employees, setEmployees] = useState([]);\n *\n * useCopilotChatSuggestions({\n * instructions: `The following employees are on duty: ${JSON.stringify(employees)}`,\n * });\n * }\n * ```\n *\n * ### Dependency Management\n *\n * ```tsx\n * import { useCopilotChatSuggestions } from \"@copilotkit/react-ui\";\n *\n * export function MyComponent() {\n * useCopilotChatSuggestions(\n * {\n * instructions: \"Suggest the most relevant next actions.\",\n * },\n * [appState],\n * );\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 /**\n * Whether the suggestions are available. Defaults to `enabled`.\n * @default enabled\n */\n available?: \"enabled\" | \"disabled\";\n\n /**\n * An optional class name to apply to the suggestions.\n */\n className?: string;\n}\n\nexport function useCopilotChatSuggestions(\n {\n available = \"enabled\",\n instructions,\n className,\n minSuggestions = 1,\n maxSuggestions = 3,\n }: UseCopilotChatSuggestionsConfiguration,\n dependencies: any[] = [],\n) {\n const context = useCopilotContext();\n\n useEffect(() => {\n if (available === \"disabled\") return;\n\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, instructions, minSuggestions, maxSuggestions, className, available]);\n}\n"],"mappings":";AA6DA,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AA8BlB,SAAS,0BACd;AAAA,EACE,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,iBAAiB;AACnB,GACA,eAAsB,CAAC,GACvB;AACA,QAAM,UAAU,kBAAkB;AAElC,YAAU,MAAM;AACd,QAAI,cAAc;AAAY;AAE9B,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,CAAC,GAAG,cAAc,cAAc,gBAAgB,gBAAgB,WAAW,SAAS,CAAC;AAC1F;","names":[]}
|