From 822b6cc61f7c4effcb27e5ad04f942252ae1cb46 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Fri, 30 Jun 2023 22:09:47 +0200 Subject: [PATCH] enhanced logging of exceptions --- api/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/__init__.py b/api/__init__.py index be313d08..59b39e73 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -28,6 +28,7 @@ import traceback import sys from lollms.console import MainMenu import urllib +import traceback __author__ = "parisneo" __github__ = "https://github.com/ParisNeo/lollms-webui" @@ -719,6 +720,8 @@ class LoLLMsAPPI(): 1 : a notification message 2 : A hidden message """ + if message_type == MSG_TYPE.MSG_TYPE_STEP: + ASCIIColors.info("--> Step:"+chunk) if message_type == MSG_TYPE.MSG_TYPE_STEP_START: ASCIIColors.info("--> Step started:"+chunk) if message_type == MSG_TYPE.MSG_TYPE_STEP_END: @@ -797,7 +800,12 @@ class LoLLMsAPPI(): output = self.personality.processor.run_workflow( prompt, full_prompt, self.process_chunk) self.process_chunk(output, MSG_TYPE.MSG_TYPE_FULL) except Exception as ex: + # Catch the exception and get the traceback as a list of strings + traceback_lines = traceback.format_exception(type(ex), ex, ex.__traceback__) + # Join the traceback lines into a single string + traceback_text = ''.join(traceback_lines) ASCIIColors.error(f"Workflow run failed.\nError:{ex}") + ASCIIColors.error(traceback_text) self.process_chunk(f"Workflow run failed\nError:{ex}", MSG_TYPE.MSG_TYPE_EXCEPTION) print("Finished executing the workflow") return