From e00da21da139bb4bd7c9bb7c861dd14d493ca177 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Mon, 24 Jul 2023 01:27:05 +0200 Subject: [PATCH] upgraded --- lollms/app.py | 32 ++++++++++++++------------------ lollms/personality.py | 20 ++++++++++++-------- setup.py | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lollms/app.py b/lollms/app.py index e7aeceea..ed57db1f 100644 --- a/lollms/app.py +++ b/lollms/app.py @@ -22,6 +22,9 @@ def __init__(self, app_name:str, config:LOLLMSConfig, lollms_paths:LollmsPaths, self.mounted_personalities = [] self.personality = None + self.binding=None + self.model=None + try: if config.auto_update: ASCIIColors.info("Bindings zoo found in your personal space.\nPulling last personalities zoo") @@ -38,11 +41,10 @@ def __init__(self, app_name:str, config:LOLLMSConfig, lollms_paths:LollmsPaths, if self.config.binding_name is None: ASCIIColors.warning(f"No binding selected") - ASCIIColors.info("Please select a valid model or install a new one from a url") if try_select_binding: + ASCIIColors.info("Please select a valid model or install a new one from a url") self.menu.select_binding() - else: - self.binding=None + if load_binding: try: @@ -57,23 +59,17 @@ def __init__(self, app_name:str, config:LOLLMSConfig, lollms_paths:LollmsPaths, if load_model: if self.config.model_name is None: ASCIIColors.warning(f"No model selected") - print("Please select a valid model") - self.menu.select_model() - try: - self.model = self.load_model() - except Exception as ex: - ASCIIColors.error(f"Failed to load model.\nReturned exception: {ex}") - trace_exception(ex) - self.model = None - else: - self.model = None + if try_select_model: + print("Please select a valid model") + self.menu.select_model() + if self.config.model_name is not None: + try: + self.model = self.load_model() + except Exception as ex: + ASCIIColors.error(f"Failed to load model.\nReturned exception: {ex}") + trace_exception(ex) else: ASCIIColors.warning(f"Couldn't load binding {self.config.binding_name}.") - self.binding = None - self.model = None - else: - self.binding = None - self.model = None self.mount_personalities() def load_binding(self): diff --git a/lollms/personality.py b/lollms/personality.py index bbdd1387..4365ee1b 100644 --- a/lollms/personality.py +++ b/lollms/personality.py @@ -44,11 +44,7 @@ def install_package(package_name): class AIPersonality: # Extra - Conditionning_commands={ - "date_time": datetime.now().strftime("%A, %B %d, %Y %I:%M:%S %p"), # Replaces {{date}} with actual date - "date": datetime.now().strftime("%A, %B %d, %Y"), # Replaces {{date}} with actual date - "time": datetime.now().strftime("%H:%M:%S"), # Replaces {{time}} with actual time - } + def __init__( self, @@ -353,6 +349,14 @@ def as_dict(self): } # ========================================== Properties =========================================== + @property + def conditionning_commands(self): + return { + "date_time": datetime.now().strftime("%A, %B %d, %Y %I:%M:%S %p"), # Replaces {{date}} with actual date + "date": datetime.now().strftime("%A, %B %d, %Y"), # Replaces {{date}} with actual date + "time": datetime.now().strftime("%H:%M:%S"), # Replaces {{time}} with actual time + } + @property def logo(self): """ @@ -453,7 +457,7 @@ def personality_conditioning(self) -> str: Returns: str: The personality conditioning of the AI assistant. """ - return self.replace_keys(self._personality_conditioning, self.Conditionning_commands) + return self.replace_keys(self._personality_conditioning, self.conditionning_commands) @personality_conditioning.setter def personality_conditioning(self, conditioning: str): @@ -473,7 +477,7 @@ def welcome_message(self) -> str: Returns: str: The welcome message of the AI assistant. """ - return self.replace_keys(self._welcome_message, self.Conditionning_commands) + return self.replace_keys(self._welcome_message, self.conditionning_commands) @welcome_message.setter def welcome_message(self, message: str): @@ -1063,7 +1067,7 @@ def process(self, text:str, message_type:MSG_TYPE): antiprompt = self.personality.detect_antiprompt(bot_says) if antiprompt: self.bot_says = self.remove_text_from_string(bot_says,antiprompt) - ASCIIColors.warning(f"Detected hallucination with antiprompt: {antiprompt}") + ASCIIColors.warning(f"\nDetected hallucination with antiprompt: {antiprompt}") return False else: self.bot_says = bot_says diff --git a/setup.py b/setup.py index 3908e92f..a4465d24 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ def get_all_files(path): setuptools.setup( name="lollms", - version="2.1.53", + version="2.1.54", author="Saifeddine ALOUI", author_email="aloui.saifeddine@gmail.com", description="A python library for AI personality definition",