| title | CopilotChat |
|---|---|
| description | The CopilotChat component, providing a chat interface for interacting with your copilot. |
{ /*
- ATTENTION! DO NOT MODIFY THIS FILE!
- This page is auto-generated. If you want to make any changes to this page, changes must be made at:
- packages/react-ui/src/components/chat/Chat.tsx */ }
A chatbot panel component for the CopilotKit framework. The component allows for a high degree of customization through various props and custom CSS.
This component is part of the @copilotkit/react-ui package.
npm install @copilotkit/react-core @copilotkit/react-uiimport { CopilotChat } from "@copilotkit/react-ui";
import "@copilotkit/react-ui/styles.css";
<CopilotChat
labels={{
title: "Your Assistant",
initial: "Hi! 👋 How can I assist you today?",
}}
/>To monitor user interactions, provide the observabilityHooks prop.
Note: This requires a publicApiKey in the <CopilotKit> provider.
<CopilotKit publicApiKey="YOUR_PUBLIC_API_KEY">
<CopilotChat
observabilityHooks={{
onMessageSent: (message) => {
console.log("Message sent:", message);
},
}}
/>
</CopilotKit>By default, CopilotKit components do not have any styles. You can import CopilotKit's stylesheet at the root of your project:
...
import "@copilotkit/react-ui/styles.css"; // [!code highlight]
export function YourRootComponent() {
return (
<CopilotKit>
...
</CopilotKit>
);
}For more information about how to customize the styles, check out the Customize Look & Feel guide.
Custom instructions to be added to the system message. Use this property to provide additional context or guidance to the language model, influencing its responses. These instructions can include specific directions, preferences, or criteria that the model should consider when generating its output, thereby tailoring the conversation more precisely to the user's needs or the application's requirements. Controls the behavior of suggestions in the chat interface.auto (default) - Suggestions are generated automatically:
- When the chat is first opened (empty state)
- After each message exchange completes
- Uses configuration from useCopilotChatSuggestions hooks
manual - Suggestions are controlled programmatically:
- Use setSuggestions() to set custom suggestions
- Use generateSuggestions() to trigger AI generation
- Access via useCopilotChat hook
SuggestionItem[] - Static suggestions array:
- Always shows the same suggestions
- No AI generation involved
@example
<CopilotChat
attachments={{
enabled: true,
accept: "image,application/pdf",
maxSize: 10 1024 1024, // 10MB
onUpload: async (file) => {
const url = await uploadToS3(file);
return { url, mimeType: file.type };
},
}}
/>makeSystemMessage).
A custom assistant message component to use instead of the default.
A custom user message component to use instead of the default.
A custom error message component to use instead of the default.
A custom Messages component to use instead of the default.
A custom RenderMessage component to use instead of the default.
Warning: This is a break-glass solution to allow for custom rendering of messages. You are most likely looking to swap out the AssistantMessage and UserMessage components instead which are also props.
A custom suggestions list component to use instead of the default. A custom Input component to use instead of the default. A class name to apply to the root element. Children to render. Event hooks for CopilotKit chat events. These hooks only work when publicApiKey is provided. Custom error renderer for chat-specific errors. When provided, errors will be displayed inline within the chat interface. Optional handler for comprehensive debugging and observability.