mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
Merge 13b77ea1b9 into 8fc0663198
This commit is contained in:
commit
3011bc49dc
2 changed files with 20 additions and 1 deletions
|
|
@ -872,6 +872,8 @@ class OpenAIChatCompletionStreamingHandler(BaseModelResponseIterator):
|
|||
}
|
||||
if "usage" in chunk and chunk["usage"] is not None:
|
||||
kwargs["usage"] = chunk["usage"]
|
||||
if "service_tier" in chunk and chunk["service_tier"] is not None:
|
||||
kwargs["service_tier"] = chunk["service_tier"]
|
||||
return ModelResponseStream(**kwargs)
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ Tests for OpenAI GPT transformation (litellm/llms/openai/chat/gpt_transformation
|
|||
|
||||
import pytest
|
||||
|
||||
|
||||
import litellm
|
||||
from litellm.litellm_core_utils.prompt_templates.common_utils import TOOL_RESULT_IMAGE_BOUNDARY
|
||||
from litellm.llms.openai.chat.gpt_5_transformation import OpenAIGPT5Config
|
||||
|
|
@ -247,6 +246,24 @@ class TestOpenAIChatCompletionStreamingHandler:
|
|||
assert result.usage.completion_tokens == 350
|
||||
assert result.usage.total_tokens == 14147
|
||||
|
||||
def test_chunk_parser_preserves_service_tier(self):
|
||||
"""Provider service-tier responses must survive chunk normalization."""
|
||||
handler = OpenAIChatCompletionStreamingHandler(
|
||||
streaming_response=None, sync_stream=True
|
||||
)
|
||||
|
||||
result = handler.chunk_parser(
|
||||
{
|
||||
"id": "gen-123",
|
||||
"created": 1234567890,
|
||||
"model": "xai/grok-4.6",
|
||||
"choices": [],
|
||||
"service_tier": "priority",
|
||||
}
|
||||
)
|
||||
|
||||
assert result.service_tier == "priority"
|
||||
|
||||
def test_chunk_parser_raises_on_in_body_error_payload(self):
|
||||
"""vLLM/sglang return HTTP 200 streams whose body carries the error,
|
||||
e.g. data: {"error": {..., "code": 400}}. chunk_parser must surface it
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue