fix: Update process method return type and handle image attribute correctly; improve error handling

This commit is contained in:
Showdown76 2025-05-19 13:10:46 +02:00
parent 670066100f
commit b881f04acc
2 changed files with 6 additions and 4 deletions

View File

@ -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)}"]

View File

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