Improve retry layout density for run-001

This commit is contained in:
2026-04-02 11:17:58 +09:00
parent 89be34f423
commit df2304f7ab
18 changed files with 226 additions and 180 deletions

View File

@@ -211,77 +211,116 @@ def _stage_1_5b(ctx: PipelineContext) -> PipelineContext:
return ctx
def _topic(ctx: PipelineContext, topic_id: int) -> Topic | None:
return next((t for t in ctx.topics if t.id == topic_id), None)
def _build_stage2_retry_html(ctx: PipelineContext, retry_plan: dict) -> dict:
title = ctx.analysis.title
core_message = ctx.analysis.core_message
relation_topic = next((t for t in ctx.topics if t.id == 3), None)
comparison_topic = next((t for t in ctx.topics if t.id == 5), None)
conclusion_topic = next((t for t in ctx.topics if t.id == 6), None)
evidence_topic = next((t for t in ctx.topics if t.id == 4), None)
problem_topic = _topic(ctx, 1)
evidence_topic = _topic(ctx, 4)
relation_topic = _topic(ctx, 3)
comparison_topic = _topic(ctx, 5)
conclusion_topic = _topic(ctx, 6)
dx_topic = _topic(ctx, 2)
relation_summary = relation_topic.summary if relation_topic and relation_topic.summary else 'DX와 GIS, BIM, Digital Twin의 관계를 시각적으로 드러낸다.'
comparison_summary = comparison_topic.summary if comparison_topic and comparison_topic.summary else '범위·프로세스·성과품·확장성의 4개 비교축으로 DX와 BIM 차이를 짧고 직접적으로 보여준다.'
conclusion_summary = conclusion_topic.summary if conclusion_topic and conclusion_topic.summary else '결론: BIM은 건설산업 DX를 수행하는 과정의 가장 기초가 되는 일부분이다.'
evidence_summary = evidence_topic.summary if evidence_topic and evidence_topic.summary else '정책 문서에서도 DX와 BIM이 혼용되며, 이를 구조적으로 바로잡을 필요가 있다.'
problem_text = problem_topic.summary if problem_topic and problem_topic.summary else 'DX와 BIM이 혼용되며 BIM 도입을 DX 완성으로 오인하는 문제가 발생한다.'
relation_text = relation_topic.summary if relation_topic and relation_topic.summary else 'DX와 GIS, BIM, Digital Twin의 관계를 시각적으로 드러낸다.'
evidence_text = evidence_topic.summary if evidence_topic and evidence_topic.summary else '정책 문서에서도 DX와 BIM이 혼용되며 이를 바로잡을 필요가 있다.'
dx_text = dx_topic.summary if dx_topic and dx_topic.summary else 'DX는 상위 개념이고 BIM은 핵심 기술이다.'
compare_text = comparison_topic.summary if comparison_topic and comparison_topic.summary else '범위·프로세스·성과품·확장성의 4개 비교축으로 DX와 BIM 차이를 짧고 직접적으로 보여준다.'
conclusion_text = conclusion_topic.summary if conclusion_topic and conclusion_topic.summary else '결론: BIM은 건설산업 DX를 수행하는 과정의 가장 기초가 되는 일부분이다.'
body_html = f"""
<div style="width:100%; height:100%; box-sizing:border-box; font-family:'Segoe UI',sans-serif; color:#0f172a; display:flex; flex-direction:column; gap:14px;">
<div style="background:linear-gradient(135deg,#0f172a 0%,#1d4ed8 100%); color:#ffffff; border-radius:16px; padding:20px 22px; box-sizing:border-box;">
<div style="font-size:11px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; color:#93c5fd; margin-bottom:8px;">Core Message</div>
<div style="font-size:24px; font-weight:800; line-height:1.18; margin-bottom:10px;">DX는 상위 개념, BIM은 핵심 기술</div>
<div style="font-size:12px; line-height:1.6; color:rgba(255,255,255,0.92);">{core_message}</div>
<div style="width:100%; height:100%; box-sizing:border-box; font-family:'Segoe UI',sans-serif; color:#0f172a; display:flex; flex-direction:column; gap:10px;">
<div style="width:100%; background:linear-gradient(135deg,#fef2f2 0%,#fee2e2 100%); border:2px solid #fca5a5; border-radius:10px; padding:12px 16px; box-sizing:border-box;">
<div style="display:flex; gap:10px; align-items:flex-start;">
<div style="font-size:20px; line-height:1;">⚠️</div>
<div>
<div style="font-size:14px; font-weight:800; color:#991b1b; margin-bottom:4px;">개념 혼용의 현실</div>
<div style="font-size:11px; line-height:1.55; color:#7f1d1d;">{problem_text}</div>
</div>
</div>
</div>
<div class="relation-diagram-card" style="background:#f8fafc; border:1px solid #cbd5e1; border-radius:16px; padding:16px 18px; box-sizing:border-box;">
<div style="display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:12px;">
<div class="relation-diagram-card" style="background:#ffffff; border:1px solid #cbd5e1; border-radius:14px; padding:14px 16px; box-sizing:border-box; flex:1;">
<div style="display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:10px;">
<div>
<div style="font-size:11px; font-weight:700; color:#2563eb; letter-spacing:0.08em; text-transform:uppercase; margin-bottom:5px;">Relation Map</div>
<div style="font-size:18px; font-weight:800; color:#0f172a; line-height:1.25;">{title}</div>
<div style="font-size:12px; font-weight:800; color:#1e40af; margin-bottom:4px;">{title}</div>
<div style="font-size:11px; line-height:1.55; color:#334155;">{dx_text}</div>
</div>
<div style="font-size:10px; color:#166534; background:#dcfce7; border:1px solid #86efac; border-radius:999px; padding:5px 9px; white-space:nowrap;">[그림 1] DX와 핵심기술간 상호관계</div>
<div style="font-size:10px; color:#166534; background:#dcfce7; border:1px solid #86efac; border-radius:999px; padding:4px 8px; white-space:nowrap;">[그림 1] DX와 핵심기술간 상호관계</div>
</div>
<div style="font-size:11px; line-height:1.6; color:#334155; margin-bottom:12px;">{relation_summary}</div>
<div style="display:flex; align-items:center; justify-content:center; gap:10px;">
<div style="min-width:120px; text-align:center; background:#1d4ed8; color:#ffffff; border-radius:999px; padding:10px 16px; font-size:15px; font-weight:800;">DX</div>
<div style="font-size:16px; color:#94a3b8;">→</div>
<div style="display:flex; gap:8px; flex-wrap:wrap; justify-content:center;">
<div style="background:#ffffff; border:1px solid #cbd5e1; border-radius:12px; padding:10px 12px; font-size:11px; font-weight:700;">GIS</div>
<div style="background:#dbeafe; border:2px solid #3b82f6; border-radius:12px; padding:10px 12px; font-size:11px; font-weight:800; color:#1d4ed8;">BIM</div>
<div style="background:#ffffff; border:1px solid #cbd5e1; border-radius:12px; padding:10px 12px; font-size:11px; font-weight:700;">Digital Twin</div>
<div style="display:flex; align-items:flex-start; gap:16px; margin-bottom:10px;">
<div style="width:220px; flex-shrink:0; background:#f8fafc; border:1px solid #dbeafe; border-radius:14px; padding:12px; box-sizing:border-box;">
<div style="display:flex; align-items:center; justify-content:center; gap:8px; margin-bottom:8px;">
<div style="min-width:72px; text-align:center; background:#1d4ed8; color:#ffffff; border-radius:999px; padding:8px 12px; font-size:14px; font-weight:800;">DX</div>
<div style="font-size:14px; color:#94a3b8;"></div>
</div>
<div style="display:grid; grid-template-columns:1fr 1fr; gap:8px;">
<div style="background:#ffffff; border:1px solid #cbd5e1; border-radius:10px; padding:10px; text-align:center; font-size:11px; font-weight:700;">GIS</div>
<div style="background:#dbeafe; border:2px solid #3b82f6; border-radius:10px; padding:10px; text-align:center; font-size:11px; font-weight:800; color:#1d4ed8;">BIM</div>
<div style="grid-column:1 / span 2; background:#ffffff; border:1px solid #cbd5e1; border-radius:10px; padding:10px; text-align:center; font-size:11px; font-weight:700;">Digital Twin</div>
</div>
</div>
<div style="flex:1; font-size:11px; line-height:1.6; color:#334155;">
<div style="margin-bottom:6px;">• {relation_text}</div>
<div style="margin-bottom:6px;">• GIS는 공간 분석과 위치 기반 정보를 제공한다.</div>
<div>• BIM은 형상정보와 내용정보를 함께 다루는 핵심 인프라 기술이다.</div>
</div>
</div>
<div class="comparison-summary-card" style="background:#eff6ff; border:1px solid #bfdbfe; border-radius:12px; padding:10px 12px; box-sizing:border-box;">
<div style="font-size:11px; font-weight:800; color:#1d4ed8; margin-bottom:8px;">DX와 BIM 핵심 비교</div>
<div style="display:grid; grid-template-columns:1fr 1fr; gap:8px; font-size:10px; line-height:1.45; color:#334155;">
<div><span style="font-weight:800; color:#0f172a;">범위</span><br>DX는 BIM을 포함하는 상위 개념</div>
<div><span style="font-weight:800; color:#0f172a;">프로세스</span><br>DX는 근본적 개선, BIM은 기존 2D 연장</div>
<div><span style="font-weight:800; color:#0f172a;">성과품</span><br>DX는 공학 정보 연계, BIM은 3D 모델 중심</div>
<div><span style="font-weight:800; color:#0f172a;">확장성</span><br>DX는 전 생애주기, BIM은 분야별 단절 위험</div>
</div>
<div style="margin-top:8px; font-size:10px; color:#475569; line-height:1.5;">{compare_text}</div>
</div>
</div>
</div>
""".strip()
sidebar_html = f"""
<div style="width:100%; height:100%; box-sizing:border-box; font-family:'Segoe UI',sans-serif; display:flex; flex-direction:column; gap:12px;">
<div class="comparison-summary-card" style="background:#ffffff; border:1px solid #cbd5e1; border-radius:14px; overflow:hidden;">
<div style="padding:12px 14px; background:linear-gradient(135deg,#eff6ff 0%,#dbeafe 100%); border-bottom:1px solid #bfdbfe;">
<div style="font-size:11px; font-weight:700; color:#1d4ed8; letter-spacing:0.08em; text-transform:uppercase; margin-bottom:4px;">Comparison</div>
<div style="font-size:16px; font-weight:800; color:#0f172a;">DX와 BIM 핵심 비교</div>
<div style="width:100%; height:100%; box-sizing:border-box; font-family:'Segoe UI',sans-serif; display:flex; flex-direction:column; gap:8px;">
<div style="display:flex; gap:12px; align-items:flex-start; padding:12px 14px; background:#f8fafc; border-radius:10px; border:1px solid #e2e8f0;">
<div style="width:28px; height:28px; border-radius:50%; background:#2563eb; display:flex; align-items:center; justify-content:center; color:#ffffff; font-size:12px; font-weight:800; flex-shrink:0;">1</div>
<div>
<div style="font-size:12px; font-weight:800; color:#1e293b; margin-bottom:3px;">건설산업</div>
<div style="font-size:10px; line-height:1.45; color:#475569;">다양한 기술을 통합해 시설물을 구현하는 종합 산업</div>
</div>
<div style="padding:10px 14px 12px; display:grid; grid-template-columns:80px 1fr; row-gap:8px; column-gap:10px; font-size:10px; line-height:1.45; color:#334155;">
<div style="font-weight:800; color:#0f172a;">범위</div><div>DX는 BIM을 포함하는 상위 개념, BIM은 3D 중심 기술</div>
<div style="font-weight:800; color:#0f172a;">프로세스</div><div>DX는 근본적 개선, BIM은 기존 2D 설계 방식 연장</div>
<div style="font-weight:800; color:#0f172a;">성과품</div><div>DX는 공학 정보 및 콘텐츠 연계, BIM은 3D 모델 중심</div>
<div style="font-weight:800; color:#0f172a;">확장성</div><div>DX는 전 생애주기 활용 시스템, BIM은 분야별 단절 위험</div>
</div>
<div style="padding:0 14px 12px; font-size:10px; color:#475569; line-height:1.5;">{comparison_summary}</div>
</div>
<div style="background:#f8fafc; border:1px solid #cbd5e1; border-radius:14px; padding:14px; box-sizing:border-box;">
<div style="font-size:11px; font-weight:700; color:#475569; letter-spacing:0.08em; text-transform:uppercase; margin-bottom:6px;">Evidence</div>
<div style="font-size:14px; font-weight:800; color:#0f172a; margin-bottom:8px;">정책 문서에서도 혼용</div>
<div style="font-size:10px; line-height:1.55; color:#475569;">{evidence_summary}</div>
<div style="display:flex; gap:12px; align-items:flex-start; padding:12px 14px; background:#f8fafc; border-radius:10px; border:1px solid #e2e8f0;">
<div style="width:28px; height:28px; border-radius:50%; background:#2563eb; display:flex; align-items:center; justify-content:center; color:#ffffff; font-size:12px; font-weight:800; flex-shrink:0;">2</div>
<div>
<div style="font-size:12px; font-weight:800; color:#1e293b; margin-bottom:3px;">BIM</div>
<div style="font-size:10px; line-height:1.45; color:#475569;">3차원 모델 기반의 정보관리 도구이자 협업 인프라</div>
<div style="font-size:9px; color:#64748b; margin-top:4px;">출처: 국토교통부 BIM 기본지침</div>
</div>
</div>
<div style="display:flex; gap:12px; align-items:flex-start; padding:12px 14px; background:#f8fafc; border-radius:10px; border:1px solid #e2e8f0;">
<div style="width:28px; height:28px; border-radius:50%; background:#2563eb; display:flex; align-items:center; justify-content:center; color:#ffffff; font-size:12px; font-weight:800; flex-shrink:0;">3</div>
<div>
<div style="font-size:12px; font-weight:800; color:#1e293b; margin-bottom:3px;">DX</div>
<div style="font-size:10px; line-height:1.45; color:#475569;">디지털 기술 기반으로 업무방식과 가치구조를 전환하는 상위 개념</div>
</div>
</div>
<div style="background:#fff7ed; border:1px solid #fdba74; border-radius:10px; padding:12px 14px; box-sizing:border-box; margin-top:2px;">
<div style="font-size:11px; font-weight:800; color:#c2410c; margin-bottom:5px;">정책 혼용 사례</div>
<div style="font-size:10px; line-height:1.5; color:#7c2d12;">{evidence_text}</div>
</div>
</div>
""".strip()
footer_html = f"""
<div style="background:linear-gradient(90deg,#0f766e 0%,#0ea5a3 100%); border-radius:12px; padding:14px 24px; text-align:center; color:#ffffff; width:100%; height:60px; display:flex; flex-direction:column; justify-content:center; box-sizing:border-box;">
<div style="font-size:13px; font-weight:800; line-height:1.35;">{conclusion_summary}</div>
<div style="background:linear-gradient(135deg, #006aff 0%, #00aaff 100%); border-radius:10px; padding:14px 24px; text-align:center; color:#ffffff; width:100%; height:60px; display:flex; align-items:center; justify-content:center; box-sizing:border-box;">
<div style="font-size:13px; font-weight:800; line-height:1.35;">{conclusion_text}</div>
</div>
""".strip()
@@ -289,7 +328,7 @@ def _build_stage2_retry_html(ctx: PipelineContext, retry_plan: dict) -> dict:
'body_html': body_html,
'sidebar_html': sidebar_html,
'footer_html': footer_html,
'reasoning': f"stage_2 retry regeneration from rollback plan: {retry_plan.get('rollback_stage', 'stage_2')}",
'reasoning': f"stage_2 retry regeneration from rollback plan: {retry_plan.get('rollback_stage', 'stage_2')} with richer slide composition",
}