feat: enhance voice reply logic to prevent duplicate name addressing and improve greeting handling
deploy / deploy (push) Successful in 32s
deploy / deploy (push) Successful in 32s
This commit is contained in:
@@ -1681,6 +1681,61 @@ def test_voice_llm_prompt_includes_context_summary_and_uses_12_segments():
|
||||
assert payload["history"][0]["sequence_no"] == 4
|
||||
|
||||
|
||||
def test_voice_llm_prompt_instructs_model_not_to_self_name_customer():
|
||||
messages = voice_module._voice_llm_prompt_messages(
|
||||
language="ru",
|
||||
customer=None,
|
||||
interaction=SimpleNamespace(
|
||||
interaction_id="int_voice_prompt_name",
|
||||
status="open",
|
||||
queue_id="que_voice",
|
||||
subject="schedule",
|
||||
customer_id="cus_voice_prompt_name",
|
||||
),
|
||||
transcript_text="Мне нужен график работы",
|
||||
transcript_window=[],
|
||||
conversation_summary_text="",
|
||||
kb_results=[],
|
||||
name_value="Ернур",
|
||||
name_status="name_obtained",
|
||||
)
|
||||
system_prompt = messages[0]["content"]
|
||||
assert "addressing the customer by name" in system_prompt
|
||||
|
||||
|
||||
def test_voice_reply_with_name_does_not_duplicate_inflected_name_form():
|
||||
# The model may address the customer using a grammatically declined form of
|
||||
# their name ("Данияре" instead of "Данияр"); an exact-token dedup check
|
||||
# would miss this and prepend the name a second time.
|
||||
reply = voice_module._voice_reply_with_name(
|
||||
"ru", "Здравствуйте, Данияре! Чем могу помочь?", "Данияр"
|
||||
)
|
||||
assert reply == "Здравствуйте, Данияре! Чем могу помочь?"
|
||||
|
||||
# A reply with no mention of the customer's name still gets it prefixed once.
|
||||
reply = voice_module._voice_reply_with_name("ru", "Чем могу помочь?", "Данияр")
|
||||
assert reply == "Данияр, Чем могу помочь?"
|
||||
|
||||
|
||||
def test_voice_reply_with_name_greet_mode_uses_one_of_two_fixed_forms():
|
||||
# Regular turns (name already known): just the name, never a greeting word.
|
||||
reply = voice_module._voice_reply_with_name("ru", "Чем могу помочь?", "Данияр", greet=False)
|
||||
assert reply == "Данияр, Чем могу помочь?"
|
||||
|
||||
# The turn the name is first learned: exactly "Здравствуйте, {name}, ...".
|
||||
reply = voice_module._voice_reply_with_name("ru", "Чем могу помочь?", "Данияр", greet=True)
|
||||
assert reply == "Здравствуйте, Данияр, Чем могу помочь?"
|
||||
|
||||
reply = voice_module._voice_reply_with_name("kz", "Немен көмектесе аламын?", "Ерлан", greet=True)
|
||||
assert reply == "Сәлеметсіз бе, Ерлан, Немен көмектесе аламын?"
|
||||
|
||||
# Still deduplicates even in greet mode if the model already named the customer.
|
||||
reply = voice_module._voice_reply_with_name(
|
||||
"ru", "Здравствуйте, Данияре! Чем могу помочь?", "Данияр", greet=True
|
||||
)
|
||||
assert reply == "Здравствуйте, Данияре! Чем могу помочь?"
|
||||
|
||||
|
||||
def test_voice_postprocess_reply_uses_summary_context_when_raw_window_lost_topic():
|
||||
reply_text = voice_module._voice_postprocess_reply_text(
|
||||
language="ru",
|
||||
|
||||
Reference in New Issue
Block a user