Skip to content

Commit

Permalink
upgraded
Browse files Browse the repository at this point in the history
  • Loading branch information
ParisNeo committed Jul 23, 2023
1 parent 74d07a0 commit e00da21
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
32 changes: 14 additions & 18 deletions lollms/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand All @@ -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):
Expand Down
20 changes: 12 additions & 8 deletions lollms/personality.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e00da21

Please sign in to comment.