56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import Any
|
|
|
|
logger = logging.getLogger("cs_agent")
|
|
|
|
|
|
async def handle_image_workflow(*, workflow_router: Any, message: str, data: dict, image_urls: list) -> bool:
|
|
"""处理图片工作流(根据客户说的话判断执行哪种工作流)。"""
|
|
if not image_urls:
|
|
return False
|
|
|
|
workflow_type, confidence = workflow_router.detect_workflow(message)
|
|
|
|
customer_id = data.get("from_id")
|
|
acc_id = data.get("acc_id", "")
|
|
acc_type = data.get("acc_type", "AliWorkbench")
|
|
image_url = image_urls[0]
|
|
|
|
logger.info("[Agent] 检测到工作流类型:%s (置信度:%s)", workflow_type, confidence)
|
|
|
|
if workflow_type == "find_image":
|
|
logger.info("[Agent] 执行查找图片工作流 | 客户:%s", customer_id)
|
|
from core.workflow import workflow
|
|
|
|
return await workflow.find_image_workflow(
|
|
customer_id=customer_id,
|
|
image_url=image_url,
|
|
acc_id=acc_id,
|
|
acc_type=acc_type,
|
|
)
|
|
if workflow_type == "process_image":
|
|
logger.info("[Agent] 执行处理图片工作流 | 客户:%s", customer_id)
|
|
from core.workflow import workflow
|
|
|
|
return await workflow.process_image_workflow(
|
|
customer_id=customer_id,
|
|
image_url=image_url,
|
|
acc_id=acc_id,
|
|
acc_type=acc_type,
|
|
)
|
|
if workflow_type == "transfer_human":
|
|
logger.info("[Agent] 执行转人工派单工作流 | 客户:%s", customer_id)
|
|
from core.workflow import workflow
|
|
|
|
return await workflow.transfer_to_designer_workflow(
|
|
customer_id=customer_id,
|
|
image_url=image_url,
|
|
acc_id=acc_id,
|
|
acc_type=acc_type,
|
|
reason="客户主动要求转人工",
|
|
)
|
|
|
|
return False
|