Files
assistant/tests/test_return_faq.py

64 lines
1.6 KiB
Python
Raw Normal View History

"""
测试退货相关 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())