合并代码,解决冲突
(cherry picked from commit 8b23bd771f04ceb1b9c1e3ae021d75001af5ba2f)
This commit is contained in:
1 parent
23badf7456
commit
93e99793d8
10 files changed
+626
-84
No files matched your search
@@ -292,7 +292,7 @@ class DifyService:
|
||||
return {}
|
||||
|
||||
@staticmethod
|
||||
def stream_chat(query: str, user_id: int, agent, conversation_id: str = None, request_id: str | None = None):
|
||||
def stream_chat(query: str, user_id: int, agent, conversation_id: str = None, request_id: str | None = None, session_id: str | None = None):
|
||||
"""
|
||||
主流程,调用 Dify、解析 SSE、记录日志、写库、向上游继续产出 SSE
|
||||
Stream chat completion from Dify and relay SSE events to caller.
|
||||
@@ -450,6 +450,7 @@ class DifyService:
|
||||
chat_log_id = DifyService._log_chat(
|
||||
user_id=user_id,
|
||||
agent_id=agent.id,
|
||||
session_id=session_id,
|
||||
conversation_id=data.get('conversation_id') or normalized_conversation_id,
|
||||
query=query,
|
||||
answer=''.join(full_answer),
|
||||
@@ -494,6 +495,7 @@ class DifyService:
|
||||
def _log_chat(
|
||||
user_id,
|
||||
agent_id,
|
||||
session_id,
|
||||
conversation_id,
|
||||
query,
|
||||
answer,
|
||||
@@ -520,6 +522,7 @@ class DifyService:
|
||||
user_id=user_id,
|
||||
agent_id=agent_id,
|
||||
conversation_id=conversation_id,
|
||||
session_id=session_id,
|
||||
query=query,
|
||||
answer=answer,
|
||||
tokens_used=tokens or 0,
|
||||
|
||||
Reference in new issue
Block a user