diff --git a/server/app.py b/server/app.py index e5d8fe6..f75eed2 100644 --- a/server/app.py +++ b/server/app.py @@ -23,6 +23,7 @@ from capcut_agent.pipeline import process_bg_template, process_paste from capcut_agent.paste import parse_paste from capcut_agent.draft import DEFAULT_DRAFT_ROOT, list_drafts, repair_layers from capcut_agent import comments as hlab +from capcut_agent import recommend from capcut_agent import plan as autoplan from capcut_agent import prompts as prompt_store from capcut_agent.correct import GeminiQuotaError, has_gemini_key @@ -530,6 +531,17 @@ async def auto_stream(aid: str) -> StreamingResponse: matched = hlab.match_window(comments, h["start"], h["end"]) h["matched"] = matched h["candidates"] = hlab.top_liked(no_ts, set(matched), len(no_ts)) + # 컷별 추천 — 실패해도 위의 matched/candidates 로 화면이 돌아간다. + # Gemini 호출이 섞여 있어 블로킹이므로 스레드로 뺀다. + try: + cuts, need = await asyncio.to_thread( + recommend.build_highlight_cuts, h, comments) + if cuts: + h["cuts"], h["need"] = cuts, need + except Exception as exc: # noqa: BLE001 — 추천 실패가 생성을 막으면 안 된다 + warnings.append( + f"ID {h.get('id')} 컷별 추천 실패 — 기존 방식으로 표시 " + f"({type(exc).__name__}: {exc})") yield _sse({"type": "result", "highlights": highlights, "comments": comments, "warnings": warnings})