You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But most importantly, making the assistant hook actually useful is the onFunctionCall event.
This is a MAJOR and really really important event as it allows the assistant to interact with the client side.
The text was updated successfully, but these errors were encountered:
johannbuscail
changed the title
Assistant Hook: Add client side function handling
Assistant Hook: Add client side function handling and other events
Dec 17, 2023
bump, my use cases needs the onFinish hook. Currently, the frontend has no way of knowing that assistant responses are done... This wouldn't be a problem usually but the dependency i'm using relies on an onFinish hook
// Track the previous status to detect when the assistant finishes processingconstpreviousStatus=useRef<string>("awaiting_message");console.log("previousStatus :>> ",previousStatus);useEffect(()=>{if(previousStatus.current==="in_progress"&&assistantStatus==="awaiting_message"){console.log("Assistant has finished responding.");// Custom onFinish logic here}previousStatus.current=assistantStatus;// Update the ref with the current status},[assistantStatus,assistantMessages]);
Feature Description
Add events on the
useAssistant
hook, just like theuseChat
hook.https://sdk.vercel.ai/docs/api-reference/use-chat
onResponse
onError
onFinish
But most importantly, making the assistant hook actually useful is the
onFunctionCall
event.This is a MAJOR and really really important event as it allows the assistant to interact with the client side.
https://sdk.vercel.ai/docs/guides/providers/openai-functions#handling-function-calls-on-the-client
The text was updated successfully, but these errors were encountered: