The result object-type returned by the useStructuredChat hook that provides functions and state for interacting with the chat.
API
interface UseStructuredChatResult<Output, Tools extends Chat.AnyTool> {error: Error | undefined;exhaustedRetries: boolean;isReceiving: boolean;isRunningToolCalls: boolean;isSending: boolean;lastAssistantMessage: Chat.AssistantMessage <
Output,
Tools
> | undefined;messages: (Chat.Message < Output, Tools > []);reload: () => void;resendMessages: () => void;sendMessage: (message: Chat.Message<Output, Tools>) => void;setMessages: (messages: Chat.Message<Output, Tools>[]) => void;stop: (clearStreamingMessage?: boolean) => void;}UseStructuredChatResult
@typeOutput@typeToolsChat.AnyToolerror
Error | undefinedThe error encountered during chat operations, if any.
exhaustedRetries
booleanWhether the current request has exhausted retries.
isReceiving
booleanWhether the chat is receiving a response.
isRunningToolCalls
booleanWhether the chat is running tool calls.
isSending
booleanWhether the chat is sending a response.
lastAssistantMessage
Chat.AssistantMessage<Output, Tools> | undefinedThe last assistant message.
messages
Chat.Message<Output, Tools>[]An array of chat messages.
reload
() => voidReload the chat, useful for retrying when an error occurs.
resendMessages
() => voidFunction to cause current messages to be resent. Can be used after an error in chat.
sendMessage
(message: Chat.Message<Output, Tools>) => voidFunction to send a new chat message.
setMessages
(messages: Chat.Message<Output, Tools>[]) => voidFunction to update the chat messages.
stop
(clearStreamingMessage?: boolean) => voidFunction to stop the chat.