diff --git a/servers/fastapi/api/v1/ppt/endpoints/presentation.py b/servers/fastapi/api/v1/ppt/endpoints/presentation.py index b4063b9e..29da8cc4 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/presentation.py +++ b/servers/fastapi/api/v1/ppt/endpoints/presentation.py @@ -204,8 +204,6 @@ async def stream_presentation( status_code=400, detail="Outlines can not be empty", ) - await sql_session.execute(delete(SlideModel).where(SlideModel.presentation == presentation_id)) - await sql_session.commit() image_generation_service = ImageGenerationService(get_images_directory()) @@ -271,6 +269,12 @@ async def stream_presentation( for assets_list in generated_assets_lists: generated_assets.extend(assets_list) + # Moved this here to make sure new slides are generated before deleting the old ones + await sql_session.execute( + delete(SlideModel).where(SlideModel.presentation == presentation_id) + ) + await sql_session.commit() + sql_session.add(presentation) sql_session.add_all(slides) sql_session.add_all(generated_assets)