fix(image_edit): read vertex_project/location from litellm_params in Imagen get_complete_url
VertexAIImagenImageEditConfig.get_complete_url was resolving vertex_project and vertex_location only from env vars and global settings, ignoring litellm_params. Users supplying project/location exclusively via YAML config would get a ValueError or wrong URL even after auth headers were fixed. Mirrors the pattern already used by VertexAIGeminiImageEditConfig and image_generation counterpart (safe_get_vertex_ai_project/location). Also fixes api_key type hint in MockImageEditConfig (str -> Optional[str]) and adds a test covering get_complete_url credential resolution. Made-with: Cursor
This commit is contained in:
parent
a7512764af
commit
447502b409
@ -137,8 +137,14 @@ class VertexAIImagenImageEditConfig(BaseImageEditConfig, VertexLLM):
|
||||
"""
|
||||
Get the complete URL for Vertex AI Imagen predict API
|
||||
"""
|
||||
vertex_project = self._resolve_vertex_project()
|
||||
vertex_location = self._resolve_vertex_location()
|
||||
vertex_project = (
|
||||
self.safe_get_vertex_ai_project(litellm_params)
|
||||
or self._resolve_vertex_project()
|
||||
)
|
||||
vertex_location = (
|
||||
self.safe_get_vertex_ai_location(litellm_params)
|
||||
or self._resolve_vertex_location()
|
||||
)
|
||||
|
||||
if not vertex_project or not vertex_location:
|
||||
raise ValueError(
|
||||
|
||||
@ -29,7 +29,7 @@ class MockImageEditConfig(BaseImageEditConfig):
|
||||
self,
|
||||
headers: dict,
|
||||
model: str,
|
||||
api_key: str = None,
|
||||
api_key: Optional[str] = None,
|
||||
litellm_params: Optional[dict] = None,
|
||||
api_base: Optional[str] = None,
|
||||
) -> dict:
|
||||
@ -341,6 +341,34 @@ class TestImageEditHandlerCredentialsForwarding:
|
||||
assert call_kwargs["credentials"] == "/path/to/creds.json"
|
||||
assert call_kwargs["project_id"] == "test-project-from-params"
|
||||
|
||||
def test_vertex_imagen_get_complete_url_reads_project_and_location_from_litellm_params(
|
||||
self,
|
||||
):
|
||||
"""
|
||||
VertexAIImagenImageEditConfig.get_complete_url should read
|
||||
vertex_ai_project and vertex_ai_location from litellm_params,
|
||||
not only from env vars / global settings.
|
||||
"""
|
||||
from litellm.llms.vertex_ai.image_edit.vertex_imagen_transformation import (
|
||||
VertexAIImagenImageEditConfig,
|
||||
)
|
||||
|
||||
config = VertexAIImagenImageEditConfig()
|
||||
|
||||
litellm_params = {
|
||||
"vertex_ai_project": "param-project",
|
||||
"vertex_ai_location": "us-east1",
|
||||
}
|
||||
|
||||
url = config.get_complete_url(
|
||||
model="vertex_ai/imagegeneration@002",
|
||||
api_base=None,
|
||||
litellm_params=litellm_params,
|
||||
)
|
||||
|
||||
assert "param-project" in url
|
||||
assert "us-east1" in url
|
||||
|
||||
def test_validate_environment_signature_includes_litellm_params(self):
|
||||
"""
|
||||
All image_edit config validate_environment methods should accept
|
||||
|
||||
Loading…
Reference in New Issue
Block a user