POLPOUI

ChatMessage

Single message renderer that dispatches to user or assistant sub-components.

ChatMessage is a dispatcher that renders ChatUserMessage or ChatAssistantMessage based on the message role. All three are exported and can be used independently.

Preview

Can you add a users table with email and role fields?

2m ago
Coder

I'll add the users table with email validation and a role enum. Let me update your schema and run the migration.

Here's my schema, please update it

A minute ago

The migration has been applied successfully. Your `users` table now has `id`, `email`, `role`, `createdAt`, and `updatedAt` columns. The `email` field has a unique constraint and the `role` field defaults to `USER`.

Import

import {
  ChatMessage,
  ChatUserMessage,
  ChatAssistantMessage,
  type ChatMessageProps,
  type ChatMessageItemData,
} from "@polpo-ai/chat";

ChatMessageItemData

FieldTypeDescription
idstringOptional message ID
role"user" | "assistant"Message sender role
contentstring | ContentPart[]Text or structured content parts
tsstringOptional ISO timestamp
toolCallsToolCallEvent[]Optional tool call events

Props

PropTypeDefaultDescription
msgChatMessageItemDatarequiredThe message data to render
isLastbooleanWhether this is the last message in the list
isStreamingbooleanWhether the assistant is currently streaming
avatarReactNodeAvatar shown on assistant messages
agentNamestringDisplay name for assistant messages
streamdownComponentsRecord<string, unknown>Streamdown component overrides
resolveFileUrl(fileId: string) => string/api/v1/files/read?path=<id>Resolve file_id to a URL
classNamestringAdditional className

Usage

<ChatMessage
  msg={{ role: "assistant", content: "Hello!" }}
  isLast={true}
  isStreaming={false}
  avatar={<BotIcon />}
  agentName="Assistant"
/>

On this page