-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Modify smoothStream transform to support tool call streams #5326
base: main
Are you sure you want to change the base?
Conversation
Extends the smoothStream transform to handle both text and tool call streaming: - Add separate buffers for text and tool call arguments - Special handling for tool-related chunk types (tool-call, tool-call-delta, tool-result) - Add buffer flushing logic for various stream states - Implement TransformStream flush method to handle remaining content - Keep consistent chunking behavior across both text and tool call streams
Please run pnpm |
There are some bugs. Can you add test cases as a first step? Once this is bug-free there will also need to be some refactoring. Finally, this feature should be opt in using a flag e.g. |
if (toolCallBuffer && toolCallBuffer.buffer.length > 0) { | ||
controller.enqueue({ | ||
type: 'tool-call-delta', | ||
toolCallId: toolCallBuffer.id, | ||
toolName: toolCallBuffer.name, | ||
argsTextDelta: toolCallBuffer.buffer, | ||
}); | ||
} |
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.
bug: what if there are several ongoing tool calls?
controller.enqueue({ | ||
type: 'tool-call-delta', | ||
toolCallId: toolCallBuffer.id, | ||
toolName: toolCallBuffer.name, | ||
argsTextDelta: toolCallBuffer.buffer, | ||
}); | ||
toolCallBuffer = null; |
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.
bug: what if there are several ongoing tool calls?
Extends the smoothStream transform to handle both text and tool call streaming: