Skip to content

How to trigger a useAssistant() call form a button instead of the value of the input field? #1143

Closed Answered by shuaizhang1999
VenessaKarlsson24 asked this question in Help
Discussion options

You must be logged in to vote

Not sure whether or not you need it anymore, but now they have an append function from the response of useAssistant. So here is how you implement it:

const { append } = useAssistant({
    api: "/api/assistant",
  });
  
<button
    key={index}
    onClick={() =>
      append({
        role: "user",
        content: yourPromptContentHere,
      })
    }
>
{prompt}
</button>;

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jeremyphilemon
Comment options

Answer selected by jeremyphilemon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants