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;generatingError: Error | undefined;isGenerating: boolean;isLoading: boolean;isLoadingThread: boolean;isReceiving: boolean;isRunningToolCalls: boolean;isSavingThread: boolean;isSending: boolean;lastAssistantMessage: Chat.AssistantMessage <
Output,
Tools
> | undefined;messages: (Chat.Message < Output, Tools > []);reload: () => void;resendMessages: () => void;sendingError: Error | undefined;sendMessage: (message: Chat.Message<Output, Tools>) => void;setMessages: (messages: Chat.Message<Output, Tools>[]) => void;stop: (clearStreamingMessage?: boolean) => void;threadLoadError: {
error: string;
stacktrace?: string;
} | undefined;threadSaveError: {
error: string;
stacktrace?: string;
} | undefined;}@typeOutput@typeToolsChat.AnyToolError | undefinedThe error encountered during chat operations, if any.
booleanWhether the current request has exhausted retries.
Error | undefinedError emitted during generation frames.
booleanWhether the chat is currently generating.
booleanAggregate loading flag across transport, generation, tool-calls, and thread load/save.
booleanWhether a thread load request is in flight.
booleanWhether the chat is receiving a response.
booleanWhether the chat is running tool calls.
booleanWhether a thread save request is in flight.
booleanWhether the chat is sending a response.
Chat.AssistantMessage<Output, Tools> | undefinedThe last assistant message.
Chat.Message<Output, Tools>[]An array of chat messages.
() => voidReload the chat, useful for retrying when an error occurs.
() => voidFunction to cause current messages to be resent. Can be used after an error in chat.
Error | undefinedTransport/request failure before generation frames arrive.
(message: Chat.Message<Output, Tools>) => voidFunction to send a new chat message.
(messages: Chat.Message<Output, Tools>[]) => voidFunction to update the chat messages.
(clearStreamingMessage?: boolean) => voidFunction to stop the chat.
{
error: string;
stacktrace?: string;
} | undefinedError encountered while loading a thread.
{
error: string;
stacktrace?: string;
} | undefinedError encountered while saving a thread.