feat: 增强 Agent 系统和完善项目结构
主要改进: - Agent 增强: 订单查询、售后支持、客服路由等功能优化 - 新增语言检测和 Token 管理模块 - 改进 Chatwoot webhook 处理和用户标识 - MCP 服务器增强: 订单 MCP 和 Strapi MCP 功能扩展 - 新增商城客户端、知识库、缓存和同步模块 - 添加多语言提示词系统 (YAML) - 完善项目结构: 整理文档、脚本和测试文件 - 新增调试和测试工具脚本 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
63
tests/test_return_faq.py
Normal file
63
tests/test_return_faq.py
Normal file
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
测试退货相关 FAQ 回答
|
||||
"""
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
|
||||
# 添加 agent 目录到路径
|
||||
sys.path.insert(0, '/app')
|
||||
|
||||
from agents.customer_service import customer_service_agent
|
||||
from core.state import AgentState
|
||||
|
||||
|
||||
async def test_return_faq():
|
||||
"""测试退货相关 FAQ"""
|
||||
|
||||
# 测试问题列表
|
||||
test_questions = [
|
||||
"I received a defective item, what should I do?",
|
||||
"How do I return a product?",
|
||||
"What is your return policy?",
|
||||
"I want to get a refund for my order",
|
||||
]
|
||||
|
||||
for question in test_questions:
|
||||
print(f"\n{'='*60}")
|
||||
print(f"📝 问题: {question}")
|
||||
print(f"{'='*60}")
|
||||
|
||||
# 初始化状态
|
||||
state = AgentState(
|
||||
conversation_id="test_return_001",
|
||||
user_id="test_user",
|
||||
account_id="2",
|
||||
message=question,
|
||||
history=[],
|
||||
context={}
|
||||
)
|
||||
|
||||
try:
|
||||
# 调用客服 Agent
|
||||
final_state = await customer_service_agent(state)
|
||||
|
||||
# 获取响应
|
||||
response = final_state.get("response", "无响应")
|
||||
tool_calls = final_state.get("tool_calls", [])
|
||||
intent = final_state.get("intent")
|
||||
|
||||
print(f"\n🎯 意图识别: {intent}")
|
||||
print(f"\n🤖 AI 回答:")
|
||||
print(response)
|
||||
print(f"\n📊 调用的工具: {tool_calls}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"\n❌ 错误: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🧪 测试退货相关 FAQ 回答\n")
|
||||
asyncio.run(test_return_faq())
|
||||
Reference in New Issue
Block a user