Skip to content

Commit 39f36a1

Browse files
author
Roy
committed
Implement error handling for asynchronous image URL generation in process_single_aspect function, logging errors and setting a default empty string for image_url on failure.
1 parent adb0bc5 commit 39f36a1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,15 @@ async def process_single_aspect(
485485
formatted_response = await run_formated_llm_call_async(rag_messages, Aspect, model_type="large")
486486

487487
# Get image URL asynchronously
488-
formatted_response["image_url"] = await get_image_url_async(
489-
formatted_response["title"], formatted_response["description"]
490-
)
488+
try:
489+
formatted_response["image_url"] = await get_image_url_async(
490+
formatted_response["title"], formatted_response["description"]
491+
)
492+
except Exception as e:
493+
logger.error(
494+
f"Error in async image generation for aspect '{formatted_response['title']}': {e}"
495+
)
496+
formatted_response["image_url"] = ""
491497

492498
# Update segments (same logic)
493499
updated_segments = []

0 commit comments

Comments
 (0)