From 90ff2b174fd47e7c74c7eedca648a997558ecccf Mon Sep 17 00:00:00 2001 From: "hehihoho3@gmail.com" Date: Tue, 4 Aug 2026 12:12:35 +0900 Subject: [PATCH] =?UTF-8?q?/auto/analyze=20=EA=B2=B0=EA=B3=BC=EC=97=90=20?= =?UTF-8?q?=EC=BB=B7=EB=B3=84=20=EC=B6=94=EC=B2=9C(cuts[])=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 댓글 매칭 후 recommend.build_highlight_cuts()를 호출해 하이라이트별 cuts/need를 SSE result에 실어 보낸다. Gemini 호출이 블로킹이라 asyncio.to_thread로 스레드에서 돌리고, 실패해도 기존 matched/candidates로 화면이 폴백하도록 warnings에만 기록하고 드래프트 생성은 막지 않는다. Co-Authored-By: Claude Opus 5 (1M context) --- server/app.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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})