mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
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.
This commit is contained in:
parent
25bc066dba
commit
319667284e
2 changed files with 7 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue