Fixed Kling: Check attributes of pydantic types. (#144)

This commit is contained in:
Robin Huang 2025-05-05 12:36:24 -07:00 committed by GitHub
parent 87047e996f
commit d78764dda9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -151,8 +151,9 @@ def is_valid_task_creation_response(response: KlingText2VideoResponse) -> bool:
def is_valid_video_response(response: KlingText2VideoResponse) -> bool:
"""Verifies that the response contains a task result with at least one video."""
return (
"task_result" in response.data
and "videos" in response.data.task_result
response.data is not None
and response.data.task_result is not None
and response.data.task_result.videos is not None
and len(response.data.task_result.videos) > 0
)