hashbrown

chatResource

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>
@paramoptions:
ChatResourceOptions<Tools, State>

Configuration for the chat resource.

@typeTools
Chat.AnyTool
@typeState
@returns
ChatResourceRef<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.' \});