Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: stop completion response not save to db (#351)

John Wanga11f36ca6066
diff --git a/api/core/callback_handler/llm_callback_handler.py b/api/core/callback_handler/llm_callback_handler.py
index b6f7ef2f549..da38fcabf59 100644
--- a/api/core/callback_handler/llm_callback_handler.py
+++ b/api/core/callback_handler/llm_callback_handler.py
@@ -75,7 +75,11 @@ class LLMCallbackHandler(BaseCallbackHandler):
self.conversation_message_task.save_message(self.llm_message)
def on_llm_new_token(self, token: str, **kwargs: Any) -> None:
- self.conversation_message_task.append_message_text(token)
+ try:
+ self.conversation_message_task.append_message_text(token)
+ except ConversationTaskStoppedException as ex:
+ self.on_llm_error(error=ex)
+
self.llm_message.completion += token
def on_llm_error(