From 1523511e97558382316a80f4d3afe8dee6ec4290 Mon Sep 17 00:00:00 2001 From: sudipnext Date: Mon, 2 Mar 2026 17:17:46 +0545 Subject: [PATCH] feat: optimize asset fetching by starting tasks immediately for parallel processing --- .../servers/fastapi/api/v1/ppt/endpoints/presentation.py | 8 ++++---- servers/fastapi/api/v1/ppt/endpoints/presentation.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) 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)