From f18ce203b5b250ddc21c53519196fa90682ba2f4 Mon Sep 17 00:00:00 2001 From: takatost Date: Sat, 12 Aug 2023 02:22:43 +0800 Subject: [PATCH] feat: optimize error logging (#808) --- .../callback_handler/agent_loop_gather_callback_handler.py | 4 ++-- api/core/callback_handler/dataset_tool_callback_handler.py | 2 +- api/core/callback_handler/llm_callback_handler.py | 2 +- .../callback_handler/main_chain_gather_callback_handler.py | 4 ++-- api/core/indexing_runner.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/core/callback_handler/agent_loop_gather_callback_handler.py b/api/core/callback_handler/agent_loop_gather_callback_handler.py index 64fb1bf108..f79db810ca 100644 --- a/api/core/callback_handler/agent_loop_gather_callback_handler.py +++ b/api/core/callback_handler/agent_loop_gather_callback_handler.py @@ -85,7 +85,7 @@ class AgentLoopGatherCallbackHandler(BaseCallbackHandler): def on_llm_error( self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any ) -> None: - logging.error(error) + logging.exception(error) self._agent_loops = [] self._current_loop = None self._message_agent_thought = None @@ -164,7 +164,7 @@ class AgentLoopGatherCallbackHandler(BaseCallbackHandler): self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any ) -> None: """Do nothing.""" - logging.error(error) + logging.exception(error) self._agent_loops = [] self._current_loop = None self._message_agent_thought = None diff --git a/api/core/callback_handler/dataset_tool_callback_handler.py b/api/core/callback_handler/dataset_tool_callback_handler.py index 5f0c5f0731..c979ff4739 100644 --- a/api/core/callback_handler/dataset_tool_callback_handler.py +++ b/api/core/callback_handler/dataset_tool_callback_handler.py @@ -68,4 +68,4 @@ class DatasetToolCallbackHandler(BaseCallbackHandler): self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any ) -> None: """Do nothing.""" - logging.error(error) + logging.exception(error) diff --git a/api/core/callback_handler/llm_callback_handler.py b/api/core/callback_handler/llm_callback_handler.py index 89b498c3e8..d7efa23021 100644 --- a/api/core/callback_handler/llm_callback_handler.py +++ b/api/core/callback_handler/llm_callback_handler.py @@ -96,4 +96,4 @@ class LLMCallbackHandler(BaseCallbackHandler): ) self.conversation_message_task.save_message(llm_message=self.llm_message, by_stopped=True) else: - logging.error(error) + logging.exception(error) diff --git a/api/core/callback_handler/main_chain_gather_callback_handler.py b/api/core/callback_handler/main_chain_gather_callback_handler.py index fc0a65e42a..f0cde2e819 100644 --- a/api/core/callback_handler/main_chain_gather_callback_handler.py +++ b/api/core/callback_handler/main_chain_gather_callback_handler.py @@ -72,5 +72,5 @@ class MainChainGatherCallbackHandler(BaseCallbackHandler): def on_chain_error( self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any ) -> None: - logging.error(error) - self.clear_chain_results() \ No newline at end of file + logging.exception(error) + self.clear_chain_results() diff --git a/api/core/indexing_runner.py b/api/core/indexing_runner.py index 57e1e8fab6..761c1c756b 100644 --- a/api/core/indexing_runner.py +++ b/api/core/indexing_runner.py @@ -549,7 +549,7 @@ class IndexingRunner: qa_documents.append(qa_document) format_documents.extend(qa_documents) except Exception as e: - logging.error(str(e)) + logging.exception(e) all_qa_documents.extend(format_documents)