diff --git a/api/__init__.py b/api/__init__.py index 153dfb80..2b56149b 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -13,7 +13,7 @@ from api.db import DiscussionsDB, Discussion from pathlib import Path from lollms.config import InstallOption from lollms.types import MSG_TYPE, SENDER_TYPES -from lollms.extension import LOLLMSExtension +from lollms.extension import LOLLMSExtension, ExtensionBuilder from lollms.personality import AIPersonality, PersonalityBuilder from lollms.binding import LOLLMSConfig, BindingBuilder, LLMBinding, ModelBuilder from lollms.paths import LollmsPaths @@ -1018,39 +1018,15 @@ class LoLLMsAPPI(LollmsApplication): if extension in loaded_names: mounted_extensions.append(loaded[loaded_names.index(extension)]) else: - personality_path = self.lollms_paths.personalities_zoo_path/f"{extension}" + extension_path = self.lollms_paths.extensions_zoo_path/f"{extension}" try: - extension = LOLLMSExtension() + extension = ExtensionBuilder().build_extension(extension_path,self.lollms_paths, self) mounted_extensions.append(extension) except Exception as ex: - ASCIIColors.error(f"Personality file not found or is corrupted ({personality_path}).\nReturned the following exception:{ex}\nPlease verify that the personality you have selected exists or select another personality. Some updates may lead to change in personality name or category, so check the personality selection in settings to be sure.") + ASCIIColors.error(f"Personality file not found or is corrupted ({extension_path}).\nReturned the following exception:{ex}\nPlease verify that the personality you have selected exists or select another personality. Some updates may lead to change in personality name or category, so check the personality selection in settings to be sure.") ASCIIColors.info("Trying to force reinstall") if self.config["debug"]: print(ex) - try: - personality = AIPersonality( - personality_path, - self.lollms_paths, - self.config, - self.model, - app = self, - run_scripts=True, - selected_language=personality.split(":")[1] if ":" in personality else None, - installation_option=InstallOption.FORCE_INSTALL) - mounted_extensions.append(personality) - except Exception as ex: - ASCIIColors.error(f"Couldn't load personality at {personality_path}") - trace_exception(ex) - ASCIIColors.info(f"Unmounting personality") - to_remove.append(i) - personality = AIPersonality(None, - self.lollms_paths, - self.config, - self.model, - run_scripts=True, - installation_option=InstallOption.FORCE_INSTALL) - mounted_extensions.append(personality) - ASCIIColors.info("Reverted to default personality") if self.config["active_personality_id"]>=0 and self.config["active_personality_id"]