style(vertex-ai): satisfy Veo quality gates

This commit is contained in:
Emerson Gomes 2026-08-12 13:39:06 -05:00
parent 6f3a7c80ca
commit bbe9fc78e9
No known key found for this signature in database
GPG key ID: D3DF28AB5D1B5E17
2 changed files with 23 additions and 17 deletions

View file

@ -7,6 +7,8 @@ Based on: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-refer
import base64
import time
from collections.abc import Mapping
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, ClassVar, Final, cast
import httpx
@ -92,18 +94,22 @@ class VertexAIVideoConfig(BaseVideoConfig, VertexBase):
3. Extract video data (base64) from response
"""
_OPENAI_VIDEO_SIZE_TO_ASPECT_RATIO: ClassVar[dict[str, str]] = {
"1280x720": "16:9",
"1920x1080": "16:9",
"720x1280": "9:16",
"1080x1920": "9:16",
}
_OPENAI_VIDEO_SIZE_TO_RESOLUTION: ClassVar[dict[str, str]] = {
"1280x720": "720p",
"1920x1080": "1080p",
"720x1280": "720p",
"1080x1920": "1080p",
}
_OPENAI_VIDEO_SIZE_TO_ASPECT_RATIO: ClassVar[Mapping[str, str]] = MappingProxyType(
{
"1280x720": "16:9",
"1920x1080": "16:9",
"720x1280": "9:16",
"1080x1920": "9:16",
}
)
_OPENAI_VIDEO_SIZE_TO_RESOLUTION: ClassVar[Mapping[str, str]] = MappingProxyType(
{
"1280x720": "720p",
"1920x1080": "1080p",
"720x1280": "720p",
"1080x1920": "1080p",
}
)
def __init__(self):
BaseVideoConfig.__init__(self)
@ -213,9 +219,9 @@ class VertexAIVideoConfig(BaseVideoConfig, VertexBase):
@staticmethod
def _supports_resolution_inference(model: str) -> bool:
model_key = model if model.startswith("vertex_ai/") else f"vertex_ai/{model}"
model_info = litellm.model_cost.get(model_key, {})
return model_info.get("output_cost_per_second_1080p") is not None
model_key: Final = model if model.startswith("vertex_ai/") else f"vertex_ai/{model}"
model_info: Final = litellm.model_cost.get(model_key)
return model_info is not None and model_info.get("output_cost_per_second_1080p") is not None
def validate_environment(
self,

View file

@ -2,7 +2,7 @@ from typing import Any, Literal
from openai.types.audio.transcription_create_params import FileTypes
from pydantic import BaseModel
from typing_extensions import TypedDict
from typing_extensions import ReadOnly, TypedDict
class VideoObject(BaseModel):
@ -76,7 +76,7 @@ class VideoCreateOptionalRequestParams(TypedDict, total=False):
image: Any | None # Image for image-to-video; dict with gcsUri/bytesBase64Encoded, or file-like object
parameters: dict[str, Any] | None # Provider-specific parameters block passed directly to the API
model: str | None
resolution: str | None
resolution: ReadOnly[str | None]
seconds: str | None
size: str | None
characters: list[dict[str, str]] | None