Merge pull request #763 from GOODDAYDAY/main

update: 优化系统prompt & 优化三方模块打印日志报错问题 & 修复Dify未过滤全量数据问题
This commit is contained in:
hrz
2025-04-14 23:09:43 +08:00
committed by GitHub
3 changed files with 14 additions and 8 deletions
+2 -4
View File
@@ -335,10 +335,8 @@ class ConnectionHandler:
def change_system_prompt(self, prompt):
self.prompt = prompt
# 找到原来的role==system,替换原来的系统提示
for m in self.dialogue.dialogue:
if m.role == "system":
m.content = prompt
# 更新系统prompt至上下文
self.dialogue.update_system_message(self.prompt)
def chat(self, query):
@@ -58,7 +58,8 @@ class LLMProvider(LLMProviderBase):
self.session_conversation_map[session_id] = (
conversation_id # 更新映射
)
if event.get("answer"):
# 过滤 message_replace 事件,此事件会全量推一次
if event.get("event") != "message_replace" and event.get("answer"):
yield event["answer"]
elif self.mode == "workflows/run":
for line in r.iter_lines():
@@ -73,7 +74,8 @@ class LLMProvider(LLMProviderBase):
for line in r.iter_lines():
if line.startswith(b"data: "):
event = json.loads(line[6:])
if event.get("answer"):
# 过滤 message_replace 事件,此事件会全量推一次
if event.get("event") != "message_replace" and event.get("answer"):
yield event["answer"]
except Exception as e: