-
Notifications
You must be signed in to change notification settings - Fork 3
fix: implement real-time streaming with proper flushing #8
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
fix: implement real-time streaming with proper flushing #8
Conversation
(base) PS C:\Users\Administrator\Documents\GitHub\autocache> go test ./...
? autocache/cmd/autocache [no test files]
ok autocache/internal/cache 0.068s
? autocache/internal/client [no test files]
ok autocache/internal/config 0.072s
ok autocache/internal/pricing 0.061s
ok autocache/internal/server 0.083s
ok autocache/internal/tokenizer 2.706s
ok autocache/internal/types 0.049sIt seems that all the tests have passed. No new tests were created because no new features were added. This is the first time I have submitted to an open-source project using the Pull Request function, so I'm not very familiar with it. If there are any mistakes in the process, you can leave a message for discussion. 测试看起来都通过了. 没有创建新的测试, 因为并没有新的功能添加. 这是我第一次使用Pull Request功能提交到开源项目, 因此我并不是很熟悉它. 如果流程有误可以留言讨论. |
…ianYi0217/autocache into feature/fix-streaming-realtime
|
Thanks @TianYi0217 for this excellent contribution! Review SummaryI've reviewed the changes and they correctly address the streaming buffering issue. The implementation is sound: ✅ What works well:
📝 Test CoverageI've added comprehensive unit tests to validate the Flush functionality:
All tests pass ✅ 🎯 RecommendationAPPROVE - Ready to merge This PR delivers real-time streaming as expected, with proper HTTP flushing for server-sent events. The changes are backward compatible and include graceful degradation when flushing isn't available. Great work! 🎉 |
Add comprehensive unit tests for the http.Flusher interface implementation in responseWrapper, which is required for real-time streaming support. Tests added: - TestResponseWrapperFlush: Validates that responseWrapper implements http.Flusher and properly delegates Flush() calls to the underlying ResponseWriter - TestResponseWrapperFlushWithNonFlusher: Ensures graceful handling when the underlying ResponseWriter doesn't support flushing These tests validate the PR #8 changes that fix real-time streaming by implementing proper HTTP flushing for server-sent events.
Add changelog entry for v1.0.4 release documenting the real-time streaming improvements from PR #8. Changes: - Document fix for real-time streaming with proper HTTP flushing - Detail technical implementation (manual read/write loop, Flush interface) - Note 512-byte buffer optimization for SSE events - Credit @TianYi0217 for the contribution - Add unit test additions to changelog
Add changelog entry for v1.0.4 release documenting the real-time streaming improvements from PR #8. Changes: - Document fix for real-time streaming with proper HTTP flushing - Detail technical implementation (manual read/write loop, Flush interface) - Note 512-byte buffer optimization for SSE events - Credit @TianYi0217 for the contribution - Add unit test additions to changelog
Add changelog entry for v1.0.4 release documenting the real-time streaming improvements from PR #8. Changes: - Document fix for real-time streaming with proper HTTP flushing - Detail technical implementation (manual read/write loop, Flush interface) - Note 512-byte buffer optimization for SSE events - Credit @TianYi0217 for the contribution - Add unit test additions to changelog Co-authored-by: chema <[email protected]>
The streaming output seems correct but only appears together at the very last moment. I tried to use AI tools to find and modify this problem.
Since I'm not familiar with go, I followed the ai's advice and used a streaming package size of 512b instead of the 100-200b officially used by Anthropic. You can modify it to a more suitable size.
流式输出看起来正确但是只有在最后的时刻才一起出现. 我试着用AI工具找到并修改了这个问题.
因为我对go并不了解, 所以遵循ai的建议使用了并非Anthropic官方使用的100-200b而是512b的流式包大小. 你们可以修改成更合适的大小.
This project is extremely helpful. I have been facing this problem for a long time but don't have the appropriate ability to complete similar projects. Thank you all.
这个项目非常的有帮助, 我长期面临这个问题但是没有合适的能力来完成类似的项目, 感谢你们.