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

Separate Text Parts with Merged Streams in processChatResponse #5435

Closed
BrianHung opened this issue Mar 28, 2025 · 1 comment
Closed

Separate Text Parts with Merged Streams in processChatResponse #5435

BrianHung opened this issue Mar 28, 2025 · 1 comment
Labels
ai/ui enhancement New feature or request

Comments

@BrianHung
Copy link
Contributor

Feature Description

I'm merging data streams of individual streamTexts to enable a multi-step workflow.
https://x.com/aisdk/status/1896946680081302007

Right now, the behavior of processChatResponse is to accumulate the text parts and reasoning text parts of separate streams into the same part.

So for multiple streams, parts would always be [TextPart, ToolCallPart, ToolCallPart].

What I'm looking for is, [TextPart, ToolCallPart, TextPart, ToolCallPart].

Use Cases

With merged streams, we want to keep the text interweaved and not accumulate.

Before

Image

After

Image

Additional context

No response

@BrianHung BrianHung added the enhancement New feature or request label Mar 28, 2025
@lgrammel lgrammel added the ai/ui label Mar 29, 2025
@BrianHung
Copy link
Contributor Author

Turns out latest version of vercel ai already has this implemented here:
https://github.com/vercel/ai/blame/4dece70cbc9606ea0c0c7921b10f43b8cce96791/packages/ui-utils/src/process-chat-response.ts#L361-L364

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

2 participants