upgraded notification

This commit is contained in:
Saifeddine ALOUI 2023-11-08 15:20:24 +01:00
parent 479329fd1e
commit c59fa57547
3 changed files with 20 additions and 7 deletions

View File

@ -22,7 +22,8 @@ class LollmsApplication:
load_model=True, load_model=True,
try_select_binding=False, try_select_binding=False,
try_select_model=False, try_select_model=False,
callback=None callback=None,
notification_callback:Callable=None
) -> None: ) -> None:
""" """
Creates a LOLLMS Application Creates a LOLLMS Application
@ -36,7 +37,7 @@ class LollmsApplication:
self.personality = None self.personality = None
self.mounted_extensions = [] self.mounted_extensions = []
self.notification_callback = notification_callback
self.binding=None self.binding=None
self.model=None self.model=None
@ -149,6 +150,9 @@ class LollmsApplication:
return generated_text return generated_text
def notify(self, content, is_success, client_id=None): def notify(self, content, is_success, client_id=None):
if self.notification_callback:
return self.notification_callback(content, is_success, client_id)
if is_success: if is_success:
ASCIIColors.yellow(content) ASCIIColors.yellow(content)
else: else:
@ -156,7 +160,7 @@ class LollmsApplication:
def load_binding(self): def load_binding(self):
try: try:
binding = BindingBuilder().build_binding(self.config, self.lollms_paths) binding = BindingBuilder().build_binding(self.config, self.lollms_paths, notification_callback=self.notify)
return binding return binding
except Exception as ex: except Exception as ex:
print(ex) print(ex)

View File

@ -59,7 +59,8 @@ class LLMBinding:
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY, installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY,
supported_file_extensions='*.bin', supported_file_extensions='*.bin',
binding_type:BindingType=BindingType.TEXT_ONLY, binding_type:BindingType=BindingType.TEXT_ONLY,
models_dir_names:list=None models_dir_names:list=None,
notification_callback:Callable=None
) -> None: ) -> None:
self.binding_type = binding_type self.binding_type = binding_type
@ -71,6 +72,7 @@ class LLMBinding:
self.binding_config = binding_config self.binding_config = binding_config
self.supported_file_extensions = supported_file_extensions self.supported_file_extensions = supported_file_extensions
self.seed = config["seed"] self.seed = config["seed"]
self.notification_callback = notification_callback
self.configuration_file_path = lollms_paths.personal_configuration_path/"bindings"/self.binding_folder_name/f"config.yaml" self.configuration_file_path = lollms_paths.personal_configuration_path/"bindings"/self.binding_folder_name/f"config.yaml"
self.configuration_file_path.parent.mkdir(parents=True, exist_ok=True) self.configuration_file_path.parent.mkdir(parents=True, exist_ok=True)
@ -94,6 +96,11 @@ class LLMBinding:
for models_folder in self.models_folders: for models_folder in self.models_folders:
models_folder.mkdir(parents=True, exist_ok=True) models_folder.mkdir(parents=True, exist_ok=True)
def notify(self, content:str, status:bool):
if self.notification_callback:
self.notification_callback(content, status)
def settings_updated(self): def settings_updated(self):
""" """
To be implemented by the bindings To be implemented by the bindings
@ -465,14 +472,16 @@ class BindingBuilder:
self, self,
config: LOLLMSConfig, config: LOLLMSConfig,
lollms_paths:LollmsPaths, lollms_paths:LollmsPaths,
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY,
notification_callback:Callable=None
)->LLMBinding: )->LLMBinding:
binding:LLMBinding = self.getBinding(config, lollms_paths, installation_option) binding:LLMBinding = self.getBinding(config, lollms_paths, installation_option)
return binding( return binding(
config, config,
lollms_paths=lollms_paths, lollms_paths=lollms_paths,
installation_option = installation_option installation_option = installation_option,
notification_callback=notification_callback
) )
def getBinding( def getBinding(

View File

@ -26,7 +26,7 @@ def get_all_files(path):
setuptools.setup( setuptools.setup(
name="lollms", name="lollms",
version="6.1.0", version="6.1.1",
author="Saifeddine ALOUI", author="Saifeddine ALOUI",
author_email="aloui.saifeddine@gmail.com", author_email="aloui.saifeddine@gmail.com",
description="A python library for AI personality definition", description="A python library for AI personality definition",