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:
55
agent/test_endpoint.py
Normal file
55
agent/test_endpoint.py
Normal file
@@ -0,0 +1,55 @@
|
||||
"""
|
||||
测试端点 - 用于测试退货 FAQ
|
||||
"""
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from core.graph import process_message
|
||||
|
||||
router = APIRouter(prefix="/test", tags=["test"])
|
||||
|
||||
|
||||
class TestRequest(BaseModel):
|
||||
"""测试请求"""
|
||||
conversation_id: str
|
||||
user_id: str
|
||||
account_id: str
|
||||
message: str
|
||||
history: list = []
|
||||
context: dict = {}
|
||||
|
||||
|
||||
@router.post("/faq")
|
||||
async def test_faq(request: TestRequest):
|
||||
"""测试 FAQ 回答
|
||||
|
||||
简化的测试端点,用于测试退货相关 FAQ
|
||||
"""
|
||||
try:
|
||||
# 调用处理流程
|
||||
result = await process_message(
|
||||
conversation_id=request.conversation_id,
|
||||
user_id=request.user_id,
|
||||
account_id=request.account_id,
|
||||
message=request.message,
|
||||
history=request.history,
|
||||
context=request.context
|
||||
)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"response": result.get("response"),
|
||||
"intent": result.get("intent"),
|
||||
"tool_calls": result.get("tool_calls", []),
|
||||
"step_count": result.get("step_count", 0)
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
return {
|
||||
"success": False,
|
||||
"error": str(e),
|
||||
"response": None
|
||||
}
|
||||
Reference in New Issue
Block a user