-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor the streaming part. #20
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
Conversation
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.
Pull Request Overview
This PR refactors the streaming layer to consolidate and simplify how SDK streaming events are translated into public ConverseStreamElement values. It removes legacy mock stream methods, introduces dedicated test stream generators, and overhauls ConverseReplyStream to use a buffered state machine with logging and new cases (text, reasoning, toolUse, metaData).
- Remove old mock implementations and add new package-scoped stream generators under
Tests/ConverseStream - Update
ConverseStreamElementenum to new cases and addResponseMetadata - Rewrite
ConverseReplyStreamto convert raw SDK output into buffered state-driven elements with logging
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Mock/MockBedrockRuntimeClient.swift | Remove legacy mock stream methods |
| Tests/ConverseStream/MockBedrockRuntimeClient+StreamGenerator.swift | Add new package-scoped stream generators |
| Tests/ConverseStream/*.swift | Delete old vision/text/document tests, update tool/reasoning tests |
| Sources/Converse/Streaming/ToolUseStart.swift | Rename toolUseId to id, adjust initializers |
| Sources/Converse/Streaming/ResponseMetaData.swift | Introduce ResponseMetadata and nested types |
| Sources/Converse/Streaming/ConverseStreamElement.swift | Update enum cases (messageStart, text, reasoning, toolUse, metaData) |
| Sources/Converse/Streaming/ConverseReplyStream.swift | Rewrite stream conversion logic with buffered state, logging, and flush helper |
| Sources/Converse/Message.swift | Add StopReason, record stop reason in Message |
Comments suppressed due to low confidence (1)
Tests/ConverseStream/ConverseStreamToolTests.swift:22
- [nitpick] The file name
ConverseStreamToolTests.swiftsuggests tests for stream tooling, but it extendsConverseReplyStreamTests. Consider renaming the file or matching the extension target to keep names consistent.
extension ConverseReplyStreamTests {
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
The new streaming code exposes the following elements