add better error propagation to veo2 (#37)

This commit is contained in:
thot experiment 2025-04-29 17:28:18 -07:00 committed by GitHub
parent cc9ce9ad9b
commit 122a4b4288
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1311 additions and 627 deletions

View File

@ -1,6 +1,6 @@
# generated by datamodel-codegen: # generated by datamodel-codegen:
# filename: https://stagingapi.comfy.org/openapi # filename: filtered-openapi.yaml
# timestamp: 2025-04-29T03:13:19+00:00 # timestamp: 2025-04-29T23:44:54+00:00
from __future__ import annotations from __future__ import annotations

View File

@ -1,12 +1,12 @@
# generated by datamodel-codegen: # generated by datamodel-codegen:
# filename: https://stagingapi.comfy.org/openapi # filename: filtered-openapi.yaml
# timestamp: 2025-04-29T03:13:19+00:00 # timestamp: 2025-04-29T23:44:54+00:00
from __future__ import annotations from __future__ import annotations
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, constr from pydantic import BaseModel, Field
class V2OpenAPII2VResp(BaseModel): class V2OpenAPII2VResp(BaseModel):
@ -30,10 +30,10 @@ class V2OpenAPIT2VReq(BaseModel):
description='Motion mode (normal, fast, --fast only available when duration=5; --quality=1080p does not support fast)', description='Motion mode (normal, fast, --fast only available when duration=5; --quality=1080p does not support fast)',
examples=['normal'], examples=['normal'],
) )
negative_prompt: Optional[constr(max_length=2048)] = Field( negative_prompt: Optional[str] = Field(
None, description='Negative prompt\n' None, description='Negative prompt\n', max_length=2048
) )
prompt: constr(max_length=2048) = Field(..., description='Prompt') prompt: str = Field(..., description='Prompt', max_length=2048)
quality: str = Field( quality: str = Field(
..., ...,
description='Video quality ("360p"(Turbo model), "540p", "720p", "1080p")', description='Video quality ("360p"(Turbo model), "540p", "720p", "1080p")',

File diff suppressed because it is too large Load Diff

View File

@ -228,8 +228,28 @@ class VeoVideoGenerationNode(ComfyNodeABC):
poll_response = poll_operation.execute() poll_response = poll_operation.execute()
# Check for error in poll response
if hasattr(poll_response, 'error') and poll_response.error:
error_message = f"Veo API error: {poll_response.error.message} (code: {poll_response.error.code})"
logging.error(error_message)
raise Exception(error_message)
if poll_response.done: if poll_response.done:
if poll_response.response and poll_response.response.videos and len(poll_response.response.videos) > 0: # Check for RAI filtered content
if (hasattr(poll_response.response, 'raiMediaFilteredCount') and
poll_response.response.raiMediaFilteredCount > 0):
# Extract reason message if available
if (hasattr(poll_response.response, 'raiMediaFilteredReasons') and
poll_response.response.raiMediaFilteredReasons):
reason = poll_response.response.raiMediaFilteredReasons[0]
error_message = f"Content filtered by Google's Responsible AI practices: {reason} ({poll_response.response.raiMediaFilteredCount} videos filtered.)"
logging.error(error_message)
raise Exception(error_message)
# Process successful response
if poll_response.response and hasattr(poll_response.response, 'videos') and poll_response.response.videos and len(poll_response.response.videos) > 0:
video = poll_response.response.videos[0] video = poll_response.response.videos[0]
# Check if video is provided as base64 or URL # Check if video is provided as base64 or URL