ChatMessageListComponent is the core primitive for rendering chat messages. It iterates over the messages from an Agent and renders each one using a matching MessageTemplateDirective. This gives you full control over how each message type is displayed.
Selector:chat-message-list
Import:
import { ChatMessageListComponent, MessageTemplateDirective, getMessageType,} from '@ngaf/chat';
How It Works
The component reads agent().messages() to get the current message list
For each message, it calls getMessageType() to determine the template type
It finds the matching MessageTemplateDirective among its content children
It renders the message using ngTemplateOutlet with the message as the implicit context
The getMessageType() function maps a runtime-neutral Message role to a MessageTemplateType.
import { getMessageType } from '@ngaf/chat';const type = getMessageType(message); // 'human' | 'ai' | 'tool' | 'system' | 'function'
Mapping logic:
Runtime-neutral role
Returns
'user'
'human'
'assistant'
'ai'
'tool'
'tool'
'system'
'system'
Any other value
'ai' (default fallback)
Working with Message Content
Runtime-neutral messages have a content property that can be either a string or a structured array. The library exports a messageContent() utility (used internally by compositions) that handles both cases:
// If content is a string, returns it directly// If content is structured, serializes to JSONfunction messageContent(message: Message): string
For custom templates, you can access message.content directly and handle the type yourself: