Represents a Hashbrown chat instance, providing methods to send and observe messages, track state, and handle errors.
API
interface Hashbrown<Output, Tools extends Chat.AnyTool> {error: StateSignal <
Error | undefined
>;exhaustedRetries: StateSignal <boolean>;isLoading: StateSignal <boolean>;isReceiving: StateSignal <boolean>;isRunningToolCalls: StateSignal <boolean>;isSending: StateSignal <boolean>;lastAssistantMessage: StateSignal <
Chat.AssistantMessage <Output, Tools> | undefined
>;messages: StateSignal <
Chat.Message <Output, Tools>[]
>;resendMessages: () => void;sendMessage: (message: Chat.Message<Output, Tools>) => void;setMessages: (messages: Chat.Message<Output, Tools>[]) => void;sizzle: () => () => void;stop: (clearStreamingMessage?: boolean) => void;updateOptions: (options: Partial<{
debugName?: string;
apiUrl: string;
model: KnownModelIds;
system: string;
tools: Tools[];
responseSchema: s.HashbrownType;
middleware: Chat.Middleware[];
emulateStructuredOutput: boolean;
debounce: number;
retries: number;
}>) => void;}Hashbrown
@typeOutput@typeToolsChat.AnyToolerror
StateSignal<Error | undefined>exhaustedRetries
StateSignal<boolean>isLoading
StateSignal<boolean>isReceiving
StateSignal<boolean>isRunningToolCalls
StateSignal<boolean>isSending
StateSignal<boolean>lastAssistantMessage
StateSignal<Chat.AssistantMessage<Output, Tools> | undefined>messages
StateSignal<Chat.Message<Output, Tools>[]>resendMessages
() => voidResend messages and update state. Often used manually after an error.
sendMessage
(message: Chat.Message<Output, Tools>) => voidSend a new message to the LLM and update state.
setMessages
(messages: Chat.Message<Output, Tools>[]) => voidReplace the current set of messages in the chat state.
sizzle
() => () => voidStart the Hashbrown effect loop.
stop
(clearStreamingMessage?: boolean) => voidStop the current LLM interaction.
updateOptions
(options: Partial<{
debugName?: string;
apiUrl: string;
model: KnownModelIds;
system: string;
tools: Tools[];
responseSchema: s.HashbrownType;
middleware: Chat.Middleware[];
emulateStructuredOutput: boolean;
debounce: number;
retries: number;
}>) => voidUpdate the chat options after initialization