Learn how to work with KorinAI's message structure for chat integration. This guide explains the core message types and their usage.
Core Message Interface
The chat system uses a structured message format for communication. Here's the core message structure:
Message Types
1. Text Messages
Text messages are the most basic form of communication in the chat system.
Features:
- Simple text content displayed in chat bubbles
- Supports markdown formatting for rich text
- Can include code blocks, links, and formatting
Example:
Tool invocation messages are used for system actions and commands.
Features:
- Shows progress and results of operations
- Supports different states (call, result, partial-call)
- Can handle various tool types and arguments
Example:
States:
call
: Initial tool invocation
result
: Completed operation
partial-call
: Operation in progress
Best Practices
-
Message Handling
- Always validate message structure before processing
- Handle missing optional fields gracefully
- Check message roles for proper display
-
Content Processing
- Parse markdown in text messages
- Handle tool invocation states appropriately
- Implement proper error handling for unsupported message types
-
Error Handling
- Validate message format
- Handle missing or malformed parts
- Provide fallback for unsupported message types