mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
fix(vertex_ai): map missing image on Gemini image edit to BadRequestError (400) (#50244)
This commit is contained in:
parent
709b27e268
commit
4ed339b2fc
2 changed files with 8 additions and 3 deletions
|
|
@ -166,7 +166,11 @@ class VertexAIGeminiImageEditConfig(BaseImageEditConfig, VertexLLM):
|
|||
) -> tuple[dict[str, object], RequestFiles | None]:
|
||||
inline_parts: Final = self._prepare_inline_image_parts(image) if image else []
|
||||
if not inline_parts:
|
||||
raise ValueError("Vertex AI Gemini image edit requires at least one image.")
|
||||
raise litellm.BadRequestError(
|
||||
message="Vertex AI Gemini image edit requires at least one image.",
|
||||
model=model,
|
||||
llm_provider="vertex_ai",
|
||||
)
|
||||
|
||||
# Build parts list with image and prompt (if provided)
|
||||
text_parts: Final[list[HttpxPartType]] = [{"text": prompt}] if prompt is not None and prompt != "" else []
|
||||
|
|
|
|||
|
|
@ -231,10 +231,10 @@ class TestVertexAIGeminiImageEditTransformation:
|
|||
)
|
||||
|
||||
def test_transform_image_edit_request_without_image_raises(self) -> None:
|
||||
"""Test that missing image raises ValueError"""
|
||||
"""Test that missing image raises BadRequestError with 400 status code"""
|
||||
optional_params = {}
|
||||
|
||||
with pytest.raises(ValueError, match="requires at least one image"):
|
||||
with pytest.raises(litellm.BadRequestError, match="requires at least one image") as exc_info:
|
||||
self.config.transform_image_edit_request(
|
||||
model=self.model,
|
||||
prompt=self.prompt,
|
||||
|
|
@ -243,6 +243,7 @@ class TestVertexAIGeminiImageEditTransformation:
|
|||
litellm_params=MagicMock(),
|
||||
headers={},
|
||||
)
|
||||
assert exc_info.value.status_code == 400
|
||||
|
||||
def test_validate_environment_with_litellm_params(self) -> None:
|
||||
"""Test validate_environment uses credentials from litellm_params"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue