A comprehensive Dash component library for integrating CopilotKit AI assistants into your Dash applications. This component supports all 4 CopilotKit UI types and is compatible with Dash 3.0.
- 4 UI Types: Chat, Popup, Sidebar, and AI-powered Textarea interfaces
- Flexible API Configuration: Use CopilotKit Cloud or bring your own API key (OpenAI, Anthropic, etc.)
- Dash 3.0 Compatible: Updated for the latest Dash version with modern React 18 support
- Fully Customizable: Complete control over styling, instructions, and behavior
- Production Ready: Comprehensive error handling and performance optimizations
- TypeScript Support: Complete type definitions for all props
Install from PyPI:
pip install dash-copilotkit-componentsThe component automatically includes all required JavaScript dependencies.
import dash_copilotkit_components
from dash import Dash, html
app = Dash(__name__)
app.layout = html.Div([
dash_copilotkit_components.DashCopilotkitComponents(
id='copilot',
ui_type='chat', # 'chat', 'popup', 'sidebar', or 'textarea'
public_api_key='your-copilotkit-cloud-api-key', # Optional
instructions="You are a helpful AI assistant.",
labels={
'title': 'AI Assistant',
'initial': 'Hello! How can I help you today?'
}
)
])
if __name__ == '__main__':
app.run(debug=True)A full chat interface embedded directly in your app.
dash_copilotkit_components.DashCopilotkitComponents(
id='chat-copilot',
ui_type='chat',
width='100%',
height='500px',
public_api_key='your-api-key'
)A popup chat window that can be toggled on/off.
dash_copilotkit_components.DashCopilotkitComponents(
id='popup-copilot',
ui_type='popup',
show_initially=False,
public_api_key='your-api-key'
)A sidebar chat interface that slides in from the side.
dash_copilotkit_components.DashCopilotkitComponents(
id='sidebar-copilot',
ui_type='sidebar',
position='right', # 'left' or 'right'
show_initially=False,
public_api_key='your-api-key'
)An AI-powered textarea that helps users write better content.
dash_copilotkit_components.DashCopilotkitComponents(
id='textarea-copilot',
ui_type='textarea',
placeholder='Start typing here...',
value='',
public_api_key='your-api-key'
)Get your API key from CopilotKit Cloud:
dash_copilotkit_components.DashCopilotkitComponents(
id='copilot',
ui_type='chat',
public_api_key='your-copilotkit-cloud-api-key'
)Use your own runtime URL with your API key:
dash_copilotkit_components.DashCopilotkitComponents(
id='copilot',
ui_type='chat',
runtime_url='http://localhost:3000/api/copilotkit',
api_key='your-openai-api-key'
)| Prop | Type | Default | Description |
|---|---|---|---|
id |
string | - | Component ID for Dash callbacks |
ui_type |
string | 'chat' | UI type: 'chat', 'popup', 'sidebar', 'textarea' |
api_key |
string | - | Your API key (for bring your own key) |
runtime_url |
string | - | Runtime URL for your backend |
public_api_key |
string | - | CopilotKit Cloud public API key |
instructions |
string | "You are a helpful AI assistant." | Custom instructions for the AI |
labels |
object | - | Labels configuration with 'title' and 'initial' |
placeholder |
string | "Type your message here..." | Placeholder for textarea mode |
value |
string | - | Current value (for textarea mode) |
disabled |
boolean | false | Whether the component is disabled |
className |
string | - | CSS class name |
style |
object | - | Inline styles |
width |
string | '100%' | Component width |
height |
string | '400px' | Component height |
position |
string | 'right' | Sidebar position ('left' or 'right') |
show_initially |
boolean | false | Show popup/sidebar initially |
See the usage.py file for a comprehensive example that demonstrates all UI types with configuration options.
Run the example:
python usage.pyThen visit http://localhost:8050 to see the component in action.
- Clone the repository:
git clone <repository-url>
cd dash-copilotkit-components- Install dependencies:
npm install
pip install -r requirements.txt- Build the component:
npm run build- Generate Python bindings:
python -c "import dash.development.component_generator as cg; cg.generate_components('./src/lib/components', 'dash_copilotkit_components', rprefix='ckc', jlprefix='ckc')"Run the test suite:
pytest tests/- Build JavaScript:
npm run build:js- Generate Python components:
npm run build:backends- Create distribution:
python setup.py sdist bdist_wheel- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
MIT License - see LICENSE file for details.