mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
fix(azure_ai): use the pixel cap the live MAI endpoint enforces
This commit is contained in:
parent
84a99dfc31
commit
38a3de7641
2 changed files with 23 additions and 2 deletions
|
|
@ -24,7 +24,7 @@ class AzureFoundryMAIImageGenerationConfig(BaseImageGenerationConfig):
|
|||
|
||||
MAX_IMAGES_PER_REQUEST: Final = 1
|
||||
MIN_DIMENSION_PX: Final = 768
|
||||
MAX_TOTAL_PX: Final = 1024 * 1024
|
||||
MAX_TOTAL_PX: Final = 1_056_768
|
||||
|
||||
@staticmethod
|
||||
def get_mai_image_generation_url(
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ class TestAzureMAIImageGeneration:
|
|||
@pytest.mark.parametrize("size", ["1792x1024", "1024x1792"])
|
||||
def test_map_openai_params_size_over_total_pixel_budget_raises(self, size):
|
||||
config = AzureFoundryMAIImageGenerationConfig()
|
||||
with pytest.raises(UnsupportedParamsError, match="at most 1048576 total pixels"):
|
||||
with pytest.raises(UnsupportedParamsError, match="at most 1056768 total pixels"):
|
||||
config.map_openai_params(
|
||||
non_default_params={"size": size},
|
||||
optional_params={},
|
||||
|
|
@ -221,6 +221,27 @@ class TestAzureMAIImageGeneration:
|
|||
drop_params=True,
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize("size", ["1032x1024", "1376x768"])
|
||||
def test_map_openai_params_size_at_live_pixel_cap_passes_through(self, size):
|
||||
config = AzureFoundryMAIImageGenerationConfig()
|
||||
optional_params = config.map_openai_params(
|
||||
non_default_params={"size": size},
|
||||
optional_params={},
|
||||
model="MAI-Image-2.5",
|
||||
drop_params=False,
|
||||
)
|
||||
assert optional_params["width"] * optional_params["height"] == 1_056_768
|
||||
|
||||
def test_map_openai_params_size_one_pixel_over_live_cap_raises(self):
|
||||
config = AzureFoundryMAIImageGenerationConfig()
|
||||
with pytest.raises(UnsupportedParamsError, match="at most 1056768 total pixels"):
|
||||
config.map_openai_params(
|
||||
non_default_params={"size": "1033x1024"},
|
||||
optional_params={},
|
||||
model="MAI-Image-2.5",
|
||||
drop_params=False,
|
||||
)
|
||||
|
||||
def test_map_openai_params_explicit_width_height_not_range_checked(self):
|
||||
config = AzureFoundryMAIImageGenerationConfig()
|
||||
optional_params = config.map_openai_params(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue