Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assistant Hook: Add client side function handling and other events #868

Open
johannbuscail opened this issue Dec 17, 2023 · 5 comments
Open
Labels
ai/ui enhancement New feature or request

Comments

@johannbuscail
Copy link

johannbuscail commented Dec 17, 2023

Feature Description

Add events on the useAssistant hook, just like the useChat 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

@johannbuscail johannbuscail changed the title Assistant Hook: Add client side function handling Assistant Hook: Add client side function handling and other events Dec 17, 2023
@lgrammel lgrammel added enhancement New feature or request ai/ui labels Jul 20, 2024
@nico-herrera
Copy link

bumping this, need it badly. If anyone has found a solution or workaround please let me know!

@hgrias
Copy link

hgrias commented Sep 9, 2024

bump

@vladdg-dev
Copy link

A isLoading boolean response from useAssistant would also be nice.

@shaurya157
Copy link

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

@rostgoat
Copy link

bump.

here is my workaround for now:

  // Track the previous status to detect when the assistant finishes processing
  const previousStatus = 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]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/ui enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants