Revert "fix(voice): stop repeating failed clarifications"
This reverts commit 294d30a797.
This commit is contained in:
@@ -907,37 +907,13 @@ def _voice_is_confused_caller_text(text: str | None) -> bool:
|
||||
return any(marker in normalized for marker in confusion_markers)
|
||||
|
||||
|
||||
def _voice_is_frustrated_caller_text(text: str | None) -> bool:
|
||||
normalized = _voice_text_key(text)
|
||||
if not normalized:
|
||||
return False
|
||||
frustration_markers = (
|
||||
"я же говор",
|
||||
"я уже говор",
|
||||
"уже сказал",
|
||||
"уже сказала",
|
||||
"сколько раз",
|
||||
"ты не слыш",
|
||||
"вы не слыш",
|
||||
"не слышишь",
|
||||
"не понимаешь",
|
||||
"работай",
|
||||
"давай работай",
|
||||
)
|
||||
return any(marker in normalized for marker in frustration_markers)
|
||||
|
||||
|
||||
def _voice_recent_clarification_count(transcript_window: list[VoiceTranscriptSegmentRow]) -> int:
|
||||
markers = (
|
||||
"в двух словах",
|
||||
"о чем именно",
|
||||
"чем могу помочь",
|
||||
"график работы какого",
|
||||
"какая услуга",
|
||||
"какой филиал",
|
||||
"назовите пожалуйста",
|
||||
"назовите один вариант",
|
||||
"плохо распознал",
|
||||
"опишите пожалуйста",
|
||||
"подскажите",
|
||||
"скажите коротко",
|
||||
@@ -952,12 +928,6 @@ def _voice_recent_clarification_count(transcript_window: list[VoiceTranscriptSeg
|
||||
if segment.speaker != "assistant":
|
||||
continue
|
||||
normalized = _voice_text_key(segment.text)
|
||||
if normalized.startswith("здравствуйте") and (
|
||||
"коротко расскажите" in normalized
|
||||
or "назовите пожалуйста ваше имя" in normalized
|
||||
or "подскажите пожалуйста чем помочь" in normalized
|
||||
):
|
||||
continue
|
||||
if any(marker in normalized for marker in markers):
|
||||
count += 1
|
||||
return count
|
||||
@@ -1146,12 +1116,6 @@ def _voice_confusion_prompt(language: str, caller_texts: list[str]) -> str:
|
||||
return "Подскажите точнее: график работы, статус заявки, тариф или оператор."
|
||||
|
||||
|
||||
def _voice_repair_prompt(language: str) -> str:
|
||||
if language == "kz":
|
||||
return "Daуыs nashar tanyldy. Bir нұсқаны ғана айтыңыз: jumys uaqyty, mekenjai, tarif, otinish nemese operator."
|
||||
return "Плохо распознал запрос. Назовите один вариант: график работы, адрес, тариф, заявка или оператор."
|
||||
|
||||
|
||||
def _voice_loop_handoff(language: str) -> tuple[str, str, str]:
|
||||
if language == "kz":
|
||||
return (
|
||||
@@ -1998,9 +1962,8 @@ def _voice_decision(
|
||||
recent_caller_window = caller_texts[-3:]
|
||||
low_signal_count = sum(1 for text in recent_caller_window if _voice_is_low_signal_caller_text(text))
|
||||
caller_confused = _voice_is_confused_caller_text(normalized)
|
||||
caller_frustrated = _voice_is_frustrated_caller_text(normalized)
|
||||
if clarification_count >= 4 or (
|
||||
clarification_count >= 3 and (caller_confused or caller_frustrated or low_signal_count >= 2 or repeated_reply_count >= 2)
|
||||
clarification_count >= 3 and (caller_confused or low_signal_count >= 2 or repeated_reply_count >= 2)
|
||||
):
|
||||
reply_text, handoff_reason, summary_text = _voice_loop_handoff(language)
|
||||
return {
|
||||
@@ -2017,32 +1980,6 @@ def _voice_decision(
|
||||
"latency_ms": 1,
|
||||
}
|
||||
|
||||
if not kb_results and (
|
||||
caller_frustrated
|
||||
or (
|
||||
clarification_count >= 2
|
||||
and repeated_reply_count >= 1
|
||||
and not _voice_has_service_topic(normalized)
|
||||
)
|
||||
):
|
||||
decision = {
|
||||
"language": language,
|
||||
"intent": "clarification",
|
||||
"reply_text": _voice_repair_prompt(language),
|
||||
"confidence": 0.5,
|
||||
"needs_handoff": False,
|
||||
"handoff_reason": None,
|
||||
"case_action": "keep_open",
|
||||
"kb_refs": [],
|
||||
"summary_text": "AI переключился в repair-mode после неудачных уточнений и попросил выбрать один короткий вариант.",
|
||||
"model": "voice_policy_repair",
|
||||
"latency_ms": 1,
|
||||
}
|
||||
if v2_metadata:
|
||||
decision["reply_text"] = _voice_compact_reply_text(decision["reply_text"], language=language)
|
||||
decision["metadata"] = {**v2_metadata, "reply_phase": "final"}
|
||||
return decision
|
||||
|
||||
if not kb_results and _voice_is_off_domain_request(normalized):
|
||||
reply_text, summary_text = _voice_off_domain_reply(language)
|
||||
decision = {
|
||||
|
||||
Reference in New Issue
Block a user