diff --git a/backend/utils/llm_calls/generate_presentation_outlines.py b/backend/utils/llm_calls/generate_presentation_outlines.py index 4649fa2..15dd3fa 100644 --- a/backend/utils/llm_calls/generate_presentation_outlines.py +++ b/backend/utils/llm_calls/generate_presentation_outlines.py @@ -140,46 +140,35 @@ async def generate_ppt_outline( client = LLMClient() - # Timeout for outline generation (prevents socket hang up) - OUTLINE_TIMEOUT = int(os.getenv("OUTLINE_TIMEOUT_SECONDS", "120")) - try: - # Wrap streaming in timeout to prevent indefinite hangs - async def stream_with_timeout(): - try: - async for chunk in client.stream_structured( - model, - get_messages( - content, - n_slides, - language, - additional_context, - tone, - verbosity, - instructions, - include_title_slide, - brand_context, - available_layouts, - content_summary, - ), - response_model.model_json_schema(), - strict=True, - tools=( - [SearchWebTool] - if (client.enable_web_grounding() and web_search) - else None - ), - ): - yield chunk - except asyncio.TimeoutError: - yield HTTPException( - status_code=504, - detail=f"Outline generation timed out after {OUTLINE_TIMEOUT}s. Please try again or reduce the number of slides." - ) - except Exception as e: - yield handle_llm_client_exceptions(e) - - async for chunk in stream_with_timeout(): + async for chunk in client.stream_structured( + model, + get_messages( + content, + n_slides, + language, + additional_context, + tone, + verbosity, + instructions, + include_title_slide, + brand_context, + available_layouts, + content_summary, + ), + response_model.model_json_schema(), + strict=True, + tools=( + [SearchWebTool] + if (client.enable_web_grounding() and web_search) + else None + ), + ): yield chunk + except asyncio.TimeoutError: + yield HTTPException( + status_code=504, + detail="Outline generation timed out. Please try again." + ) except Exception as e: yield handle_llm_client_exceptions(e)