Spaces:
Runtime error

Macbath commited on
Commit
650cb4f
·
1 Parent(s): 85eba4e

Fix: 修复 RecommendationAgent JSON解析失败问题

Browse files

- 添加 import re
- 新增 _parse_json_with_fallback() 方法(4级降级策略)
- 新增 _repair_json() 方法(修复常见JSON错误)
- 新增 _balance_brackets() 方法(自动补全括号)
- 更新 _parse_response() 使用强大的JSON解析
- 增强错误处理和日志记录

修复内容:
1. 处理 'Unterminated string' 错误
2. 处理 'Unexpected end of input' 错误
3. 使用 json5 作为首选解析器(更宽容)
4. 解析失败时返回详细错误信息便于调试

1 file changed +141 -3
agents/recommendation_agent.py+141-3