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

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

View File

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