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"