mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
envia speaker_id para a LLM em cada mensagem
This commit is contained in:
parent
37150d60b5
commit
8ab3e8c9a3
1 changed files with 3 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue