Fix: error validating Kling image response, trying to use "key" in on Pydantic class instance (#147)

This commit is contained in:
Christian Byrne 2025-05-05 13:20:28 -07:00 committed by GitHub
parent 7399187340
commit 1ec10422d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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