Log more descriptive error when image gen fails with Replicate

This commit is contained in:
Debanjum Singh Solanky 2024-10-24 01:01:48 -07:00
parent 5120597d4e
commit 2a32836d1a

View file

@ -204,9 +204,10 @@ def generate_image_with_replicate(
# Raise exception if the image generation task fails
if status != "succeeded":
error = get_prediction.get("error")
if retry_count >= 10:
raise requests.RequestException("Image generation timed out")
raise requests.RequestException(f"Image generation failed with status: {status}")
raise requests.RequestException(f"Image generation failed with status: {status}, message: {error}")
# Get the generated image
image_url = get_prediction["output"][0] if isinstance(get_prediction["output"], list) else get_prediction["output"]