diff --git a/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py b/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py index 3ad01ddd..27a01244 100644 --- a/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py +++ b/electron/servers/fastapi/api/v1/ppt/endpoints/presentation.py @@ -317,9 +317,9 @@ async def stream_presentation( # This will mutate slide and add placeholder assets process_slide_add_placeholder_assets(slide) - # This will mutate slide + # This will mutate slide - start task immediately so it runs in parallel with next slide LLM generation async_assets_generation_tasks.append( - process_slide_and_fetch_assets(image_generation_service, slide) + asyncio.create_task(process_slide_and_fetch_assets(image_generation_service, slide)) ) yield SSEResponse( @@ -721,9 +721,9 @@ async def generate_presentation_handler( slides.append(slide) batch_slides.append(slide) - # Start asset fetch tasks for just-generated slides so they run while next batch is processed + # Start asset fetch tasks immediately so they run in parallel with next batch's LLM calls asset_tasks = [ - process_slide_and_fetch_assets(image_generation_service, slide) + asyncio.create_task(process_slide_and_fetch_assets(image_generation_service, slide)) for slide in batch_slides ] async_assets_generation_tasks.extend(asset_tasks) diff --git a/servers/fastapi/api/v1/ppt/endpoints/presentation.py b/servers/fastapi/api/v1/ppt/endpoints/presentation.py index a2cbc4ed..6d377f2d 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/presentation.py +++ b/servers/fastapi/api/v1/ppt/endpoints/presentation.py @@ -317,9 +317,9 @@ async def stream_presentation( # This will mutate slide and add placeholder assets process_slide_add_placeholder_assets(slide) - # This will mutate slide + # This will mutate slide - start task immediately so it runs in parallel with next slide LLM generation async_assets_generation_tasks.append( - process_slide_and_fetch_assets(image_generation_service, slide) + asyncio.create_task(process_slide_and_fetch_assets(image_generation_service, slide)) ) yield SSEResponse( @@ -716,9 +716,9 @@ async def generate_presentation_handler( slides.append(slide) batch_slides.append(slide) - # Start asset fetch tasks for just-generated slides so they run while next batch is processed + # Start asset fetch tasks immediately so they run in parallel with next batch's LLM calls asset_tasks = [ - process_slide_and_fetch_assets(image_generation_service, slide) + asyncio.create_task(process_slide_and_fetch_assets(image_generation_service, slide)) for slide in batch_slides ] async_assets_generation_tasks.extend(asset_tasks)