This Angular resource provides a reactive chat interface for send and receiving messages from a model. The resource-based API includes signals for the current messages, status, and control methods for sending and stopping messages.
API
declare function chatResource<
Tools extends Chat.AnyTool ,
>(
options: ChatResourceOptions <Tools>,
): ChatResourceRef <Tools>;
chatResource
ChatResourceRef<Tools>
@param
options:
ChatResourceOptions<Tools>
Configuration for the chat resource.
@type
Tools
Chat.AnyTool
@returns
ChatResourceRef<Tools>
Examples
This example demonstrates how to use the chatResource
function to create a simple chat component.
const chat = chatResource({
system: 'hashbrowns should be covered and smothered',
model: 'gpt-5',
});
chat.sendMessage({ role: 'user', content: 'Write a short story about breakfast.' });