fix(discord_bot): unified prompt JSON '{' parsing fallback

This commit is contained in:
2026-03-23 20:43:41 +09:00
parent e5a52f68ab
commit c59c934ff5
5 changed files with 25 additions and 17 deletions

View File

@@ -8,25 +8,11 @@ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="repla
sys.path.insert(0, ".")
from core.gemini_caller import GeminiCaller
from api.discord_bot import _parse_unified_response
def extract_mode(raw):
start = raw.find("{")
if start == -1:
return "NO_JSON"
depth = 0
for i in range(start, len(raw)):
if raw[i] == "{":
depth += 1
elif raw[i] == "}":
depth -= 1
if depth == 0:
try:
p = json.loads(raw[start : i + 1])
return p.get("mode", "?")
except json.JSONDecodeError:
return "PARSE_ERR"
return "NO_CLOSE"
parsed = _parse_unified_response(raw)
return parsed.get("mode", "?")
async def main():