Chat Interface Component
The Chat Interface is the primary way users interact with AI agents in Artifact Chat. It provides a clean, responsive interface for messaging, with support for rich content.Basic Usage
To implement the chat interface in your application:Props
TheChatInterface component accepts the following props:
Examples
- Basic Chat
- With Pre-configured Agent
- With Initial Message
Message Rendering
The Chat Interface handles several types of message content:- Text: Plain text messages
- Markdown: Rich text with support for headings, lists, etc.
- Code Blocks: Syntax-highlighted code snippets
- Image Attachments: Display of image content
- File Attachments: Links to attached files
- Interactive Elements: Buttons, forms, and other interactive UI
The message rendering is handled by the
<MarkdownRenderer> component which is documented separately.Customization
The Chat Interface can be customized in several ways:Custom Styling
You can customize the appearance using Tailwind CSS classes:Custom Message Renderer
You can provide your own message renderer component:Input Options
The Chat Interface includes a rich text input with several features:- Text Formatting: Basic markdown formatting
- File Attachments: Upload and attach files
- Code Snippets: Special handling for code
- Command Palette: Quick commands via / prefix
- Mentions: @mentions for referencing items
Mobile Responsiveness
The Chat Interface is fully responsive and works well on mobile devices:- Adapts layout for smaller screens
- Supports touch interactions
- Adjusts input methods for mobile
- Handles keyboard appearance on mobile devices
Accessibility
The Chat Interface includes several accessibility features:- Proper ARIA roles and labels
- Keyboard navigation support
- Screen reader compatibility
- High contrast mode support
- Focus management for new messages
Performance Considerations
For optimal performance when using the Chat Interface:- Virtualization: Messages are virtualized to handle large threads
- Lazy Loading: Images and attachments load lazily
- Debounced Input: Input events are debounced
- Memoization: Components use React.memo to prevent unnecessary re-renders
API Integration
The Chat Interface integrates with the Artifact Chat API through the thread store:Events
The Chat Interface emits the following events:ToolBox Component
The ToolBox component provides access to the AI assistant’s specialized tools directly from the chat interface. This component allows users to view available tools, toggle their activation, and see which tools are currently active in a conversation.Tool Organization
Tools are organized into categories for easy navigation:- Images - Image generation and analysis tools
- Web - Internet search and web scraping tools
- Knowledge - Information retrieval tools
- Data - Data visualization and analysis tools
- Code - Code execution and analysis tools
- Files - File management tools
- Context7 - Documentation access tools
- Firecrawl - Advanced web scraping tools
- Binance - Cryptocurrency market data tools
- Gmail - Email management tools
- GitHub - Repository management tools
- Reddit - Reddit interaction tools
- Sequential Thinking - Step-by-step reasoning tools
- Google Drive - Document management tools
- Slack - Workspace communication tools
Using the ToolBox
- Accessing Tools: Click the toolbox icon in the chat input area to open the ToolBox
- Browsing Categories: Expand categories to view available tools
- Activating Tools: Toggle tools on/off by clicking them
- Active Tool Indicator: Currently active tools appear highlighted and are displayed as icons in the chat input
Tool Permissions
Some tools require authentication or specific permissions:- Google Drive: Requires Google account authorization
- Gmail: Requires email account access
- GitHub: Requires GitHub account authorization
- Slack: Requires Slack workspace authorization
Tool Usage
Tools can be used in two ways:- AI-Initiated: The assistant automatically uses appropriate tools based on your query
- User-Prompted: You can specifically ask the assistant to use a particular tool
