fix(discord_bot): unified prompt JSON '{' parsing fallback
This commit is contained in:
@@ -183,6 +183,18 @@ def _parse_unified_response(raw: str) -> dict:
|
||||
except json.JSONDecodeError:
|
||||
break
|
||||
|
||||
# 2.5) JSON 시작 중괄호 누락 복구
|
||||
raw_s = raw.strip()
|
||||
if raw_s.startswith('"mode"'):
|
||||
if not raw_s.startswith("{"):
|
||||
raw_s = "{" + raw_s
|
||||
if not raw_s.endswith("}"):
|
||||
raw_s = raw_s + "}"
|
||||
try:
|
||||
return json.loads(raw_s, strict=False)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
# 3) 파싱 실패 → chat 모드 폴백
|
||||
logger.warning(f"unified 응답 JSON 파싱 실패: {raw[:200]}")
|
||||
return {"mode": "chat", "response": raw}
|
||||
|
||||
Reference in New Issue
Block a user