From 5a7012f1faa6b505e368ea74051f6f52fc529cb0 Mon Sep 17 00:00:00 2001 From: OoO Date: Sun, 3 May 2026 00:15:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(ppt):=20AI=20parser=20drops=20empty-body=20?= =?UTF-8?q?sections=20+=20cap=20raised=206=E2=86=9210?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 實戰問題:升級 monthly AI prompt 後,AI 輸出多了【行銷與銷售行動建議 — SMART 框架】這個「主段」加 3 個 ■ 子段(本週/本月/下月)。原 parser: 1. ■ 子段被當成新 section(這是正確行為) 2. 但「行銷與銷售行動建議」主段自己 body 變空殼 3. 顯示成「(本段無內容)」醜陋占位 4. 加上 sections[:6] 切斷,後面的競爭定位/風險預警被丟掉 修補(services/ppt_generator.py:_parse_ai_sections): - 過濾空 body section(len(body) < 5 視為空殼) - 上限放寬 6 → 10(容納升級 prompt 後的 9 段:整體/市場/品類/熱銷/ MCP/本週/本月/下月/風險) 驗證:模擬 9 段輸入 → 過濾後得 6 個非空段,正確包含本週/本月/下月。 bump monthly v3.1.2 → v3.1.3 Co-Authored-By: Claude Opus 4.7 (1M context) --- services/ppt_generator.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/ppt_generator.py b/services/ppt_generator.py index ec41f58..ffa166d 100644 --- a/services/ppt_generator.py +++ b/services/ppt_generator.py @@ -43,7 +43,7 @@ REPORTS_DIR.mkdir(parents=True, exist_ok=True) TEMPLATE_VERSIONS = { 'daily': 'v3.0.2', # 2026-05-02 折線稀疏資料防呆:N<=2 時 inset legend、加「資料不足」提示 'weekly': 'v3.0.2', # 2026-05-02 同上 - 'monthly': 'v3.1.2', # 2026-05-02 同上(雖月報通常 30 點不會踩到,仍 bump 統一) + 'monthly': 'v3.1.3', # 2026-05-03 AI 段落 parser:丟棄空 body 段、上限 6→10 容納 SMART 框架 9 段 'strategy': 'v3.0', # 2026-05-02 AI 頁去黑改暖紙 + 附錄頁 'competitor': 'v3.0', # 2026-05-02 AI 頁去黑改暖紙 + 附錄頁 'promo': 'v3.0', # 2026-05-02 AI 頁去黑改暖紙 + 附錄頁 @@ -2173,7 +2173,13 @@ def _parse_ai_sections(ai_text: str) -> list: if not sections and ai_text.strip(): sections.append(("💡", "AI 月度策略洞察", ai_text.strip())) - return sections[:6] + # 過濾「空 body」段(如 SMART 框架主標題下接續是 ■ 子段,主標題自己沒內容) + # 這些「空殼」section 占版面但無資訊,丟掉避免顯示「(本段無內容)」 + sections = [(i, t, b) for (i, t, b) in sections if b and len(b.strip()) >= 5] + + # 上限放寬 6 → 10(升級 prompt 後最多 9 段:整體/市場/品類/熱銷/MCP/ + # 本週/本月/下月/風險),仍會自動分頁(每頁 4 卡,最多 3 頁) + return sections[:10] def _ai_insight_slide(prs, ai_text: str, W: float = 33.87):