sales-assistant-py-new/app/chat_qa/nodes/route_by_quality_node.py

18 lines
527 B
Python
Raw Permalink 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.

from app.chat_qa.qa_state import QAState
# ==================== 条件路由 ====================
def route_by_quality(state: QAState) -> str:
"""根据质检结果和重试次数决定路由"""
is_valid = state.get("is_valid", False)
retry = state["retry_count"]
qas = state.get("current_qas", [])
# 质检通过有有效QA且评分足够
if is_valid :
return "pass"
# 质检不通过但还有重试机会最多3次
if retry < 3:
return "retry"
return "fail"