fix(voice): preserve llm name corrections in downstream turns
This commit is contained in:
@@ -712,8 +712,7 @@ def _voice_downstream_name_update(
|
||||
action = "provide" if not name_value else "confirm"
|
||||
candidate = candidate or name_value
|
||||
elif status == "name_obtained":
|
||||
if explicit_candidate and candidate_key and candidate_key != current_key:
|
||||
action = "correct"
|
||||
pass
|
||||
else:
|
||||
if explicit_candidate:
|
||||
action = "provide"
|
||||
@@ -1121,10 +1120,19 @@ def _voice_llm_prompt_messages(
|
||||
if name_status in ("name_not_obtained", "name_followup_required"):
|
||||
system_prompt += (
|
||||
" The user's name is not yet obtained. If the user explicitly provided their name in this turn, "
|
||||
"extract it into the `extracted_name` JSON field. If they did not provide a name or just stated a problem "
|
||||
"extract it into the `extracted_name` JSON field. Extract ONLY the actual name, not surrounding words "
|
||||
"like commands or verbs (e.g. from 'Меня зовут Ернор. Перезаписать.' extract only 'Ернор'). "
|
||||
"If they did not provide a name or just stated a problem "
|
||||
"(e.g., 'У меня не работает интернет'), set `extracted_name` to null and politely ask for their name "
|
||||
"in your `reply_text` before assisting."
|
||||
)
|
||||
elif name_status == "name_obtained" and name_value:
|
||||
system_prompt += (
|
||||
f" The customer's name is currently recorded as '{name_value}'. "
|
||||
"If the user explicitly corrects their name in this turn (e.g. 'Нет, меня зовут X' or 'Моё имя Y'), "
|
||||
"extract the corrected name into `extracted_name`. Extract ONLY the actual name. "
|
||||
"Otherwise set `extracted_name` to null."
|
||||
)
|
||||
|
||||
return [
|
||||
{
|
||||
@@ -1965,7 +1973,7 @@ def turn_voice_session(session_id: str, payload: VoiceAITurnIn) -> VoiceAITurnDe
|
||||
customer_name_status=name_update["status"],
|
||||
)
|
||||
|
||||
if decision.get("extracted_name") and name_update["status"] not in ("name_obtained", "name_obtained_previously"):
|
||||
if decision.get("extracted_name"):
|
||||
name_update["status"] = "name_obtained"
|
||||
name_update["value"] = str(decision["extracted_name"]).strip()
|
||||
name_update["source"] = "llm_extraction"
|
||||
|
||||
Reference in New Issue
Block a user