fix(voice): fast fallback for off-domain requests
This commit is contained in:
@@ -1356,6 +1356,46 @@ def test_voice_v2_fast_conversational_adds_ack_metadata_and_compacts_reply(monke
|
||||
assert len(decision["reply_text"]) <= 180
|
||||
|
||||
|
||||
def test_voice_v2_off_domain_request_returns_fast_operator_fallback_without_llm(monkeypatch):
|
||||
monkeypatch.setenv("AI_VOICE_POLICY_MODE", "v2_fast_conversational")
|
||||
|
||||
def _unexpected_llm(messages):
|
||||
raise AssertionError(f"LLM should not be called for off-domain fallback: {messages!r}")
|
||||
|
||||
monkeypatch.setattr(ai_module, "_request_structured_model_decision", _unexpected_llm)
|
||||
|
||||
decision = voice_module._voice_decision(
|
||||
language="ru",
|
||||
customer=None,
|
||||
interaction=SimpleNamespace(interaction_id="int_voice_off_domain", status="new", queue_id="que_voice", subject="unknown"),
|
||||
transcript_text="Мне надо узнать, как работает ядерный реактор.",
|
||||
transcript_window=[
|
||||
SimpleNamespace(
|
||||
speaker="caller",
|
||||
text="Мне надо узнать, как работает ядерный реактор.",
|
||||
sequence_no=1,
|
||||
source_type="voice_asr",
|
||||
barge_in_interrupted=False,
|
||||
created_at=utc_now_iso(),
|
||||
)
|
||||
],
|
||||
kb_results=[],
|
||||
disclosure_required=False,
|
||||
request_metadata={"voice_v2_enabled": True, "response_plan_id": "rsp_off_domain"},
|
||||
)
|
||||
|
||||
assert decision["intent"] == "clarification"
|
||||
assert decision["needs_handoff"] is False
|
||||
assert decision["model"] == "voice_policy_off_domain"
|
||||
assert "наших услуг" in decision["reply_text"].lower()
|
||||
assert "оператор" in decision["reply_text"].lower()
|
||||
assert "ai" not in decision["reply_text"].lower()
|
||||
assert "база знаний" not in decision["reply_text"].lower()
|
||||
assert decision["metadata"]["voice_v2_enabled"] is True
|
||||
assert decision["metadata"]["early_intent"] == "unknown"
|
||||
assert decision["metadata"]["response_plan_id"] == "rsp_off_domain"
|
||||
|
||||
|
||||
def test_ai_enqueue_creates_outbound_ai_reply_and_delivery_flow(monkeypatch):
|
||||
monkeypatch.setenv("AI_TELEGRAM_ENABLED", "1")
|
||||
monkeypatch.setenv("AI_PROVIDER", "stub")
|
||||
|
||||
Reference in New Issue
Block a user