Merge branch 'main' into fix-#548

This commit is contained in:
Wendong-Fan 2025-10-21 21:02:15 +08:00 committed by GitHub
commit 4e77e5e25c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,6 @@
import asyncio
import datetime
import json
from pathlib import Path
import platform
from typing import Literal
@ -829,11 +830,22 @@ Based on the user query, determine the type and provide appropriate response."""
content = resp.msgs[0].content
if not content:
return True
normalized = content.strip().lower()
if normalized in ["yes", "complex"]:
return True
return sse_json("wait_confirm", {"content": content, "question": prompt})
content_stripped = content.strip()
if content_stripped.startswith('{') and content_stripped.endswith('}'):
try:
parsed_json = json.loads(content_stripped)
result = QuestionAnalysisResult(**parsed_json)
except (json.JSONDecodeError, ValueError) as e:
logger.warning(f"Failed to parse JSON from content: {e}")
normalized = content.strip().lower()
if normalized in ["yes", "complex"]:
return True
return sse_json("wait_confirm", {"content": content, "question": prompt})
else:
normalized = content.strip().lower()
if normalized in ["yes", "complex"]:
return True
return sse_json("wait_confirm", {"content": content, "question": prompt})
if result.type == "simple" and result.answer:
return sse_json("wait_confirm", {"content": result.answer, "question": prompt})
else: