Skip to content

Commit 92bbdfd

Browse files
committed
Add documentation
1 parent a5b41be commit 92bbdfd

3 files changed

Lines changed: 180 additions & 4 deletions

File tree

CopilotKit/packages/react-ui/src/components/chat/Chat.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,91 @@ import { Input as DefaultInput } from "./Input";
1010
import { nanoid } from "nanoid";
1111
import { ResponseButton } from "./Response";
1212

13+
/**
14+
* Props for CopilotKitChat component.
15+
*/
1316
export interface CopilotKitChatProps {
17+
/**
18+
* Custom instructions to be added to the system message. Use this property to
19+
* provide additional context or guidance to the language model, influencing
20+
* its responses. These instructions can include specific directions,
21+
* preferences, or criteria that the model should consider when generating
22+
* its output, thereby tailoring the conversation more precisely to the
23+
* user's needs or the application's requirements.
24+
*/
1425
instructions?: string;
26+
27+
/**
28+
* Whether the chat window should be open by default.
29+
* @default false
30+
*/
1531
defaultOpen?: boolean;
32+
33+
/**
34+
* If the chat window should close when the user clicks outside of it.
35+
* @default true
36+
*/
1637
clickOutsideToClose?: boolean;
38+
39+
/**
40+
* If the chat window should close when the user hits the Escape key.
41+
* @default true
42+
*/
1743
hitEscapeToClose?: boolean;
44+
45+
/**
46+
* The hotkey to open the chat window.
47+
* Uses Command-<hotkey> on a Mac and Ctrl-<hotkey> on Windows.
48+
* @default "e"
49+
*/
1850
hotkey?: string;
51+
52+
/**
53+
* Icons can be used to set custom icons for the chat window.
54+
*/
1955
icons?: CopilotKitChatIcons;
56+
57+
/**
58+
* Labels can be used to set custom labels for the chat window.
59+
*/
2060
labels?: CopilotKitChatLabels;
61+
62+
/**
63+
* A function that takes in context string and instructions and returns
64+
* the system message to include in the chat request.
65+
* Use this to completely override the system message, when providing
66+
* instructions is not enough.
67+
*/
2168
makeSystemMessage?: SystemMessageFunction;
69+
70+
/**
71+
* A custom Window component to use instead of the default.
72+
*/
2273
Window?: React.ComponentType<WindowProps>;
74+
75+
/**
76+
* A custom Button component to use instead of the default.
77+
*/
2378
Button?: React.ComponentType<ButtonProps>;
79+
80+
/**
81+
* A custom Header component to use instead of the default.
82+
*/
2483
Header?: React.ComponentType<HeaderProps>;
84+
85+
/**
86+
* A custom Messages component to use instead of the default.
87+
*/
2588
Messages?: React.ComponentType<MessagesProps>;
89+
90+
/**
91+
* A custom Input component to use instead of the default.
92+
*/
2693
Input?: React.ComponentType<InputProps>;
94+
95+
/**
96+
* A class name to apply to the root element.
97+
*/
2798
className?: string;
2899
}
29100

CopilotKit/packages/react-ui/src/components/chat/ChatContext.tsx

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,108 @@
11
import React, { useMemo } from "react";
22
import * as DefaultIcons from "./Icons";
33

4+
/**
5+
* Icons for CopilotKitChat component.
6+
*/
47
export interface CopilotKitChatIcons {
8+
/**
9+
* The icon to use for the open chat button.
10+
* @default <OpenIcon />
11+
*/
512
openIcon?: React.ReactNode;
13+
14+
/**
15+
* The icon to use for the close chat button.
16+
* @default <CloseIcon />
17+
*/
618
closeIcon?: React.ReactNode;
19+
20+
/**
21+
* The icon to use for the close chat button in the header.
22+
* @default <HeaderCloseIcon />
23+
*/
724
headerCloseIcon?: React.ReactNode;
25+
26+
/**
27+
* The icon to use for the send button.
28+
* @default <SendIcon />
29+
*/
830
sendIcon?: React.ReactNode;
31+
32+
/**
33+
* The icon to use for the activity indicator.
34+
* @default <ActivityIcon />
35+
*/
936
activityIcon?: React.ReactNode;
37+
38+
/**
39+
* The icon to use for the spinner.
40+
* @default <SpinnerIcon />
41+
*/
1042
spinnerIcon?: React.ReactNode;
43+
44+
/**
45+
* The icon to use for the stop button.
46+
* @default <StopIcon />
47+
*/
1148
stopIcon?: React.ReactNode;
49+
50+
/**
51+
* The icon to use for the regenerate button.
52+
* @default <RegenerateIcon />
53+
*/
1254
regenerateIcon?: React.ReactNode;
1355
}
1456

57+
/**
58+
* Labels for CopilotKitChat component.
59+
*/
1560
export interface CopilotKitChatLabels {
61+
/**
62+
* The initial message(s) to display in the chat window.
63+
*/
1664
initial?: string | string[];
65+
66+
/**
67+
* The title to display in the header.
68+
* @default "CopilotKit"
69+
*/
1770
title?: string;
71+
72+
/**
73+
* The placeholder to display in the input.
74+
* @default "Type a message..."
75+
*/
1876
placeholder?: string;
77+
78+
/**
79+
* The message to display while the chat is thinking.
80+
* @default "Thinking..."
81+
*/
1982
thinking?: string;
83+
84+
/**
85+
* The message to display when the chat is done thinking.
86+
* @default "✅ Done"
87+
*/
2088
done?: string;
89+
90+
/**
91+
* The message to display when an error occurs.
92+
* @default "❌ An error occurred. Please try again."
93+
*/
2194
error?: string;
95+
96+
/**
97+
* The message to display when the user clicks the stop button.
98+
* @default "Stop generating"
99+
*/
22100
stopGenerating?: string;
101+
102+
/**
103+
* The message to display when the user clicks the regenerate button.
104+
* @default "Regenerate response"
105+
*/
23106
regenerateResponse?: string;
24107
}
25108

@@ -62,7 +145,7 @@ export const ChatContextProvider: React.FC<ChatContextProps> = ({
62145
labels: {
63146
...{
64147
initial: "",
65-
title: "Assistant",
148+
title: "CopilotKit",
66149
placeholder: "Type a message...",
67150
thinking: "Thinking...",
68151
done: "✅ Done",

docs/TODO-POPUP.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
# What needs to be documented:
22

3-
## CopilotKitPopupProps
3+
## CopilotKitChatProps
44

55
- instructions?: string; Custom instructions to add to the system message
6-
- headers?: Record<string, string> | Headers; Headers to add to the request
7-
- body?: object; Body to add to the request. Can override model etc.
6+
- [x] in code
7+
- [ ] in mintlify
88
- defaultOpen?: boolean; Whether the popup should be open by default
9+
- [x] in code
10+
- [ ] in mintlify
911
- clickOutsideToClose?: boolean; Whether the popup should close when clicking outside of it
12+
- [x] in code
13+
- [ ] in mintlify
1014
- hitEscapeToClose?: boolean; Whether the popup should close when hitting the escape key
15+
- [x] in code
16+
- [ ] in mintlify
1117
- hotkey?: string; The hotkey to open the popup
18+
- [x] in code
19+
- [ ] in mintlify
1220
- icons?: CopilotKitChatIcons; Users can override icons
21+
- [x] in code
22+
- [ ] in mintlify
1323
- labels?: CopilotKitChatLabels; Users can override labels
24+
- [x] in code
25+
- [ ] in mintlify
1426
- Window?: React.ComponentType<WindowProps>; Users can override the Window component
27+
- [x] in code
28+
- [ ] in mintlify
1529
- Button?: React.ComponentType<ButtonProps>; Users can override the Button component
30+
- [x] in code
31+
- [ ] in mintlify
1632
- Header?: React.ComponentType<HeaderProps>; Users can override the Header component
33+
- [x] in code
34+
- [ ] in mintlify
1735
- Messages?: React.ComponentType<MessagesProps>; Users can override the Messages component
36+
- [x] in code
37+
- [ ] in mintlify
1838
- Input?: React.ComponentType<InputProps>; Users can override the Input component
39+
- [x] in code
40+
- [ ] in mintlify
1941

2042
## Mobile/Responsive Support
2143

0 commit comments

Comments
 (0)