-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat (rsc): multiple tool calls for streamUI #1904
base: main
Are you sure you want to change the base?
feat (rsc): multiple tool calls for streamUI #1904
Conversation
e15066d
to
cdcf506
Compare
if (wasPreviouslyText && (done || value.type !== 'text-delta')) { | ||
const textNodeId = `text-${textNodeIndex}`; | ||
if (!uiStreams[textNodeId]) { | ||
throw new Error('Expected text node to exist'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have text intermixed with tool calling?
I was able to get text before tool calling, but trying to prompt at least the OpenAI agent to require a text response after tool calling did not seem to work.
If text nodes can only appear once and before tool calling, this can be simplified instead of trying to keep track of nodes being written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, I noticed that with tool calling can come with a delay before the first chunk comes in for reader.read()
. This had the unexpected effect of leaving out a last word or words of a text body that comes before tool calling and only shows up once the tool calls start streaming in.
@lgrammel LMK if you have any thoughts on this implementation. I've ad-hoc tested this in my own application and it does seem to work, though I've made a few comments on the implementation where things were maybe not as ideal. |
Hi Guys! |
Hi guys any news on , when will this feature be released? |
Haven't put this PR up for review because it's a bit buggy after updating it to the latest AI SDK version.
|
Ah, I was wondering why my app kept hanging up. This would be awesome to get released |
I had the same requirement and ended up building a layer on top of streamText to do it. It sounds like this will be natively supported in the SDK at some point, but for the time being I think it's still something one needs to put together oneself. Check out https://github.com/edspencer/stream-multi if you are interested - the little video there shows the ability to have the LLM respond with both streaming text and any number of tools calls. I published it as a npm module called ai-stream-multi. It basically has the same API as streamText(), but adds the concept of |
I created a similar version here but using the new streamText api as the plumbing. |
Summary
Adds the ability to invoke multiple tool calls for
streamUI
.Addresses #1894, #1532 (comment)
NOTE: For usage with
aiState
, it's important to callaiState.done(...)
only in theonFinish
callback (if expecting multiple tool calls). -- Not sure if this is a breaking change.Tasks
onFinish
callback changes