fix(debate): slug 생성 강화 — 영문 2-3단어, 30자 제한, 따옴표/특수문자 strip
This commit is contained in:
@@ -85,21 +85,24 @@ class DebateHandler:
|
|||||||
from core.gemini_caller import GeminiCaller
|
from core.gemini_caller import GeminiCaller
|
||||||
caller = GeminiCaller()
|
caller = GeminiCaller()
|
||||||
short_title = await caller.call_simple(
|
short_title = await caller.call_simple(
|
||||||
f"다음 토론 주제를 3~5단어의 짧고 명확한 제목으로 요약해주세요. 마크다운 기호 없이 텍스트만 출력하세요.\n\n주제: {topic}",
|
f"다음 주제를 2~3단어 영문 키워드로 요약. 따옴표/기호 없이 텍스트만.\n\n주제: {topic}",
|
||||||
timeout=30
|
timeout=30
|
||||||
)
|
)
|
||||||
short_title = short_title.strip()
|
short_title = short_title.strip().strip('"\'""''「」')
|
||||||
if len(short_title) > 50:
|
# 특수문자 제거
|
||||||
short_title = short_title[:50]
|
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
|
from tools.wiki_client import WikiClient
|
||||||
slug = WikiClient.slugify(short_title)
|
slug = WikiClient.slugify(short_title)
|
||||||
if len(slug) > 80:
|
if len(slug) > 30:
|
||||||
slug = slug[:80].rstrip("-")
|
slug = slug[:30].rstrip("-")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"짧은 제목 생성 실패: {e}")
|
logger.warning(f"짧은 제목 생성 실패: {e}")
|
||||||
short_title = topic[:20]
|
short_title = topic[:20]
|
||||||
slug = short_title.replace(" ", "-").lower()
|
slug = re.sub(r'[^\w-]', '-', short_title).lower()[:30].rstrip("-")
|
||||||
|
|
||||||
self.session = DebateSession(
|
self.session = DebateSession(
|
||||||
topic=topic, topic_slug=slug, wiki_title=short_title,
|
topic=topic, topic_slug=slug, wiki_title=short_title,
|
||||||
|
|||||||
Reference in New Issue
Block a user