fix: 兼容 mimo-v2.5 返回 JSON 数组而非对象的格式

- intent_analyzer._parse_json: 解析结果为 list 时取第一个 dict 元素
- llm_utils.parse_json_from_response: 同样处理 list 返回值
- 修复日志错误: 'list' object has no attribute 'get'
This commit is contained in:
lacerate551
2026-06-21 23:20:57 +08:00
parent 8268071fdc
commit e761af6111
2 changed files with 17 additions and 2 deletions

View File

@@ -245,7 +245,13 @@ def parse_json_from_response(content: str) -> Optional[dict]:
json_str = json_match.group(1) if json_match else content
try:
return json.loads(json_str.strip())
parsed = json.loads(json_str.strip())
# mimo 等模型可能返回 JSON 数组而非对象,取第一个元素
if isinstance(parsed, list) and len(parsed) > 0 and isinstance(parsed[0], dict):
return parsed[0]
if isinstance(parsed, dict):
return parsed
return None
except (json.JSONDecodeError, TypeError, ValueError):
return None