I propose adding two new features to the useObject hook in the Vercel AI SDK:
isLoading: A boolean state that indicates whether the object is currently being generated or updated.
stop: A function that allows users to interrupt the ongoing object generation or update process.
These additions would align the useObject hook more closely with other hooks in the SDK, such as useChat and useCompletion, which already have similar functionalities.
Use Case
Adding isLoading and stop to useObject would significantly improve the user experience in applications using this hook. Here are some specific use cases:
Loading State UI: With isLoading, developers can easily implement loading indicators or disable UI elements while the object is being generated or updated. This provides clear feedback to users about the current state of the operation.
Cancellation: The stop function would allow users to cancel long-running or unnecessary object generations, giving them more control over the application's behavior and potentially saving computational resources.
Error Handling: isLoading can be used in conjunction with error states to provide more nuanced feedback to users, distinguishing between "loading", "error", and "ready" states.
These enhancements would make the useObject hook more versatile and user-friendly, aligning it with the high standards of other hooks in the Vercel AI SDK. I believe this addition would be valuable for many developers using the Vercel AI SDK in their projects.
Feature Description
I propose adding two new features to the
useObject
hook in the Vercel AI SDK:isLoading
: A boolean state that indicates whether the object is currently being generated or updated.stop
: A function that allows users to interrupt the ongoing object generation or update process.These additions would align the
useObject
hook more closely with other hooks in the SDK, such asuseChat
anduseCompletion
, which already have similar functionalities.Use Case
Adding
isLoading
andstop
touseObject
would significantly improve the user experience in applications using this hook. Here are some specific use cases:Loading State UI: With
isLoading
, developers can easily implement loading indicators or disable UI elements while the object is being generated or updated. This provides clear feedback to users about the current state of the operation.Cancellation: The
stop
function would allow users to cancel long-running or unnecessary object generations, giving them more control over the application's behavior and potentially saving computational resources.Error Handling:
isLoading
can be used in conjunction with error states to provide more nuanced feedback to users, distinguishing between "loading", "error", and "ready" states.These enhancements would make the
useObject
hook more versatile and user-friendly, aligning it with the high standards of other hooks in the Vercel AI SDK. I believe this addition would be valuable for many developers using the Vercel AI SDK in their projects.Additional context
No response