Represents a Hashbrown chat instance, providing methods to send and observe messages, track state, and handle errors.
@template Output - The type of messages received from the LLM, either a string or structured output defined by HashbrownType. @template Tools - The set of tools available to the chat instance.
interface Hashbrown<Output, Tools extends Chat.AnyTool> {
readonly error: Error | undefined;
readonly messages: Chat.Message<Output, Tools>[];
observeError: (onChange: (error: Error | undefined) => void) => void;
observeExhaustedRetries: (onChange: (exhaustedRetries: boolean) => void) => void;
observeIsLoading: (onChange: (isLoading: boolean) => void) => void;
observeIsReceiving: (onChange: (isReceiving: boolean) => void) => void;
observeIsRunningToolCalls: (onChange: (isRunningToolCalls: boolean) => void) => void;
observeIsSending: (onChange: (isSending: boolean) => void) => void;
observeMessages: (onChange: (messages: Chat.Message<Output, Tools>[]) => void) => void;
resendMessages: () => void;
sendMessage: (message: Chat.Message<Output, Tools>) => void;
setMessages: (messages: Chat.Message<Output, Tools>[]) => void;
teardown: () => void;
updateOptions: (options: Partial<{
debugName?: string;
apiUrl: string;
model: string;
system: string;
tools: Tools[];
responseSchema: s.HashbrownType;
middleware: Chat.Middleware[];
emulateStructuredOutput: boolean;
debounce: number;
retries: number;
}>) => void;
}
@type
Output
@type
Tools
Chat.AnyTool