Files
group_xinghuo_jinrong/app/utils/sanitize_postprocess.py
T
zhanghongyu_0626 4b8e11c9bd feat(threshold): Implement customer loss threshold configuration and notification system
- Added `ThresholdRepository` for managing customer loss threshold configurations and notifications.
- Introduced `threshold_service` to handle loss threshold alerts based on customer portfolio performance.
- Enhanced `customer_prompts` to include new intent for querying product net values.
- Updated `customer_service` to integrate new threshold alert functionality into existing workflows.
- Implemented `sanitize_postprocess` for improved compliance handling in customer interactions.
- Enhanced course documentation to reflect updates in advisor training modules and interactive elements.

This update significantly improves the customer experience by providing proactive loss threshold notifications and enhancing the overall service framework.
2026-09-10 10:57:40 +08:00

35 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""客服/游客编排层:违禁词扫描后的分治(1B 拍板)。
底层 compliance_guard.sanitize_reply 仍返回 need_transfer=True;
本模块在 customer/visitor 编排层决定是否真的转人工。
"""
from __future__ import annotations
from app.utils.compliance_guard import COMPLIANCE_REJECT, sanitize_reply
DATA_QUERY_INTENTS = frozenset({
"holding_query",
"transaction_query",
"risk_assessment_query",
"suitability_check",
"nav_query",
})
def finalize_sanitized_reply(
reply: str,
*,
intent: str | None = None,
fact_text: str | None = None,
data_query_intents: frozenset[str] | None = None,
) -> tuple[str, bool]:
"""数据查询 intent 命中违禁词 → 回退 fact_text;其余 → COMPLIANCE_REJECT;均不自动 transfer。"""
allowed = data_query_intents or DATA_QUERY_INTENTS
safe, hit = sanitize_reply(reply)
if not hit:
return safe, False
if intent in allowed and fact_text:
return fact_text, False
return COMPLIANCE_REJECT, False