From a21ce0a06cae174f3625e779d830de0d1b615288 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Tue, 10 Oct 2023 23:42:01 +0200 Subject: [PATCH] upgraded ui --- api/__init__.py | 4 +++- app.py | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/api/__init__.py b/api/__init__.py index e1a10f78..aa2d13f1 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -1531,7 +1531,9 @@ class LoLLMsAPPI(LollmsApplication): return output def start_message_generation(self, message, message_id, client_id, is_continue=False): - + if self.personality is None: + self.notify("Select a personality",False,None) + return ASCIIColors.info(f"Text generation requested by client: {client_id}") # send the message to the bot print(f"Received message : {message.content}") diff --git a/app.py b/app.py index 32c3874b..a630556a 100644 --- a/app.py +++ b/app.py @@ -27,6 +27,7 @@ import traceback import webbrowser from pathlib import Path import os +from lollms.utilities import AdvancedGarbageCollector def run_update_script(args=None): update_script = Path(__file__).parent/"update_script.py" @@ -811,8 +812,17 @@ class LoLLMsWebUI(LoLLMsAPPI): del self.binding self.binding = None + to_remove = [] for per in self.mounted_personalities: - per.model = None + if per is not None: + per.model = None + else: + to_remove.append(per) + for per in to_remove: + self.mounted_personalities.remove(per) + if len(self.mounted_personalities)==0: + self.config.personalities= ["generic/lollms"] + self.mount_personality(0) gc.collect() self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths) self.model = self.binding.build_model() @@ -1457,6 +1467,8 @@ class LoLLMsWebUI(LoLLMsAPPI): ASCIIColors.info(f"- Reinstalling binding {data['name']}...") try: ASCIIColors.info("Unmounting binding and model") + GG = AdvancedGarbageCollector() + GG.safeHardCollect("binding", self) self.binding = None gc.collect() ASCIIColors.info("Reinstalling binding")