From 319667284e451fb1b77c9cbcf0a2399c9bff45c2 Mon Sep 17 00:00:00 2001 From: Kris Xia Date: Tue, 12 May 2026 10:07:24 +0800 Subject: [PATCH] chore(vertex_ai): translate chunk error-check comments to english - Translate docstring and inline comments for the mid-stream error detection added in PR #23711 so the codebase stays English-only. - Apply Black (23.12) formatting on the corresponding regression test. --- .../vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py | 6 +++--- .../gemini/test_vertex_and_google_ai_studio_gemini.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index ee269b457c1..8ab31791397 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -3141,7 +3141,7 @@ class ModelResponseIterator: @staticmethod def _check_streaming_error(chunk: dict) -> None: - """检测流式响应中内嵌的错误(如 429 RESOURCE_EXHAUSTED),有错误时抛出 VertexAIError。""" + """Detect embedded errors (e.g. 429 RESOURCE_EXHAUSTED) in streaming chunks and raise VertexAIError.""" if "error" not in chunk: return error_data = chunk["error"] @@ -3276,8 +3276,8 @@ class ModelResponseIterator: try: verbose_logger.debug(f"RAW GEMINI CHUNK: {chunk}") - # 检测流式响应中内嵌的错误(如 429 RESOURCE_EXHAUSTED)。 - # 这类错误以 HTTP 200 返回,但 SSE body 中包含 error JSON。 + # Detect mid-stream error chunks (e.g. 429 RESOURCE_EXHAUSTED). + # Vertex AI can return errors as HTTP 200 but with an "error" field in the SSE body. self._check_streaming_error(chunk) from litellm.types.utils import ModelResponseStream diff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py index 7c724b01ed1..c679d08b826 100644 --- a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py +++ b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_and_google_ai_studio_gemini.py @@ -4466,7 +4466,7 @@ def test_chunk_parser_raises_on_string_error_code(): ModelResponseIterator, ) - # code 字段为字符串类型 "429" 而非 int + # code field is a string "429" rather than an int error_chunk = { "error": { "code": "429", @@ -4575,7 +4575,9 @@ def test_mid_stream_429_error_raises_during_iteration(): results.append(chunk) # Verify: received normal chunks before the error - assert len(results) >= 1, "Should have received at least 1 normal chunk before the error" + assert ( + len(results) >= 1 + ), "Should have received at least 1 normal chunk before the error" # Verify: 429 error is properly raised assert exc_info.value.status_code == 429