Unverified Commit a11f36ca authored by John Wang's avatar John Wang Committed by GitHub

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

parent 433f8cb5
...@@ -75,7 +75,11 @@ class LLMCallbackHandler(BaseCallbackHandler): ...@@ -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:
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 self.llm_message.completion += token
def on_llm_error( def on_llm_error(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment