added sync notify

This commit is contained in:
Saifeddine ALOUI 2025-04-09 21:47:59 +02:00
parent bbdd04e512
commit ee8d670d0a
3 changed files with 55 additions and 1 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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,