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 ,
State = unknown,
>(
options: ChatResourceOptions <Tools, State>,
): ChatResourceRef <Tools, State>;chatResource
ChatResourceRef<Tools, State>Configuration for the chat resource.
@typeToolsChat.AnyTool@typeState@returnsChatResourceRef<Tools, State>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',
});
chat.sendMessage(\{ role: 'user', content: 'Write a short story about breakfast.' \});