记录只采集用户最近的发言。不采集助手的发言。

This commit is contained in:
liuwei
2026-02-05 10:34:28 +08:00
parent db90896775
commit 3723434bd6

View File

@@ -264,6 +264,7 @@ class DifyPlugin(MessagePluginInterface):
# 将历史记录转换为字符串格式 # 将历史记录转换为字符串格式
for msg in self.conversations[session_id]: for msg in self.conversations[session_id]:
role = "用户" if msg["role"] == "user" else "助手" role = "用户" if msg["role"] == "user" else "助手"
if role == "用户":
history_text += f"{role}: {msg['content']}\n" history_text += f"{role}: {msg['content']}\n"
history_text = history_text.strip() history_text = history_text.strip()