From 8319b7bcda0d6e32b21aaaa10fc75020d902b7f0 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sat, 1 Jun 2024 14:10:12 +0200 Subject: [PATCH] enhanced tti integration --- lollms/personality.py | 26 +++++++------------ lollms/services/dalle/lollms_dalle.py | 2 +- lollms/services/diffusers/lollms_diffusers.py | 2 +- lollms/services/fooocus/lollms_fooocus.py | 2 +- .../services/midjourney/lollms_midjourney.py | 4 +-- lollms/services/sd/lollms_sd.py | 2 +- lollms/tti.py | 4 ++- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/lollms/personality.py b/lollms/personality.py index 57c4844..08f1b6a 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -2568,23 +2568,6 @@ class APScript(StateMachine): if callback: callback(warning, MSG_TYPE.MSG_TYPE_EXCEPTION) - def info(self, info:str, callback: Callable[[str, MSG_TYPE, dict, list], bool]=None): - """This sends exception to the client - - Args: - inf (str): The information to be sent - callback (callable, optional): A callable with this signature (str, MSG_TYPE, dict, list) to send the step to. Defaults to None. - The callback has these fields: - - chunk - - Message Type : the type of message - - Parameters (optional) : a dictionary of parameters - - Metadata (optional) : a list of metadata - """ - if not callback and self.callback: - callback = self.callback - - if callback: - callback(info, MSG_TYPE.MSG_TYPE_INFO) def json(self, title:str, json_infos:dict, callback: Callable[[str, int, dict, list], bool]=None, indent=4): """This sends json data to front end @@ -3198,6 +3181,15 @@ The AI should respond in this format using data from actions_list: ) + def InfoMessage(self, content, client_id=None, verbose:bool=None): + self.personality.app.notify( + content, + notification_type=NotificationType.NOTIF_SUCCESS, + duration=0, + client_id=client_id, + display_type=NotificationDisplayType.MESSAGE_BOX, + verbose=verbose + ) def info(self, info_text:str, callback: Callable[[str, MSG_TYPE, dict, list], bool]=None): """This sends info text to front end diff --git a/lollms/services/dalle/lollms_dalle.py b/lollms/services/dalle/lollms_dalle.py index c9e7fc1..bfe0ad4 100644 --- a/lollms/services/dalle/lollms_dalle.py +++ b/lollms/services/dalle/lollms_dalle.py @@ -43,7 +43,7 @@ class LollmsDalle(LollmsTTI): generation_engine="dall-e-3",# other possibility "dall-e-2" output_path=None ): - super().__init__(app) + super().__init__(generation_engine,app) self.key = key self.generation_engine = generation_engine self.output_path = output_path diff --git a/lollms/services/diffusers/lollms_diffusers.py b/lollms/services/diffusers/lollms_diffusers.py index 46217cf..7df4775 100644 --- a/lollms/services/diffusers/lollms_diffusers.py +++ b/lollms/services/diffusers/lollms_diffusers.py @@ -93,7 +93,7 @@ class LollmsDiffusers(LollmsTTI): app:LollmsApplication, wm = "Artbot", ): - super().__init__(app) + super().__init__("diffusers",app) self.ready = False # Get the current directory lollms_paths = app.lollms_paths diff --git a/lollms/services/fooocus/lollms_fooocus.py b/lollms/services/fooocus/lollms_fooocus.py index d379a5e..9f0e954 100644 --- a/lollms/services/fooocus/lollms_fooocus.py +++ b/lollms/services/fooocus/lollms_fooocus.py @@ -92,7 +92,7 @@ class LollmsFooocus(LollmsTTI): wm = "Artbot", base_url="localhost:1024" ): - super().__init__(app) + super().__init__("fooocus",app) self.ready = False self.base_url = base_url # Get the current directory diff --git a/lollms/services/midjourney/lollms_midjourney.py b/lollms/services/midjourney/lollms_midjourney.py index ed683a5..a4195b3 100644 --- a/lollms/services/midjourney/lollms_midjourney.py +++ b/lollms/services/midjourney/lollms_midjourney.py @@ -40,12 +40,10 @@ class LollmsMidjourney(LollmsTTI): self, app:LollmsApplication, key="", - generation_engine="dall-e-3",# other possibility "dall-e-2" output_path=None ): - super().__init__(app) + super().__init__("midjourney",app) self.key = key - self.generation_engine = generation_engine self.output_path = output_path def paint( diff --git a/lollms/services/sd/lollms_sd.py b/lollms/services/sd/lollms_sd.py index a3f87d5..674a643 100644 --- a/lollms/services/sd/lollms_sd.py +++ b/lollms/services/sd/lollms_sd.py @@ -256,7 +256,7 @@ class LollmsSD(LollmsTTI): share=False, wait_for_service=True ): - super().__init__(app) + super().__init__("stable_diffusion",app) if auto_sd_base_url=="" or auto_sd_base_url=="http://127.0.0.1:7860": auto_sd_base_url = None self.ready = False diff --git a/lollms/tti.py b/lollms/tti.py index 18921c0..743b4d4 100644 --- a/lollms/tti.py +++ b/lollms/tti.py @@ -25,7 +25,8 @@ class LollmsTTI: """ def __init__( - self, + self, + name:str, app: LollmsApplication, model="", api_key="", @@ -41,6 +42,7 @@ class LollmsTTI: output_path (Path or str, optional): Path where the output image files will be saved. Defaults to None. """ self.ready = False + self.name = name self.app = app self.model = model self.api_key = api_key