1.修改提示词与说话人注入,减少模型每次回答都带着说话人信息
This commit is contained in:
DaGou12138
2026-07-08 14:12:16 +08:00
parent 209fd3fbc8
commit 04c10ef225
3 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ Calling unnecessarily is also wrong: User asks ”明天天气” → you call g
<speaker_recognition>
For the input format `{"speaker":"...", "content":"..."}` (speaker = speaker name, content = text):
1. [Identity known] When `speaker` is a specific name, identity has been recognized. On the first turn you must address them naturally and adjust your response style based on their history.
1. [Identity known] When `speaker` is a specific name, identity has been recognized — remember it and stay consistent about who they are. The only restriction is about OPENING a reply: do not start every reply by greeting or addressing them by name. You may greet/address them by name naturally ONLY ONCE (the first time you see their name); after that, get straight to the point. This does NOT forbid mentioning their name — if the user asks who they are, whether you know them (e.g. "你知道我是谁吗", "还记得我吗"), or otherwise references their identity, you MUST answer truthfully using their recognized name. Always adjust your response style based on their history.
2. [Identity unknown] When `speaker` is `未知说话人`, the system failed to identify the voice. You must NEVER mention the data inside the `speakers_info` tag to the user. Judge from context whether the speaker is the owner or the owner's friend, and keep the conversation natural.
</speaker_recognition>
+2 -2
View File
@@ -983,7 +983,7 @@ class ConnectionHandler:
llm_responses = self.llm.response_with_functions(
self.session_id,
self.dialogue.get_llm_dialogue_with_memory(
memory_str, self.config.get("voiceprint", {})
memory_str, self.config.get("voiceprint", {}), self.current_speaker
),
functions=functions,
)
@@ -991,7 +991,7 @@ class ConnectionHandler:
llm_responses = self.llm.response(
self.session_id,
self.dialogue.get_llm_dialogue_with_memory(
memory_str, self.config.get("voiceprint", {})
memory_str, self.config.get("voiceprint", {}), self.current_speaker
),
)
except Exception as e:
+7 -2
View File
@@ -92,7 +92,8 @@ class Dialogue:
return result
def get_llm_dialogue_with_memory(
self, memory_str: str = None, voiceprint_config: dict = None
self, memory_str: str = None, voiceprint_config: dict = None,
current_speaker: str = None,
) -> List[Dict[str, str]]:
# 构建对话
dialogue = []
@@ -145,8 +146,12 @@ class Dialogue:
# 追加说话人信息
try:
speakers = voiceprint_config.get("speakers", [])
if speakers:
current_speaker_name = (current_speaker or "").strip()
if speakers or (current_speaker_name and current_speaker_name != "未知说话人"):
dynamic_part += "\n<speakers_info>"
# 当前说话人置于块首,确保弱模型也能稳定获取身份
if current_speaker_name and current_speaker_name != "未知说话人":
dynamic_part += f"\n当前说话人:{current_speaker_name}"
for speaker_str in speakers:
try:
parts = speaker_str.split(",", 2)