newtw2
This commit is contained in:
@@ -7,43 +7,18 @@ logger = logging.getLogger("cs_agent")
|
||||
|
||||
class BusinessEngine:
|
||||
"""
|
||||
业务逻辑中枢:
|
||||
1. 接收 StandardMessage。
|
||||
2. 决定由哪个 AI 工具或流程处理。
|
||||
3. 返回 StandardResponse。
|
||||
4. 对外广播异步事件。
|
||||
业务逻辑中枢(备用引擎,主流程由 Orchestrator + Brain 处理)。
|
||||
仅在 Orchestrator 不可用时作为降级方案。
|
||||
"""
|
||||
def __init__(self, agent_instance: Any = None):
|
||||
"""
|
||||
:param agent_instance: 核心 AI Agent 的实例(比如重构后的 CustomerServiceAgent)
|
||||
"""
|
||||
self.agent = agent_instance
|
||||
|
||||
async def handle_message(self, msg: StandardMessage) -> StandardResponse:
|
||||
"""
|
||||
大脑的思考主入口
|
||||
"""
|
||||
logger.info(f"[Engine] 收到来自 {msg.platform} 的消息: {msg.user_id} -> {msg.content[:50]}")
|
||||
|
||||
# TODO: 这里将接入重构后的 Single Agent + Tool Calling
|
||||
# 目前模拟一个简单的规则响应,展示 StandardResponse 的用法
|
||||
|
||||
if "报价" in msg.content or msg.image_urls:
|
||||
return StandardResponse(
|
||||
reply_content="正在为你查看图片,请稍等...",
|
||||
metadata={"acc_id": msg.acc_id, "acc_type": msg.acc_type}
|
||||
)
|
||||
|
||||
if "转人工" in msg.content:
|
||||
return StandardResponse(
|
||||
reply_content="正在为你转接设计师...",
|
||||
need_transfer=True,
|
||||
metadata={"acc_id": msg.acc_id, "acc_type": msg.acc_type}
|
||||
)
|
||||
content = (msg.content or "")
|
||||
logger.info(f"[Engine] 收到来自 {msg.platform} 的消息: {msg.user_id} -> {content[:50]}")
|
||||
|
||||
# 兜底回复
|
||||
return StandardResponse(
|
||||
reply_content="你好,我是AI助手,有什么可以帮你的?",
|
||||
reply_content="稍等哈,设计师马上来。",
|
||||
metadata={"acc_id": msg.acc_id, "acc_type": msg.acc_type}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user