mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-30 01:52:18 +00:00
fix(azure_ai): ignore non-finite FLUX.2 request_meta megapixels
This commit is contained in:
parent
61a361abbf
commit
3608ba392e
2 changed files with 6 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import math
|
||||
from collections.abc import Mapping
|
||||
from types import MappingProxyType
|
||||
from typing import TYPE_CHECKING, Final
|
||||
|
|
@ -42,7 +43,10 @@ def with_flux2_billed_megapixels(image_response: ImageResponse, raw_response: ht
|
|||
request_meta: Final = _Flux2ResponseBody.model_validate_json(raw_response.content).request_meta
|
||||
except ValidationError:
|
||||
return image_response
|
||||
image_response.set_provider_billed_megapixels(request_meta.input_mp + request_meta.output_mp)
|
||||
billed_megapixels: Final = request_meta.input_mp + request_meta.output_mp
|
||||
if not math.isfinite(billed_megapixels):
|
||||
return image_response
|
||||
image_response.set_provider_billed_megapixels(billed_megapixels)
|
||||
return image_response
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ def test_flux2_cost_uses_mapped_dimensions_after_response_transformation(dimensi
|
|||
({"input_mp": 45.78, "output_mp": 1.0}, 46.78),
|
||||
({"output_mp": 0.39}, 2048 * 1024 / (1024 * 1024)),
|
||||
({"input_mp": -1.0, "output_mp": 0.39}, 2048 * 1024 / (1024 * 1024)),
|
||||
({"input_mp": 1.7e308, "output_mp": 1.7e308}, 2048 * 1024 / (1024 * 1024)),
|
||||
),
|
||||
)
|
||||
def test_flux2_generation_bills_azure_reported_megapixels_and_falls_back_to_requested_size(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue