Auto: feature/streaming-translation #12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/streaming-translation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Automated PR for branch
feature/streaming-translation.Changes Requested
Well-structured streaming implementation with good error handling, retry logic, fallback to non-streaming, and solid test coverage. One bug to fix: the streaming callback escapes text for HTML but doesn't tell Telegram to parse it as HTML.
Warnings
_make_streaming_callbackcallssafe_html(accumulated_text)which escapes<,>,&into HTML entities (<,>,&), butbot.edit_message_textis called withoutparse_mode="HTML". Telegram treats the message as plain text, so users will see literal&,<etc. during streaming if their text contains those characters. Fix: addparse_mode="HTML"to theedit_message_textcall. Note: the testtest_streaming_stops_edits_on_deleted_messageuses the absence ofparse_modeto distinguish streaming edits from final edits — that test logic will also need updating.Suggestions
_retryable_errorsdict is rebuilt on every call to_perform_streaming_translation. Since it's static, consider making it a module-level constant (same pattern as in_perform_single_model_translationif applicable) to avoid repeated allocation.Approved
Clean, well-implemented streaming translation feature with good resilience patterns. Timeout covers full stream iteration, chunk errors are gracefully skipped, Telegram edits are throttled and capped, retries disable streaming edits to avoid UX jank, and non-streaming fallback provides a last resort. Security is handled via safe_html before HTML-mode edits. Test coverage is thorough across happy path, error, and edge cases.
Suggestions
_retryable_errorsdict is recreated on every call to_perform_streaming_translation. Since it's static, it could be a module-level constant (like_STREAMING_RETRYABLE_ERRORS) to make it clearer that it doesn't depend on runtime state._fake_stream_iteratorhelper is imported as a private function (_prefix) from conftest into the test file. Consider renaming it tofake_stream_iterator(no underscore) since it's part of the test utilities' public API used across test modules.forloop (lines ~567-574) is unreachable — every loop iteration ends with areturnorcontinue. This is harmless defensive code but could be annotated with a# pragma: no coverif you track coverage.