hashbrown

UseStructuredChatResult

The result object-type returned by the useStructuredChat hook that provides functions and state for interacting with the chat.

API

UseStructuredChatResult
@typeOutput
@typeTools
Chat.AnyTool
error
Error | undefined

The error encountered during chat operations, if any.

exhaustedRetries
boolean

Whether the current request has exhausted retries.

generatingError
Error | undefined

Error emitted during generation frames.

isGenerating
boolean

Whether the chat is currently generating.

isLoading
boolean

Aggregate loading flag across transport, generation, and tool calls.

isReceiving
boolean

Whether the chat is receiving a response.

isRunningToolCalls
boolean

Whether the chat is running tool calls.

isSending
boolean

Whether the chat is sending a response.

lastAssistantMessage
Chat.AssistantMessage<Output, Tools> | undefined

The last assistant message.

messages
Chat.Message<Output, Tools>[]

An array of chat messages.

reload
() => void

Reload the chat, useful for retrying when an error occurs.

resendMessages
() => void

Function to cause current messages to be resent. Can be used after an error in chat.

sendingError
Error | undefined

Transport/request failure before generation frames arrive.

sendMessage
(message: Chat.Message<Output, Tools>) => void

Function to send a new chat message.

setMessages
(messages: Chat.Message<Output, Tools>[]) => void

Function to update the chat messages.

stop
(clearStreamingMessage?: boolean) => void

Function to stop the chat.