envia speaker_id para a LLM em cada mensagem

This commit is contained in:
Jordan 2026-10-14 10:59:46 -03:00
parent 37150d60b5
commit 8ab3e8c9a3

View file

@ -54,13 +54,9 @@ async def startToChat(conn: "ConnectionHandler", text):
actual_content = data["content"]
conn.logger.bind(tag=TAG).info(f"解析到说话人信息: {speaker_name}")
# 仅在该说话人首次出现时保留 {"speaker":...} JSON,让模型自然称呼一次;
# 后续轮降为纯文本,避免每轮重复出现名字诱导模型反复称呼
if speaker_name not in conn.introduced_speakers:
conn.introduced_speakers.add(speaker_name)
actual_text = text
else:
actual_text = actual_content
# Mantém o JSON completo contendo o speaker para a LLM sempre identificar quem fala
actual_text = text
except (json.JSONDecodeError, KeyError):
# 如果解析失败,继续使用原始文本
pass