The result object-type returned by the useChat hook that provides functions and state for interacting with the chat.
API
interface UseChatResult<Tools extends Chat.AnyTool> {error: Error | undefined;exhaustedRetries: boolean;isReceiving: boolean;isRunningToolCalls: boolean;isSending: boolean;lastAssistantMessage: Chat.AssistantMessage <
string,
Tools
> | undefined;messages: (Chat.Message < string, Tools > []);reload: () => void;sendMessage: (message: Chat.Message<string, Tools>) => void;setMessages: (messages: Chat.Message<string, Tools>[]) => void;stop: (clearStreamingMessage?: boolean) => void;}UseChatResult
@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<string, Tools> | undefinedThe last assistant message.
messages
Chat.Message<string, Tools>[]An array of chat messages.
reload
() => voidReload the chat, useful for retrying when an error occurs.
sendMessage
(message: Chat.Message<string, Tools>) => voidFunction to send a new chat message.
setMessages
(messages: Chat.Message<string, Tools>[]) => voidFunction to update the chat messages.
stop
(clearStreamingMessage?: boolean) => voidFunction to stop the chat.