mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 20:27:58 +00:00
upgraded notification
This commit is contained in:
parent
479329fd1e
commit
c59fa57547
@ -22,7 +22,8 @@ class LollmsApplication:
|
||||
load_model=True,
|
||||
try_select_binding=False,
|
||||
try_select_model=False,
|
||||
callback=None
|
||||
callback=None,
|
||||
notification_callback:Callable=None
|
||||
) -> None:
|
||||
"""
|
||||
Creates a LOLLMS Application
|
||||
@ -36,7 +37,7 @@ class LollmsApplication:
|
||||
self.personality = None
|
||||
|
||||
self.mounted_extensions = []
|
||||
|
||||
self.notification_callback = notification_callback
|
||||
self.binding=None
|
||||
self.model=None
|
||||
|
||||
@ -149,6 +150,9 @@ class LollmsApplication:
|
||||
return generated_text
|
||||
|
||||
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:
|
||||
ASCIIColors.yellow(content)
|
||||
else:
|
||||
@ -156,7 +160,7 @@ class LollmsApplication:
|
||||
|
||||
def load_binding(self):
|
||||
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
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
@ -59,7 +59,8 @@ class LLMBinding:
|
||||
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY,
|
||||
supported_file_extensions='*.bin',
|
||||
binding_type:BindingType=BindingType.TEXT_ONLY,
|
||||
models_dir_names:list=None
|
||||
models_dir_names:list=None,
|
||||
notification_callback:Callable=None
|
||||
) -> None:
|
||||
|
||||
self.binding_type = binding_type
|
||||
@ -71,6 +72,7 @@ class LLMBinding:
|
||||
self.binding_config = binding_config
|
||||
self.supported_file_extensions = supported_file_extensions
|
||||
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.parent.mkdir(parents=True, exist_ok=True)
|
||||
@ -94,6 +96,11 @@ class LLMBinding:
|
||||
for models_folder in self.models_folders:
|
||||
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):
|
||||
"""
|
||||
To be implemented by the bindings
|
||||
@ -465,14 +472,16 @@ class BindingBuilder:
|
||||
self,
|
||||
config: LOLLMSConfig,
|
||||
lollms_paths:LollmsPaths,
|
||||
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY
|
||||
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY,
|
||||
notification_callback:Callable=None
|
||||
)->LLMBinding:
|
||||
|
||||
binding:LLMBinding = self.getBinding(config, lollms_paths, installation_option)
|
||||
return binding(
|
||||
config,
|
||||
lollms_paths=lollms_paths,
|
||||
installation_option = installation_option
|
||||
installation_option = installation_option,
|
||||
notification_callback=notification_callback
|
||||
)
|
||||
|
||||
def getBinding(
|
||||
|
Loading…
Reference in New Issue
Block a user