This commit is contained in:
Temo 2026-10-20 01:15:43 +00:00 • committed by GitHub
commit c2ede42307
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View file

@ -86,4 +86,6 @@ class AiohttpOpenAIChatConfig(OpenAILikeChatConfig):
model_response.model = _json_response.get("model")
model_response.object = _json_response.get("object")
model_response.system_fingerprint = _json_response.get("system_fingerprint")
if "service_tier" in _json_response:
model_response.service_tier = _json_response.get("service_tier")
return model_response

View file

@ -99,3 +99,16 @@ async def test_transform_response_rejects_choices_that_are_not_a_list_of_objects
async def test_transform_response_rejects_a_choice_whose_message_is_not_an_object():
with pytest.raises(ValidationError, match="validation error for Choices"):
await _transform({"choices": [{"message": "text"}]})
@pytest.mark.parametrize("tier", ["flex", "priority", "default"])
async def test_transform_response_forwards_service_tier(tier: str):
response = await _transform({"id": "chatcmpl-1", "choices": [{}], "service_tier": tier})
assert response.service_tier == tier
async def test_transform_response_service_tier_is_none_when_omitted():
response = await _transform({"id": "chatcmpl-1", "choices": [{}]})
assert getattr(response, "service_tier", None) is None