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

This commit is contained in:
John Wang 2023-06-13 15:47:58 +08:00 committed by GitHub
parent 433f8cb57e
commit a11f36ca60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(