@@ -386,12 +386,25 @@ def __init__(self, partial_images: int | None = None):
386386 """
387387 self .partial_images = partial_images
388388
389- async def base64_image_to_url (self , base64_image : str ) -> str :
389+ async def base64_image_to_url (
390+ self ,
391+ image_id : str ,
392+ base64_image : str ,
393+ partial_image_index : int | None = None ,
394+ ) -> str :
390395 """
391396 Convert a base64-encoded image into a URL.
392397
393398 This method is used to produce the URL stored on thread items for image
394399 generation results.
400+
401+ Args:
402+ image_id: The ID of the image generation call. This stays stable across partial image updates.
403+ base64_image: The base64-encoded image.
404+ partial_image_index: The index of the partial image update, starting from 0.
405+
406+ Returns:
407+ A URL string.
395408 """
396409 return f"data:image/png;base64,{ base64_image } "
397410
@@ -695,7 +708,7 @@ def end_workflow(item: WorkflowItem):
695708 if not ctx .generated_image_item :
696709 continue
697710
698- url = await converter .base64_image_to_url (item .result )
711+ url = await converter .base64_image_to_url (item .id , item . result )
699712 image = GeneratedImage (id = item .id , url = url )
700713
701714 ctx .generated_image_item .image = image
@@ -706,7 +719,11 @@ def end_workflow(item: WorkflowItem):
706719 if not ctx .generated_image_item :
707720 continue
708721
709- url = await converter .base64_image_to_url (event .partial_image_b64 )
722+ url = await converter .base64_image_to_url (
723+ event .item_id ,
724+ event .partial_image_b64 ,
725+ event .partial_image_index ,
726+ )
710727 progress = converter .partial_image_index_to_progress (
711728 event .partial_image_index
712729 )
0 commit comments