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

How to handle multistep toll call with streamUI? #357

Closed
pavlogolovatyy opened this issue May 28, 2024 · 6 comments
Closed

How to handle multistep toll call with streamUI? #357

pavlogolovatyy opened this issue May 28, 2024 · 6 comments

Comments

@pavlogolovatyy
Copy link

Something like in the docs of AI SDK RSC:

User: What's the status of my wife's upcoming flight?
Function: lookupContacts() -> ["John Doe", "Jane Doe"]
Function: lookupBooking("Jane Doe") -> "BA123 confirmed"
Function: lookupFlight("BA123") -> "Flight BA123 is scheduled to depart on 12th December."
Model: Your wife's flight BA123 is confirmed and scheduled to depart on 12th December.

Before refreshing the chat, only the last UI will be visible: lookupFlight.

How to handle all functions return without refreshing the page?

@athrael-soju
Copy link

This should be able to do something similar, but maybe outdated: https://github.com/vercel-labs/gemini-chatbot

@iosifnicolae2
Copy link

I'm also interested in a solution to be able to implement chain of thoughts using AI SDK.

@pavlogolovatyy
Copy link
Author

pavlogolovatyy commented May 29, 2024

It seems like the issue might stem from the following lines of code in prompt-form.tsx:

const [_, setMessages] = useUIState<typeof AI>()

const responseMessage = await submitUserMessage(value)
setMessages(currentMessages => [...currentMessages, responseMessage])

The submitUserMessage function is returning a single message. Additionally, during refresh, the messages are being fetched from AIState.

@intoxopox
Copy link

@pavlogolovatyy Curious to see if you found a better way.

@athrael-soju
Copy link

athrael-soju commented May 30, 2024

The Completions API has a single output. You may want to look into the assistants API

@JokeJason
Copy link

AI SDK 3.2 has new feature that maybe helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants