@copilotkit/react-ui 1.1.1-feat-runtime-remote-actions.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -5
- package/dist/{chunk-JC7QYDYI.mjs → chunk-4Z2WDXSK.mjs} +2 -8
- package/dist/chunk-4Z2WDXSK.mjs.map +1 -0
- package/dist/{chunk-VE4TIYL6.mjs → chunk-D6QNFZXK.mjs} +2 -4
- package/dist/chunk-D6QNFZXK.mjs.map +1 -0
- package/dist/{chunk-TOCSYTIB.mjs → chunk-EJ4SJ2HU.mjs} +2 -2
- package/dist/chunk-EJ4SJ2HU.mjs.map +1 -0
- package/dist/{chunk-WCPLXRZX.mjs → chunk-KSCXPA74.mjs} +1 -1
- package/dist/chunk-KSCXPA74.mjs.map +1 -0
- package/dist/{chunk-BWXEQ7ZU.mjs → chunk-PF5HUDUP.mjs} +2 -54
- package/dist/chunk-PF5HUDUP.mjs.map +1 -0
- package/dist/{chunk-ZIZZGFE2.mjs → chunk-SWWFXRFF.mjs} +7 -32
- package/dist/chunk-SWWFXRFF.mjs.map +1 -0
- package/dist/{chunk-MNEGEFTI.mjs → chunk-UJHTRHS4.mjs} +2 -2
- package/dist/chunk-UJHTRHS4.mjs.map +1 -0
- package/dist/{chunk-6UDD2RWZ.mjs → chunk-WOPUCUQK.mjs} +3 -3
- package/dist/components/chat/Chat.d.ts +22 -36
- package/dist/components/chat/Chat.js +4 -85
- package/dist/components/chat/Chat.js.map +1 -1
- package/dist/components/chat/Chat.mjs +5 -5
- package/dist/components/chat/Messages.js +0 -5
- package/dist/components/chat/Messages.js.map +1 -1
- package/dist/components/chat/Messages.mjs +1 -1
- package/dist/components/chat/Modal.js +4 -85
- package/dist/components/chat/Modal.js.map +1 -1
- package/dist/components/chat/Modal.mjs +6 -6
- package/dist/components/chat/Popup.d.ts +19 -35
- package/dist/components/chat/Popup.js +4 -85
- package/dist/components/chat/Popup.js.map +1 -1
- package/dist/components/chat/Popup.mjs +7 -7
- package/dist/components/chat/Sidebar.js +4 -85
- package/dist/components/chat/Sidebar.js.map +1 -1
- package/dist/components/chat/Sidebar.mjs +7 -7
- package/dist/components/chat/Suggestion.js.map +1 -1
- package/dist/components/chat/Suggestion.mjs +1 -1
- package/dist/components/chat/index.js +4 -85
- package/dist/components/chat/index.js.map +1 -1
- package/dist/components/chat/index.mjs +8 -8
- package/dist/components/dev-console/console.js +0 -52
- 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 +0 -52
- 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.d.ts +1 -2
- package/dist/components/dev-console/utils.js +0 -53
- package/dist/components/dev-console/utils.js.map +1 -1
- package/dist/components/dev-console/utils.mjs +1 -3
- package/dist/components/index.js +4 -85
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +8 -8
- package/dist/index.js +4 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/package.json +8 -8
- package/src/components/chat/Chat.tsx +24 -66
- package/src/components/chat/Messages.tsx +0 -26
- package/src/components/chat/Popup.tsx +19 -35
- package/src/components/chat/Sidebar.tsx +20 -35
- package/src/components/chat/Suggestion.tsx +0 -2
- package/src/components/dev-console/console.tsx +0 -6
- package/src/components/dev-console/utils.ts +0 -56
- package/dist/chunk-BWXEQ7ZU.mjs.map +0 -1
- package/dist/chunk-JC7QYDYI.mjs.map +0 -1
- package/dist/chunk-MNEGEFTI.mjs.map +0 -1
- package/dist/chunk-TOCSYTIB.mjs.map +0 -1
- package/dist/chunk-VE4TIYL6.mjs.map +0 -1
- package/dist/chunk-WCPLXRZX.mjs.map +0 -1
- package/dist/chunk-ZIZZGFE2.mjs.map +0 -1
- /package/dist/{chunk-6UDD2RWZ.mjs.map → chunk-WOPUCUQK.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -4,26 +4,26 @@ import "./chunk-JD7BAH7U.mjs";
|
|
|
4
4
|
import "./chunk-MRFF7GSQ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
CopilotSidebar
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UJHTRHS4.mjs";
|
|
8
8
|
import "./chunk-WB3YULQ4.mjs";
|
|
9
9
|
import {
|
|
10
10
|
CopilotPopup
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-EJ4SJ2HU.mjs";
|
|
12
|
+
import "./chunk-WOPUCUQK.mjs";
|
|
13
13
|
import "./chunk-LLOSOTAT.mjs";
|
|
14
14
|
import "./chunk-SE6DAYSX.mjs";
|
|
15
15
|
import "./chunk-UC3Y7MWX.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CopilotChat
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SWWFXRFF.mjs";
|
|
19
19
|
import "./chunk-V7W6IM2V.mjs";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-KSCXPA74.mjs";
|
|
21
|
+
import "./chunk-D6QNFZXK.mjs";
|
|
22
|
+
import "./chunk-PF5HUDUP.mjs";
|
|
23
23
|
import "./chunk-OTPAZXVR.mjs";
|
|
24
24
|
import "./chunk-U6J5DGOE.mjs";
|
|
25
25
|
import "./chunk-YQFVRDNC.mjs";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-4Z2WDXSK.mjs";
|
|
27
27
|
import "./chunk-YQ3D5IQV.mjs";
|
|
28
28
|
import "./chunk-XSUSSWDS.mjs";
|
|
29
29
|
import {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.1.
|
|
12
|
+
"version": "1.1.2",
|
|
13
13
|
"sideEffects": [
|
|
14
14
|
"**/*.css"
|
|
15
15
|
],
|
|
@@ -40,19 +40,19 @@
|
|
|
40
40
|
"ts-jest": "^29.1.1",
|
|
41
41
|
"tsup": "^6.7.0",
|
|
42
42
|
"typescript": "^5.2.3",
|
|
43
|
-
"eslint-config-custom": "1.1.1
|
|
44
|
-
"tailwind-config": "1.1.1
|
|
45
|
-
"tsconfig": "1.1.1
|
|
43
|
+
"eslint-config-custom": "1.1.1",
|
|
44
|
+
"tailwind-config": "1.1.1",
|
|
45
|
+
"tsconfig": "1.1.1"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@headlessui/react": "
|
|
48
|
+
"@headlessui/react": "2.1.1",
|
|
49
49
|
"react-markdown": "^8.0.7",
|
|
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.1.
|
|
54
|
-
"@copilotkit/runtime-client-gql": "1.1.
|
|
55
|
-
"@copilotkit/shared": "1.1.
|
|
53
|
+
"@copilotkit/react-core": "1.1.2",
|
|
54
|
+
"@copilotkit/runtime-client-gql": "1.1.2",
|
|
55
|
+
"@copilotkit/shared": "1.1.2"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|
|
58
58
|
"copilotkit",
|
|
@@ -5,7 +5,15 @@
|
|
|
5
5
|
* A chatbot panel component for the CopilotKit framework. The component allows for a high degree
|
|
6
6
|
* of customization through various props and custom CSS.
|
|
7
7
|
*
|
|
8
|
-
* ##
|
|
8
|
+
* ## Install Dependencies
|
|
9
|
+
*
|
|
10
|
+
* This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
|
|
11
|
+
*
|
|
12
|
+
* ```shell npm2yarn \"@copilotkit/react-ui"\
|
|
13
|
+
* npm install @copilotkit/react-core @copilotkit/react-ui
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ## Usage
|
|
9
17
|
*
|
|
10
18
|
* ```tsx
|
|
11
19
|
* import { CopilotChat } from "@copilotkit/react-ui";
|
|
@@ -18,44 +26,22 @@
|
|
|
18
26
|
* />
|
|
19
27
|
* ```
|
|
20
28
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* ### Install Dependencies
|
|
24
|
-
*
|
|
25
|
-
* This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
|
|
29
|
+
* ### Look & Feel
|
|
26
30
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* ### Custom Styles
|
|
32
|
-
*
|
|
33
|
-
* To opt-in for the built-in styles, make sure to import the following at the root of your application:
|
|
34
|
-
*
|
|
35
|
-
* ```tsx
|
|
31
|
+
* By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
|
|
32
|
+
* ```tsx fileName="YourRootComponent.tsx" {2}
|
|
33
|
+
* ...
|
|
36
34
|
* import "@copilotkit/react-ui/styles.css";
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* You can customize the colors of the panel by overriding the CSS variables
|
|
40
|
-
* defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).
|
|
41
|
-
*
|
|
42
|
-
* For example, to set the primary color to purple:
|
|
43
35
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* To further customize the chat window, you can override the CSS classes defined
|
|
51
|
-
* [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).
|
|
52
|
-
*
|
|
53
|
-
* For example:
|
|
54
|
-
*
|
|
55
|
-
* ```css
|
|
56
|
-
* .copilotKitButton {
|
|
57
|
-
* border-radius: 0;
|
|
36
|
+
* export function YourRootComponent() {
|
|
37
|
+
* return (
|
|
38
|
+
* <CopilotKit>
|
|
39
|
+
* ...
|
|
40
|
+
* </CopilotKit>
|
|
41
|
+
* );
|
|
58
42
|
* }
|
|
43
|
+
* ```
|
|
44
|
+
* For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.
|
|
59
45
|
*/
|
|
60
46
|
|
|
61
47
|
import {
|
|
@@ -72,7 +58,7 @@ import React, { useEffect, useRef, useState } from "react";
|
|
|
72
58
|
import { SystemMessageFunction, useCopilotChat, useCopilotContext } from "@copilotkit/react-core";
|
|
73
59
|
import { reloadSuggestions } from "./Suggestion";
|
|
74
60
|
import { CopilotChatSuggestion } from "../../types/suggestions";
|
|
75
|
-
import { Message, Role, TextMessage
|
|
61
|
+
import { Message, Role, TextMessage } from "@copilotkit/runtime-client-gql";
|
|
76
62
|
import { InputProps, MessagesProps, ResponseButtonProps } from "./props";
|
|
77
63
|
import { randomId } from "@copilotkit/shared";
|
|
78
64
|
|
|
@@ -243,7 +229,7 @@ const SUGGESTIONS_DEBOUNCE_TIMEOUT = 1000;
|
|
|
243
229
|
export const useCopilotChatLogic = (
|
|
244
230
|
makeSystemMessage?: SystemMessageFunction,
|
|
245
231
|
onInProgress?: (isLoading: boolean) => void,
|
|
246
|
-
onSubmitMessage?: (messageContent: string) =>
|
|
232
|
+
onSubmitMessage?: (messageContent: string) => void,
|
|
247
233
|
) => {
|
|
248
234
|
const { visibleMessages, appendMessage, reloadMessages, stopGeneration, isLoading } =
|
|
249
235
|
useCopilotChat({
|
|
@@ -307,35 +293,7 @@ export const useCopilotChatLogic = (
|
|
|
307
293
|
}
|
|
308
294
|
}
|
|
309
295
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (lastMessage instanceof AgentMessage) {
|
|
313
|
-
const newState = {
|
|
314
|
-
...lastMessage.state,
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
newState.coagent ||= {};
|
|
318
|
-
newState.coagent.execute ||= { name: "ask" };
|
|
319
|
-
newState.coagent.execute.result = { answer: messageContent };
|
|
320
|
-
|
|
321
|
-
const message = new AgentMessage({
|
|
322
|
-
role: Role.User,
|
|
323
|
-
agentName: lastMessage.agentName,
|
|
324
|
-
nodeName: lastMessage.nodeName,
|
|
325
|
-
state: newState,
|
|
326
|
-
running: lastMessage.running,
|
|
327
|
-
threadId: lastMessage.threadId,
|
|
328
|
-
});
|
|
329
|
-
appendMessage(message);
|
|
330
|
-
return message;
|
|
331
|
-
} else {
|
|
332
|
-
const message: Message = new TextMessage({
|
|
333
|
-
content: messageContent,
|
|
334
|
-
role: Role.User,
|
|
335
|
-
});
|
|
336
|
-
appendMessage(message);
|
|
337
|
-
return message;
|
|
338
|
-
}
|
|
296
|
+
return message;
|
|
339
297
|
};
|
|
340
298
|
|
|
341
299
|
return {
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
ResultMessage,
|
|
11
11
|
TextMessage,
|
|
12
12
|
Role,
|
|
13
|
-
AgentMessage,
|
|
14
13
|
} from "@copilotkit/runtime-client-gql";
|
|
15
14
|
|
|
16
15
|
export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
|
|
@@ -63,17 +62,6 @@ export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
|
|
|
63
62
|
{message.content}
|
|
64
63
|
</div>
|
|
65
64
|
);
|
|
66
|
-
} else if (
|
|
67
|
-
message instanceof AgentMessage &&
|
|
68
|
-
message.role === "user" &&
|
|
69
|
-
message.state?.coagent?.execute?.name === "ask" &&
|
|
70
|
-
message.state?.coagent?.execute?.result?.answer
|
|
71
|
-
) {
|
|
72
|
-
return (
|
|
73
|
-
<div key={index} className="copilotKitMessage copilotKitUserMessage">
|
|
74
|
-
{message.state?.coagent?.execute?.result?.answer}
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
65
|
} else if (message instanceof TextMessage && message.role == "assistant") {
|
|
78
66
|
return (
|
|
79
67
|
<div key={index} className={`copilotKitMessage copilotKitAssistantMessage`}>
|
|
@@ -84,20 +72,6 @@ export const Messages = ({ messages, inProgress, children }: MessagesProps) => {
|
|
|
84
72
|
)}
|
|
85
73
|
</div>
|
|
86
74
|
);
|
|
87
|
-
} else if (
|
|
88
|
-
message instanceof AgentMessage &&
|
|
89
|
-
message.role === "assistant" &&
|
|
90
|
-
((message.state?.coagent?.execute?.name === "ask" &&
|
|
91
|
-
message.state?.coagent?.execute?.arguments?.question) ||
|
|
92
|
-
(message.state?.coagent?.execute?.name === "message" &&
|
|
93
|
-
message.state?.coagent?.execute?.arguments?.text))
|
|
94
|
-
) {
|
|
95
|
-
return (
|
|
96
|
-
<div key={index} className="copilotKitMessage copilotKitAssistantMessage">
|
|
97
|
-
{message.state?.coagent?.execute?.arguments?.question ||
|
|
98
|
-
message.state?.coagent?.execute?.arguments?.text}
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
75
|
} else if (message instanceof ActionExecutionMessage) {
|
|
102
76
|
if (chatComponentsCache.current !== null && chatComponentsCache.current[message.name]) {
|
|
103
77
|
const render = chatComponentsCache.current[message.name];
|
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
*
|
|
8
8
|
* See [CopilotSidebar](/reference/components/CopilotSidebar) for a sidebar version of this component.
|
|
9
9
|
*
|
|
10
|
-
* ##
|
|
10
|
+
* ## Install Dependencies
|
|
11
|
+
*
|
|
12
|
+
* This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
|
|
13
|
+
*
|
|
14
|
+
* ```shell npm2yarn \"@copilotkit/react-ui"\
|
|
15
|
+
* npm install @copilotkit/react-core @copilotkit/react-ui
|
|
16
|
+
* ```
|
|
17
|
+
* ## Usage
|
|
11
18
|
*
|
|
12
19
|
* ```tsx
|
|
13
20
|
* import { CopilotPopup } from "@copilotkit/react-ui";
|
|
@@ -20,45 +27,22 @@
|
|
|
20
27
|
* />
|
|
21
28
|
* ```
|
|
22
29
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* ### Install Dependencies
|
|
26
|
-
*
|
|
27
|
-
* This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
|
|
28
|
-
*
|
|
29
|
-
* ```shell npm2yarn \"@copilotkit/react-ui"\
|
|
30
|
-
* npm install @copilotkit/react-core @copilotkit/react-ui
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* ### Custom Styles
|
|
34
|
-
*
|
|
35
|
-
* To opt-in for the built-in styles, make sure to import the following at the root of your application:
|
|
30
|
+
* ### Look & Feel
|
|
36
31
|
*
|
|
37
|
-
*
|
|
32
|
+
* By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
|
|
33
|
+
* ```tsx fileName="YourRootComponent.tsx" {2}
|
|
34
|
+
* ...
|
|
38
35
|
* import "@copilotkit/react-ui/styles.css";
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* You can customize the colors of the chat window by overriding the CSS variables
|
|
42
|
-
* defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).
|
|
43
|
-
*
|
|
44
|
-
* For example, to set the primary color to purple:
|
|
45
|
-
*
|
|
46
|
-
* ```tsx
|
|
47
|
-
* <div style={{ "--copilot-kit-primary-color": "#7D5BA6" }}>
|
|
48
|
-
* <CopilotPopup />
|
|
49
|
-
* </div>
|
|
50
|
-
* ```
|
|
51
|
-
*
|
|
52
|
-
* To further customize the chat window, you can override the CSS classes defined
|
|
53
|
-
* [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).
|
|
54
|
-
*
|
|
55
|
-
* For example:
|
|
56
36
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
37
|
+
* export function YourRootComponent() {
|
|
38
|
+
* return (
|
|
39
|
+
* <CopilotKit>
|
|
40
|
+
* ...
|
|
41
|
+
* </CopilotKit>
|
|
42
|
+
* );
|
|
60
43
|
* }
|
|
61
44
|
* ```
|
|
45
|
+
* For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.
|
|
62
46
|
*/
|
|
63
47
|
|
|
64
48
|
import { CopilotModal, CopilotModalProps } from "./Modal";
|
|
@@ -6,7 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
* See [CopilotPopup](/reference/components/CopilotPopup) for a popup version of this component.
|
|
8
8
|
*
|
|
9
|
-
* ##
|
|
9
|
+
* ## Install Dependencies
|
|
10
|
+
*
|
|
11
|
+
* This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
|
|
12
|
+
*
|
|
13
|
+
* ```shell npm2yarn \"@copilotkit/react-ui"\
|
|
14
|
+
* npm install @copilotkit/react-core @copilotkit/react-ui
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Usage
|
|
10
18
|
*
|
|
11
19
|
* ```tsx
|
|
12
20
|
* import { CopilotSidebar } from "@copilotkit/react-ui";
|
|
@@ -21,45 +29,22 @@
|
|
|
21
29
|
* </CopilotSidebar>
|
|
22
30
|
* ```
|
|
23
31
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* ### Install Dependencies
|
|
27
|
-
*
|
|
28
|
-
* This component is part of the [@copilotkit/react-ui](https://npmjs.com/package/@copilotkit/react-ui) package.
|
|
29
|
-
*
|
|
30
|
-
* ```shell npm2yarn \"@copilotkit/react-ui"\
|
|
31
|
-
* npm install @copilotkit/react-core @copilotkit/react-ui
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* ### Custom Styles
|
|
32
|
+
* ### Look & Feel
|
|
35
33
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
34
|
+
* By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
|
|
35
|
+
* ```tsx fileName="YourRootComponent.tsx" {2}
|
|
36
|
+
* ...
|
|
39
37
|
* import "@copilotkit/react-ui/styles.css";
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* You can customize the colors of the chat window by overriding the CSS variables
|
|
43
|
-
* defined in the [default styles](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/colors.css).
|
|
44
|
-
*
|
|
45
|
-
* For example, to set the primary color to purple:
|
|
46
|
-
*
|
|
47
|
-
* ```jsx
|
|
48
|
-
* <div style={{ "--copilot-kit-primary-color": "#7D5BA6" }}>
|
|
49
|
-
* <CopilotSidebar />
|
|
50
|
-
* </div>
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* To further customize the chat window, you can override the CSS classes defined
|
|
54
|
-
* [here](https://github.com/CopilotKit/CopilotKit/blob/main/CopilotKit/packages/react-ui/src/css/).
|
|
55
|
-
*
|
|
56
|
-
* For example:
|
|
57
38
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
39
|
+
* export function YourRootComponent() {
|
|
40
|
+
* return (
|
|
41
|
+
* <CopilotKit>
|
|
42
|
+
* ...
|
|
43
|
+
* </CopilotKit>
|
|
44
|
+
* );
|
|
61
45
|
* }
|
|
62
46
|
* ```
|
|
47
|
+
* For more information about how to customize the styles, check out the [Customize Look & Feel](/concepts/customize-look-and-feel) guide.
|
|
63
48
|
*/
|
|
64
49
|
import React, { useState } from "react";
|
|
65
50
|
import { CopilotModal, CopilotModalProps } from "./Modal";
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
CopilotContextParams,
|
|
3
3
|
extract,
|
|
4
4
|
CopilotChatSuggestionConfiguration,
|
|
5
|
-
useCopilotContext,
|
|
6
5
|
} from "@copilotkit/react-core";
|
|
7
6
|
import { SuggestionsProps } from "./props";
|
|
8
7
|
import { SmallSpinnerIcon } from "./Icons";
|
|
@@ -51,7 +50,6 @@ export const reloadSuggestions = async (
|
|
|
51
50
|
? `Produce up to ${config.maxSuggestions} suggestions. ` +
|
|
52
51
|
`If there are no highly relevant suggestions you can think of, provide an empty array.`
|
|
53
52
|
: `Produce between ${config.minSuggestions} and ${config.maxSuggestions} suggestions.`;
|
|
54
|
-
|
|
55
53
|
const result = await extract({
|
|
56
54
|
context,
|
|
57
55
|
instructions:
|
|
@@ -4,7 +4,6 @@ import { useCopilotContext } from "@copilotkit/react-core";
|
|
|
4
4
|
import {
|
|
5
5
|
getPublishedCopilotKitVersion,
|
|
6
6
|
logActions,
|
|
7
|
-
logMessages,
|
|
8
7
|
logReadables,
|
|
9
8
|
shouldShowDevConsole,
|
|
10
9
|
} from "./utils";
|
|
@@ -251,11 +250,6 @@ export default function DebugMenuButton({
|
|
|
251
250
|
Log Actions
|
|
252
251
|
</button>
|
|
253
252
|
</MenuItem>
|
|
254
|
-
<MenuItem>
|
|
255
|
-
<button className="copilotKitDebugMenuItem" onClick={() => logMessages(context)}>
|
|
256
|
-
Log Messages
|
|
257
|
-
</button>
|
|
258
|
-
</MenuItem>
|
|
259
253
|
<MenuItem>
|
|
260
254
|
<button className="copilotKitDebugMenuItem" onClick={() => checkForUpdates(true)}>
|
|
261
255
|
Check for Updates
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CopilotContextParams, defaultCopilotContextCategories } from "@copilotkit/react-core";
|
|
2
2
|
import { CopilotKitVersion } from "./types";
|
|
3
|
-
import { ActionExecutionMessage, ResultMessage, TextMessage } from "@copilotkit/runtime-client-gql";
|
|
4
|
-
import { AgentMessage } from "@copilotkit/runtime-client-gql";
|
|
5
3
|
|
|
6
4
|
export function shouldShowDevConsole(showDevConsole: boolean | "auto"): boolean {
|
|
7
5
|
if (typeof showDevConsole === "boolean") {
|
|
@@ -80,8 +78,6 @@ export async function getPublishedCopilotKitVersion(
|
|
|
80
78
|
}
|
|
81
79
|
|
|
82
80
|
export function logReadables(context: CopilotContextParams) {
|
|
83
|
-
console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
|
|
84
|
-
|
|
85
81
|
const readables = context.getContextString([], defaultCopilotContextCategories).trim();
|
|
86
82
|
if (readables.length === 0) {
|
|
87
83
|
console.log("No readables found");
|
|
@@ -91,8 +87,6 @@ export function logReadables(context: CopilotContextParams) {
|
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
export function logActions(context: CopilotContextParams) {
|
|
94
|
-
console.log("%cCurrent Actions:", "font-size: 16px; font-weight: bold;");
|
|
95
|
-
|
|
96
90
|
if (Object.values(context.actions).length === 0) {
|
|
97
91
|
console.log("No actions found");
|
|
98
92
|
return;
|
|
@@ -106,53 +100,3 @@ export function logActions(context: CopilotContextParams) {
|
|
|
106
100
|
console.groupEnd();
|
|
107
101
|
}
|
|
108
102
|
}
|
|
109
|
-
|
|
110
|
-
export function logMessages(context: CopilotContextParams) {
|
|
111
|
-
console.log("%cCurrent Messages:", "font-size: 16px; font-weight: bold;");
|
|
112
|
-
|
|
113
|
-
if (context.messages.length === 0) {
|
|
114
|
-
console.log("No messages found");
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const tableData = context.messages.map((message) => {
|
|
119
|
-
if (message instanceof TextMessage) {
|
|
120
|
-
return {
|
|
121
|
-
id: message.id,
|
|
122
|
-
type: "TextMessage",
|
|
123
|
-
role: message.role,
|
|
124
|
-
name: undefined,
|
|
125
|
-
scope: undefined,
|
|
126
|
-
content: message.content,
|
|
127
|
-
};
|
|
128
|
-
} else if (message instanceof ActionExecutionMessage) {
|
|
129
|
-
return {
|
|
130
|
-
id: message.id,
|
|
131
|
-
type: "ActionExecutionMessage",
|
|
132
|
-
role: undefined,
|
|
133
|
-
name: message.name,
|
|
134
|
-
scope: message.scope,
|
|
135
|
-
content: message.arguments,
|
|
136
|
-
};
|
|
137
|
-
} else if (message instanceof ResultMessage) {
|
|
138
|
-
return {
|
|
139
|
-
id: message.id,
|
|
140
|
-
type: "ResultMessage",
|
|
141
|
-
role: undefined,
|
|
142
|
-
name: message.actionName,
|
|
143
|
-
scope: message.actionExecutionId,
|
|
144
|
-
content: message.result,
|
|
145
|
-
};
|
|
146
|
-
} else if (message instanceof AgentMessage) {
|
|
147
|
-
return {
|
|
148
|
-
id: message.id,
|
|
149
|
-
type: `AgentMessage (running: ${message.running})`,
|
|
150
|
-
role: message.role,
|
|
151
|
-
name: message.agentName,
|
|
152
|
-
scope: message.threadId,
|
|
153
|
-
content: message.state,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
console.table(tableData);
|
|
158
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/dev-console/utils.ts"],"sourcesContent":["import { CopilotContextParams, defaultCopilotContextCategories } from \"@copilotkit/react-core\";\nimport { CopilotKitVersion } from \"./types\";\nimport { ActionExecutionMessage, ResultMessage, TextMessage } from \"@copilotkit/runtime-client-gql\";\nimport { AgentMessage } 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.stagingcopilotkit.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: CopilotContextParams) {\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 instanceof TextMessage) {\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 instanceof ActionExecutionMessage) {\n return {\n id: message.id,\n type: \"ActionExecutionMessage\",\n role: undefined,\n name: message.name,\n scope: message.scope,\n content: message.arguments,\n };\n } else if (message instanceof ResultMessage) {\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 instanceof AgentMessage) {\n return {\n id: message.id,\n type: `AgentMessage (running: ${message.running})`,\n role: message.role,\n name: message.agentName,\n scope: message.threadId,\n content: message.state,\n };\n }\n });\n console.table(tableData);\n}\n"],"mappings":";;;;;AAAA,SAA+B,uCAAuC;AAEtE,SAAS,wBAAwB,eAAe,mBAAmB;AACnE,SAAS,oBAAoB;AAEtB,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,OAAO,WAAW,eAAe,OAAO,UAAU;AACpD,WAAO,OAAO,SAAS;AAAA,EACzB;AACA,SAAO;AACT;AAEA,SAAsB,8BACpB,SACA,aAAsB,OACM;AAAA;AAC5B,UAAM,oBAAoB;AAC1B,UAAM,oBAAoB,aAAa,QAAQ,iBAAiB;AAChE,QAAI,qBAAqB,CAAC,YAAY;AACpC,UAAI;AACF,cAAM,gBAAmC,KAAK,MAAM,iBAAiB;AACrE,cAAM,UAAU,KAAK,KAAK;AAC1B,cAAM,OAAM,oBAAI,KAAK,GAAE,QAAQ;AAE/B,YACE,cAAc,YAAY,WAC1B,MAAM,IAAI,KAAK,cAAc,WAAW,EAAE,QAAQ,IAAI,SACtD;AACA,iBAAO;AAAA,QACT;AAAA,MACF,SAAS,OAAP;AACA,gBAAQ,MAAM,uDAAuD,KAAK;AAAA,MAC5E;AAAA,IACF;AAEA,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,4DAA4D;AAAA,QACvF,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,gBAAgB;AAAA,QAClB;AAAA,QACA,MAAM,KAAK,UAAU;AAAA,UACnB,UAAU;AAAA,YACR;AAAA,cACE,aAAa;AAAA,cACb,gBAAgB;AAAA,YAClB;AAAA,UACF;AAAA,QACF,CAAC;A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AQ,SAAS,IAAI,CAAC,YAAY;AAClD,QAAI,mBAAmB,aAAa;AAClC,aAAO;AAAA,QACL,IAAI,QAAQ;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,QAAQ;AAAA,QACd,MAAM;AAAA,QACN,OAAO;AAAA,QACP,SAAS,QAAQ;AAAA,MACnB;AAAA,IACF,WAAW,mBAAmB,wBAAwB;AACpD,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,mBAAmB,eAAe;AAC3C,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,mBAAmB,cAAc;AAC1C,aAAO;AAAA,QACL,IAAI,QAAQ;AAAA,QACZ,MAAM,0BAA0B,QAAQ;AAAA,QACxC,MAAM,QAAQ;AAAA,QACd,MAAM,QAAQ;AAAA,QACd,OAAO,QAAQ;AAAA,QACf,SAAS,QAAQ;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACD,UAAQ,MAAM,SAAS;AACzB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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 AgentMessage,\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 (\n message instanceof AgentMessage &&\n message.role === \"user\" &&\n message.state?.coagent?.execute?.name === \"ask\" &&\n message.state?.coagent?.execute?.result?.answer\n ) {\n return (\n <div key={index} className=\"copilotKitMessage copilotKitUserMessage\">\n {message.state?.coagent?.execute?.result?.answer}\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 (\n message instanceof AgentMessage &&\n message.role === \"assistant\" &&\n ((message.state?.coagent?.execute?.name === \"ask\" &&\n message.state?.coagent?.execute?.arguments?.question) ||\n (message.state?.coagent?.execute?.name === \"message\" &&\n message.state?.coagent?.execute?.arguments?.text))\n ) {\n return (\n <div key={index} className=\"copilotKitMessage copilotKitAssistantMessage\">\n {message.state?.coagent?.execute?.arguments?.question ||\n message.state?.coagent?.execute?.arguments?.text}\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: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O,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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/Sidebar.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"/images/CopilotSidebar.gif\" width=\"500\" />\n *\n * A chatbot sidebar component for the CopilotKit framework. Highly customizable through various props and custom CSS.\n *\n * See [CopilotPopup](/reference/components/CopilotPopup) for a popup version of this component.\n *\n * ## Example\n *\n * ```tsx\n * import { CopilotSidebar } from \"@copilotkit/react-ui\";\n *\n * <CopilotSidebar\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * >\n * <YourApp/>\n * </CopilotSidebar>\n * ```\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 * ### Custom Styles\n *\n * To opt-in for the built-in styles, make sure to import the following at the root of your application:\n *\n * ```tsx\n * import \"@copilotkit/react-ui/styles.css\";\n * ```\n *\n * You can customize the colors of the chat window 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 * <CopilotSidebar />\n * </div>\n * ```\n *\n * To further customize the chat window, 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 */\nimport React, { useState } from \"react\";\nimport { CopilotModal, CopilotModalProps } from \"./Modal\";\n\nexport function CopilotSidebar(props: CopilotModalProps) {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitSidebar\" : \"copilotKitSidebar\",\n };\n const [expandedClassName, setExpandedClassName] = useState(\n props.defaultOpen ? \"sidebarExpanded\" : \"\",\n );\n\n const onSetOpen = (open: boolean) => {\n props.onSetOpen?.(open);\n setExpandedClassName(open ? \"sidebarExpanded\" : \"\");\n };\n\n return (\n <div className={`copilotKitSidebarContentWrapper ${expandedClassName}`}>\n <CopilotModal {...props} {...{ onSetOpen }}>\n {props.children}\n </CopilotModal>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AA+DA,SAAgB,gBAAgB;AAmB1B;AAhBC,SAAS,eAAe,OAA0B;AACvD,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,uBAAuB;AAAA,EACxE;AACA,QAAM,CAAC,mBAAmB,oBAAoB,IAAI;AAAA,IAChD,MAAM,cAAc,oBAAoB;AAAA,EAC1C;AAEA,QAAM,YAAY,CAAC,SAAkB;AA3EvC;AA4EI,gBAAM,cAAN,+BAAkB;AAClB,yBAAqB,OAAO,oBAAoB,EAAE;AAAA,EACpD;AAEA,SACE,oBAAC,SAAI,WAAW,mCAAmC,qBACjD,8BAAC,8DAAiB,QAAW,EAAE,UAAU,IAAxC,EACE,gBAAM,WACT,GACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/Popup.tsx"],"sourcesContent":["/**\n * <br/>\n * <img src=\"/images/CopilotPopup.gif\" width=\"500\" />\n *\n * A chatbot popup component for the CopilotKit framework. The component allows for a high degree\n * of customization through various props and custom CSS.\n *\n * See [CopilotSidebar](/reference/components/CopilotSidebar) for a sidebar version of this component.\n *\n * ## Example\n *\n * ```tsx\n * import { CopilotPopup } from \"@copilotkit/react-ui\";\n *\n * <CopilotPopup\n * labels={{\n * title: \"Your Assistant\",\n * initial: \"Hi! 👋 How can I assist you today?\",\n * }}\n * />\n * ```\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 * ### Custom Styles\n *\n * To opt-in for the built-in styles, make sure to import the following at the root of your application:\n *\n * ```tsx\n * import \"@copilotkit/react-ui/styles.css\";\n * ```\n *\n * You can customize the colors of the chat window 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 * ```tsx\n * <div style={{ \"--copilot-kit-primary-color\": \"#7D5BA6\" }}>\n * <CopilotPopup />\n * </div>\n * ```\n *\n * To further customize the chat window, 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 { CopilotModal, CopilotModalProps } from \"./Modal\";\n\nexport function CopilotPopup(props: CopilotModalProps) {\n props = {\n ...props,\n className: props.className ? props.className + \" copilotKitPopup\" : \"copilotKitPopup\",\n };\n return <CopilotModal {...props}>{props.children}</CopilotModal>;\n}\n"],"mappings":";;;;;;;;;AAsES;AALF,SAAS,aAAa,OAA0B;AACrD,UAAQ,iCACH,QADG;AAAA,IAEN,WAAW,MAAM,YAAY,MAAM,YAAY,qBAAqB;AAAA,EACtE;AACA,SAAO,oBAAC,+CAAiB,QAAjB,EAAyB,gBAAM,WAAS;AAClD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/dev-console/console.tsx"],"sourcesContent":["\"use client\";\n\nimport { useCopilotContext } from \"@copilotkit/react-core\";\nimport {\n getPublishedCopilotKitVersion,\n logActions,\n logMessages,\n logReadables,\n shouldShowDevConsole,\n} from \"./utils\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n CheckIcon,\n ChevronDownIcon,\n CopilotKitIcon,\n ExclamationMarkIcon,\n ExclamationMarkTriangleIcon,\n} from \"./icons\";\nimport { Menu, MenuButton, MenuItem, MenuItems } from \"@headlessui/react\";\nimport { COPILOTKIT_VERSION } from \"@copilotkit/shared\";\nimport { SmallSpinnerIcon } from \"../chat/Icons\";\n\ntype VersionStatus = \"unknown\" | \"checking\" | \"latest\" | \"update-available\" | \"outdated\";\n\nexport function CopilotDevConsole() {\n const currentVersion = COPILOTKIT_VERSION;\n const context = useCopilotContext();\n\n // to prevent hydration errors, ensure that the component renders the same content\n // server-side as it does during the initial client-side render to prevent a hydration\n // mismatch\n // see: https://nextjs.org/docs/messages/react-hydration-error#solution-1-using-useeffect-to-run-on-the-client-only\n\n const [showDevConsole, setShowDevConsole] = useState(false);\n\n useEffect(() => {\n setShowDevConsole(shouldShowDevConsole(context.showDevConsole));\n }, [context.showDevConsole]);\n\n const dontRunTwiceInDevMode = useRef(false);\n const [versionStatus, setVersionStatus] = useState<VersionStatus>(\"unknown\");\n const [latestVersion, setLatestVersion] = useState<string>(\"\");\n const consoleRef = useRef<HTMLDivElement>(null);\n const [debugButtonMode, setDebugButtonMode] = useState<\"full\" | \"compact\">(\"full\");\n\n const checkForUpdates = (force: boolean = false) => {\n setVersionStatus(\"checking\");\n\n getPublishedCopilotKitVersion(currentVersion, force)\n .then((v) => {\n setLatestVersion(v.latest);\n let versionOk = false;\n\n // match exact version or a version with a letter (e.g. 1.0.0-alpha.1)\n if (v.current === v.latest) {\n versionOk = true;\n } else if (/[a-zA-Z]/.test(v.current)) {\n versionOk = true;\n }\n\n if (versionOk) {\n setVersionStatus(\"latest\");\n } else if (v.severity !== \"low\") {\n setVersionStatus(\"outdated\");\n } else {\n setVersionStatus(\"update-available\");\n }\n })\n .catch((e) => {\n console.error(e);\n setVersionStatus(\"unknown\");\n });\n };\n\n useEffect(() => {\n if (dontRunTwiceInDevMode.current === true) {\n return;\n }\n dontRunTwiceInDevMode.current = true;\n\n checkForUpdates();\n }, []);\n\n useEffect(() => {\n const handleResize = (entries: ResizeObserverEntry[]) => {\n for (let entry of entries) {\n if (entry.target === consoleRef.current) {\n const width = entry.contentRect.width;\n if (width < 400) {\n setDebugButtonMode(\"compact\");\n } else {\n setDebugButtonMode(\"full\");\n }\n }\n }\n };\n\n const observer = new ResizeObserver(handleResize);\n if (consoleRef.current) {\n observer.observe(consoleRef.current);\n\n const initialWidth = consoleRef.current.getBoundingClientRect().width;\n if (initialWidth < 400) {\n setDebugButtonMode(\"compact\");\n } else {\n setDebugButtonMode(\"full\");\n }\n }\n\n return () => {\n if (consoleRef.current) {\n observer.unobserve(consoleRef.current);\n }\n };\n }, [consoleRef.current]);\n\n if (!showDevConsole) {\n return null;\n }\n return (\n <div\n ref={consoleRef}\n className={\n \"copilotKitDevConsole \" +\n (versionStatus === \"update-available\" ? \"copilotKitDevConsoleUpgrade\" : \"\") +\n (versionStatus === \"outdated\" ? \"copilotKitDevConsoleWarnOutdated\" : \"\")\n }\n >\n <div className=\"copilotKitDevConsoleLogo\">\n <a href=\"https://copilotkit.ai\" target=\"_blank\">\n {CopilotKitIcon}\n </a>\n </div>\n <VersionInfo\n showDevConsole={context.showDevConsole}\n versionStatus={versionStatus}\n currentVersion={currentVersion}\n latestVersion={latestVersion}\n />\n\n <DebugMenuButton\n setShowDevConsole={setShowDevConsole}\n checkForUpdates={checkForUpdates}\n mode={debugButtonMode}\n />\n </div>\n );\n}\n\nfunction VersionInfo({\n showDevConsole,\n versionStatus,\n currentVersion,\n latestVersion,\n}: {\n showDevConsole: boolean | \"auto\";\n versionStatus: VersionStatus;\n currentVersion: string;\n latestVersion: string;\n}) {\n const [copyStatus, setCopyStatus] = useState<string>(\"\");\n\n let versionLabel = \"\";\n let versionIcon: any = \"\";\n let currentVersionLabel = currentVersion;\n\n if (versionStatus === \"latest\") {\n versionLabel = \"latest\";\n versionIcon = CheckIcon;\n } else if (versionStatus === \"checking\") {\n versionLabel = \"checking\";\n versionIcon = SmallSpinnerIcon;\n } else if (versionStatus === \"update-available\") {\n versionLabel = \"update available\";\n versionIcon = ExclamationMarkIcon;\n currentVersionLabel = `${currentVersion} → ${latestVersion}`;\n } else if (versionStatus === \"outdated\") {\n versionLabel = \"outdated\";\n versionIcon = ExclamationMarkTriangleIcon;\n currentVersionLabel = `${currentVersion} → ${latestVersion}`;\n }\n\n let asideLabel = \"\";\n if (showDevConsole === \"auto\") {\n asideLabel = \"(localhost only)\";\n } else if (showDevConsole === true) {\n asideLabel = \"(always on)\";\n }\n\n const installCommand = [\n `npm install`,\n `@copilotkit/react-core@${latestVersion}`,\n `@copilotkit/react-ui@${latestVersion}`,\n `@copilotkit/react-textarea@${latestVersion}`,\n ].join(\" \");\n\n const handleCopyClick = () => {\n navigator.clipboard.writeText(installCommand.trim()).then(() => {\n setCopyStatus(\"Command copied to clipboard!\");\n setTimeout(() => setCopyStatus(\"\"), 1000);\n });\n };\n\n return (\n <div className=\"copilotKitVersionInfo\">\n <header>\n COPILOTKIT DEV CONSOLE{showDevConsole === \"auto\" && <aside>{asideLabel}</aside>}\n </header>\n <section>\n Version: {versionLabel} ({currentVersionLabel}) {versionIcon}\n </section>\n {(versionStatus === \"update-available\" || versionStatus === \"outdated\") && (\n <footer>\n <button onClick={handleCopyClick}>{copyStatus || installCommand}</button>\n </footer>\n )}\n </div>\n );\n}\nexport default function DebugMenuButton({\n setShowDevConsole,\n checkForUpdates,\n mode,\n}: {\n setShowDevConsole: (show: boolean) => void;\n checkForUpdates: (force: boolean) => void;\n mode: \"full\" | \"compact\";\n}) {\n const context = useCopilotContext();\n\n return (\n <div className=\"bg-black fixed top-24 w-52 text-right\">\n <Menu>\n <MenuButton className={`copilotKitDebugMenuButton ${mode === \"compact\" ? \"compact\" : \"\"}`}>\n {mode == \"compact\" ? \"Debug\" : <>Debug {ChevronDownIcon}</>}\n </MenuButton>\n\n <MenuItems\n transition\n anchor=\"bottom end\"\n className=\"copilotKitDebugMenu\"\n style={{ zIndex: 40 }}\n >\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => logReadables(context)}>\n Log Readables\n </button>\n </MenuItem>\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => logActions(context)}>\n Log Actions\n </button>\n </MenuItem>\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => logMessages(context)}>\n Log Messages\n </button>\n </MenuItem>\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => checkForUpdates(true)}>\n Check for Updates\n </button>\n </MenuItem>\n <hr />\n <MenuItem>\n <button className=\"copilotKitDebugMenuItem\" onClick={() => setShowDevConsole(false)}>\n Hide Dev Console\n </button>\n </MenuItem>\n </MenuItems>\n </Menu>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,SAAS,yBAAyB;AAQlC,SAAS,WAAW,QAAQ,gBAAgB;AAQ5C,SAAS,MAAM,YAAY,UAAU,iBAAiB;AACtD,SAAS,0BAA0B;AAqG/B,SAkHqC,UAzGjC,KATJ;AAhGG,SAAS,oBAAoB;AAClC,QAAM,iBAAiB;AACvB,QAAM,UAAU,kBAAkB;AAOlC,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAE1D,YAAU,MAAM;AACd,sBAAkB,qBAAqB,QAAQ,cAAc,CAAC;AAAA,EAChE,GAAG,CAAC,QAAQ,cAAc,CAAC;AAE3B,QAAM,wBAAwB,OAAO,KAAK;AAC1C,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,SAAS;AAC3E,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,EAAE;AAC7D,QAAM,aAAa,OAAuB,IAAI;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ACF;AAAA,UACA,oBAAC,YACC,8BAAC,YAAO,WAAU,2BAA0B,SAAS,MAAM,YAAY,OAAO,GAAG,0BAEjF,GACF;AAAA,UACA,oBAAC,YACC,8BAAC,YAAO,WAAU,2BAA0B,SAAS,MAAM,gBAAgB,IAAI,GAAG,+BAElF,GACF;AAAA,UACA,oBAAC,QAAG;AAAA,UACJ,oBAAC,YACC,8BAAC,YAAO,WAAU,2BAA0B,SAAS,MAAM,kBAAkB,KAAK,GAAG,8BAErF,GACF;AAAA;AAAA;AAAA,IACF;AAAA,KACF,GACF;AAEJ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat/Suggestion.tsx"],"sourcesContent":["import {\n CopilotContextParams,\n extract,\n CopilotChatSuggestionConfiguration,\n useCopilotContext,\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 >\n {partial && SmallSpinnerIcon}\n <span>{title}</span>\n </button>\n );\n}\n\nexport const reloadSuggestions = async (\n context: CopilotContextParams,\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 config.instructions +\n \"\\n\\n\" +\n numOfSuggestionsInstructions,\n data: \"Available tools: \" + tools + \"\\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,SASE,KATF;AAFG,SAAS,WAAW,EAAE,OAAO,SAAS,SA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