From b881f04accac868b9626291258e41cee188b8637 Mon Sep 17 00:00:00 2001 From: Showdown76py Date: Mon, 19 May 2025 13:10:46 +0200 Subject: [PATCH] fix: Update process method return type and handle image attribute correctly; improve error handling --- ai/processor.py | 8 ++++---- objects/logger.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ai/processor.py b/ai/processor.py index 1c55a87..86c5480 100644 --- a/ai/processor.py +++ b/ai/processor.py @@ -39,7 +39,7 @@ class AIProcessor: return f"Error executing {name}: {e}" # -------------------------- main entry -------------------------- # - def process(self, prompt: str, img_data: str | bytes | None = None) -> str | list[str | dict]: + def process(self, prompt: str, img_data: str | bytes | None = None) -> list[str | dict]: outputs = [] # type: list[str | dict] reexec = True nextsteps = "" @@ -68,7 +68,7 @@ class AIProcessor: outputs.append(r) if r else None # Make sure the two last messages from user has an image, but set disable_image to True for the others for msg in self.session.messages[-2:]: - msg.disable_image = True + msg.image = None logger.debug( self.session.messages ) @@ -96,7 +96,7 @@ class AIProcessor: aic.Message(role="assistant", content=output_text) ) - return outputs + return [*outputs] except Exception as e: traceback.print_exc() - return f"Error processing request: {str(e)}" + return [f"Error processing request: {str(e)}"] diff --git a/objects/logger.py b/objects/logger.py index cda9e1e..93ef0dc 100644 --- a/objects/logger.py +++ b/objects/logger.py @@ -1,6 +1,8 @@ import logging import os from logging.handlers import RotatingFileHandler +from dotenv import load_dotenv +load_dotenv() # Configuration values LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()