refactor: unify core pipeline logging with cs_agent logger
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from utils.metrics_tracker import emit as metrics_emit
|
||||
from core.post_ops import auto_tag, detect_discount, detect_price, record_deal_fail
|
||||
|
||||
logger = logging.getLogger("cs_agent")
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.pydantic_ai_agent import AgentResponse, ConversationState, CustomerMessage, CustomerServiceAgent
|
||||
|
||||
@@ -25,7 +28,7 @@ async def finalize_ai_reply(
|
||||
|
||||
blocked, fallback = should_block_reply(reply_text)
|
||||
if blocked:
|
||||
print("[Agent] 敏感词拦截,使用兜底回复")
|
||||
logger.warning("[Agent] 敏感词拦截,使用兜底回复")
|
||||
reply_text = fallback or "好的,您稍等,我帮您确认一下"
|
||||
except Exception:
|
||||
pass
|
||||
@@ -88,9 +91,9 @@ async def finalize_ai_reply(
|
||||
|
||||
if should_reply:
|
||||
state.last_reply_at = datetime.now()
|
||||
print(f"{agent.C_REPLY}[REPLY->CUSTOMER]{agent.C_RESET} {reply_text}")
|
||||
logger.info("[REPLY->CUSTOMER] %s", reply_text)
|
||||
else:
|
||||
print(f"{agent.C_MUTED}[REPLY->CUSTOMER]{agent.C_RESET} <静默/不发送>")
|
||||
logger.info("[REPLY->CUSTOMER] <静默/不发送>")
|
||||
|
||||
agent._activity_log(
|
||||
"agent_outbound_decision",
|
||||
|
||||
Reference in New Issue
Block a user