diff --git a/handlers/debate_handler.py b/handlers/debate_handler.py index 89e1330..18cf842 100644 --- a/handlers/debate_handler.py +++ b/handlers/debate_handler.py @@ -85,21 +85,24 @@ class DebateHandler: from core.gemini_caller import GeminiCaller caller = GeminiCaller() short_title = await caller.call_simple( - f"다음 토론 주제를 3~5단어의 짧고 명확한 제목으로 요약해주세요. 마크다운 기호 없이 텍스트만 출력하세요.\n\n주제: {topic}", + f"다음 주제를 2~3단어 영문 키워드로 요약. 따옴표/기호 없이 텍스트만.\n\n주제: {topic}", timeout=30 ) - short_title = short_title.strip() - if len(short_title) > 50: - short_title = short_title[:50] + short_title = short_title.strip().strip('"\'""''「」') + # 특수문자 제거 + import re + short_title = re.sub(r'[^\w\s-]', '', short_title).strip() + if len(short_title) > 30: + short_title = short_title[:30].strip() from tools.wiki_client import WikiClient slug = WikiClient.slugify(short_title) - if len(slug) > 80: - slug = slug[:80].rstrip("-") + if len(slug) > 30: + slug = slug[:30].rstrip("-") except Exception as e: logger.warning(f"짧은 제목 생성 실패: {e}") short_title = topic[:20] - slug = short_title.replace(" ", "-").lower() + slug = re.sub(r'[^\w-]', '-', short_title).lower()[:30].rstrip("-") self.session = DebateSession( topic=topic, topic_slug=slug, wiki_title=short_title,