diff --git a/lollms/app.py b/lollms/app.py index ff576d7..c6bf2f5 100644 --- a/lollms/app.py +++ b/lollms/app.py @@ -804,6 +804,39 @@ class LollmsApplication(LoLLMsCom): else: ASCIIColors.red(content) + def sync_notify( + self, + content, + notification_type: NotificationType = NotificationType.NOTIF_SUCCESS, + duration: int = 4, + client_id=None, + display_type: NotificationDisplayType = NotificationDisplayType.TOAST, + verbose: bool | None = None, + ): + if verbose is None: + verbose = self.verbose + self.schedule_task( + self.sio.emit( + "notification", + { + "content": content, + "notification_type": notification_type.value, + "duration": duration, + "display_type": display_type.value, + }, + to=client_id, + ) + ) + + if verbose: + if notification_type == NotificationType.NOTIF_SUCCESS: + ASCIIColors.success(content) + elif notification_type == NotificationType.NOTIF_INFO: + ASCIIColors.info(content) + elif notification_type == NotificationType.NOTIF_WARNING: + ASCIIColors.warning(content) + else: + ASCIIColors.red(content) async def refresh_files(self, client_id=None): await self.sio.emit("refresh_files", to=client_id) diff --git a/lollms/binding.py b/lollms/binding.py index 1f42c9d..542ebd6 100644 --- a/lollms/binding.py +++ b/lollms/binding.py @@ -458,7 +458,7 @@ class LLMBinding: verbose=True ): if self.lollmsCom: - return self.lollmsCom.notify(content=content, notification_type=notification_type, duration=duration, client_id=client_id, display_type=display_type, verbose=verbose) + return self.lollmsCom.sync_notify(content=content, notification_type=notification_type, duration=duration, client_id=client_id, display_type=display_type, verbose=verbose) ASCIIColors.white(content) diff --git a/lollms/com.py b/lollms/com.py index 230dedc..95ba67d 100644 --- a/lollms/com.py +++ b/lollms/com.py @@ -232,7 +232,28 @@ class LoLLMsCom: else: ASCIIColors.red(content) + def sync_notify( + self, + content, + notification_type: NotificationType = NotificationType.NOTIF_SUCCESS, + duration: int = 4, + client_id=None, + display_type: NotificationDisplayType = NotificationDisplayType.TOAST, + verbose: bool | None = None, + ): + if verbose is None: + verbose = self.verbose + if verbose: + if notification_type==NotificationType.NOTIF_SUCCESS: + ASCIIColors.success(content) + elif notification_type==NotificationType.NOTIF_INFO: + ASCIIColors.info(content) + elif notification_type==NotificationType.NOTIF_WARNING: + ASCIIColors.warning(content) + else: + ASCIIColors.red(content) + async def notify_model_install(self, installation_path, model_name,