fix: 改进错误处理和清理测试代码
## 主要修复 ### 1. JSON 解析错误处理 - 修复所有 Agent 的 LLM 响应解析失败时返回原始内容的问题 - 当 JSON 解析失败时,返回友好的兜底消息而不是原始文本 - 影响文件: customer_service.py, order.py, product.py, aftersale.py ### 2. FAQ 快速路径修复 - 修复 customer_service.py 中变量定义顺序问题 - has_faq_query 在使用前未定义导致 NameError - 添加详细的错误日志记录 ### 3. Chatwoot 集成改进 - 添加响应内容调试日志 - 改进错误处理和日志记录 ### 4. 订单查询优化 - 将订单列表默认返回数量从 10 条改为 5 条 - 统一 MCP 工具层和 Mall Client 层的默认值 ### 5. 代码清理 - 删除所有测试代码和示例文件 - 刋试文件包括: test_*.py, test_*.html, test_*.sh - 删除测试目录: tests/, agent/tests/, agent/examples/ Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -494,7 +494,7 @@ async def get_mall_order_list(
|
||||
date_added: Optional[str] = None,
|
||||
date_end: Optional[str] = None,
|
||||
no: Optional[str] = None,
|
||||
status: Optional[int] = None,
|
||||
status: int = 10000,
|
||||
is_drop_shopping: int = 0
|
||||
) -> dict:
|
||||
"""Query order list from Mall API with filters
|
||||
@@ -517,7 +517,7 @@ async def get_mall_order_list(
|
||||
date_added: 开始日期,格式 YYYY-MM-DD (default: None)
|
||||
date_end: 结束日期,格式 YYYY-MM-DD (default: None)
|
||||
no: 订单号筛选 (default: None)
|
||||
status: 订单状态筛选 (default: None, None表示全部状态)
|
||||
status: 订单状态筛选 (default: 10000, 10000表示全部状态)
|
||||
is_drop_shopping: 是否代发货 (default: 0)
|
||||
|
||||
Returns:
|
||||
@@ -673,9 +673,14 @@ if __name__ == "__main__":
|
||||
|
||||
tool_obj = _tools[tool_name]
|
||||
|
||||
# Call the tool with arguments
|
||||
# Filter arguments to only include parameters expected by the tool
|
||||
# Get parameter names from tool's parameters schema
|
||||
tool_params = tool_obj.parameters.get('properties', {})
|
||||
filtered_args = {k: v for k, v in arguments.items() if k in tool_params}
|
||||
|
||||
# Call the tool with filtered arguments
|
||||
# FastMCP FunctionTool.run() takes a dict of arguments
|
||||
tool_result = await tool_obj.run(arguments)
|
||||
tool_result = await tool_obj.run(filtered_args)
|
||||
|
||||
# Extract content from ToolResult
|
||||
# ToolResult.content is a list of TextContent objects with a 'text' attribute
|
||||
|
||||
Reference in New Issue
Block a user