mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
fix: stop completion response not save to db (#351)
This commit is contained in:
parent
433f8cb57e
commit
a11f36ca60
|
@ -75,7 +75,11 @@ class LLMCallbackHandler(BaseCallbackHandler):
|
||||||
self.conversation_message_task.save_message(self.llm_message)
|
self.conversation_message_task.save_message(self.llm_message)
|
||||||
|
|
||||||
def on_llm_new_token(self, token: str, **kwargs: Any) -> None:
|
def on_llm_new_token(self, token: str, **kwargs: Any) -> None:
|
||||||
|
try:
|
||||||
self.conversation_message_task.append_message_text(token)
|
self.conversation_message_task.append_message_text(token)
|
||||||
|
except ConversationTaskStoppedException as ex:
|
||||||
|
self.on_llm_error(error=ex)
|
||||||
|
|
||||||
self.llm_message.completion += token
|
self.llm_message.completion += token
|
||||||
|
|
||||||
def on_llm_error(
|
def on_llm_error(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user