From 744a7f912b810ec777f128e80888982beed8c349 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sat, 8 Mar 2025 00:58:42 +0100 Subject: [PATCH] added lollms services zoo --- lollms/app.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ lollms/paths.py | 15 +++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/lollms/app.py b/lollms/app.py index 2ac0773..53e2b9d 100644 --- a/lollms/app.py +++ b/lollms/app.py @@ -124,6 +124,19 @@ class LollmsApplication(LoLLMsCom): ASCIIColors.blue("Models zoo found in your personal space.") ASCIIColors.execute_with_animation("Pulling last Models zoo", check_lollms_models_zoo) + # Pull the repository if it already exists + def check_lollms_function_calling_zoo(): + subprocess.run(["git", "-C", self.lollms_paths.functions_zoo_path, "pull"]) + ASCIIColors.blue("Function calling zoo found in your personal space.") + ASCIIColors.execute_with_animation("Pulling last Function calling zoo", check_lollms_function_calling_zoo) + + # Pull the repository if it already exists + def check_lollms_services_zoo(): + subprocess.run(["git", "-C", self.lollms_paths.services_zoo_path, "pull"]) + ASCIIColors.blue("Services zoo found in your personal space.") + ASCIIColors.execute_with_animation("Pulling last services zoo", check_lollms_services_zoo) + + except Exception as ex: ASCIIColors.error("Couldn't pull zoos. Please contact the main dev on our discord channel and report the problem.") trace_exception(ex) @@ -484,6 +497,39 @@ class LollmsApplication(LoLLMsCom): self.active_datalakes.append( rag_db | {"binding": lr} ) + + def load_class_from_folder(self, folder_path, target_name): + # List all folders in the given directory + folders = [f for f in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, f))] + + # Check if the target_name matches any folder name + if target_name in folders: + folder = os.path.join(folder_path, target_name) + + # Load the config.yaml file + config_path = os.path.join(folder, "config.yaml") + with open(config_path, 'r') as file: + config = yaml.safe_load(file) + + # Extract the class_name from the config + class_name = config.get('class_name') + if not class_name: + raise ValueError(f"class_name not found in {config_path}") + + # Load the Python file + python_file_path = os.path.join(folder, f"{target_name}.py") + spec = importlib.util.spec_from_file_location(target_name, python_file_path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + + # Import the class and instantiate it + class_ = getattr(module, class_name) + instance = class_(self) # Pass the config as a parameter to the constructor + + return instance + else: + raise FileNotFoundError(f"No folder named {target_name} found in {folder_path}") + def start_servers(self): ASCIIColors.yellow("* - * - * - Starting services - * - * - *") def start_local_services(*args, **kwargs): @@ -636,6 +682,8 @@ class LollmsApplication(LoLLMsCom): ASCIIColors.execute_with_animation("Loading loacal TTI services", start_tti, ASCIIColors.color_blue) def start_ttv(*args, **kwargs): + self.ttv = self.load_class_from_folder(self.lollms_paths.personal_services_path) + if self.config.active_ttv_service == "lumalabs": try: from lollms.services.ttv.lumalabs.lollms_lumalabs import LollmsLumaLabs diff --git a/lollms/paths.py b/lollms/paths.py index cfb9f38..f932414 100644 --- a/lollms/paths.py +++ b/lollms/paths.py @@ -18,10 +18,11 @@ safe_store_repo = "https://github.com/ParisNeo/safe_store.git" personalities_zoo_repo = "https://github.com/ParisNeo/lollms_personalities_zoo.git" bindings_zoo_repo = "https://github.com/ParisNeo/lollms_bindings_zoo.git" models_zoo_repo = "https://github.com/ParisNeo/models_zoo.git" +services_zoo_repo = "https://github.com/ParisNeo/lollms_services_zoo.git" functions_zoo_repo = "https://github.com/ParisNeo/lollms_functions_zoo.git" gptqlora_repo = "https://github.com/ParisNeo/gptqlora.git" -lollms_webui_version = "v17 (codename Pulsar 💫)" +lollms_webui_version = "v19 (codename Omni 🔗)" # Now we speify the personal folders class LollmsPaths: @@ -106,6 +107,8 @@ class LollmsPaths: self.bindings_zoo_path = rt / "bindings_zoo" self.personalities_zoo_path = rt / "personalities_zoo" self.models_zoo_path = rt / "models_zoo" + self.services_zoo_path = rt / "services_zoo" + self.functions_zoo_path = rt / "functions_zoo" else: ASCIIColors.orange("local zoos folder not found") @@ -114,6 +117,7 @@ class LollmsPaths: self.bindings_zoo_path = rt / "bindings_zoo" self.personalities_zoo_path = rt / "personalities_zoo" self.models_zoo_path = rt / "models_zoo" + self.services_zoo_path = rt / "services_zoo" self.functions_zoo_path = rt / "functions_zoo" @@ -205,7 +209,8 @@ class LollmsPaths: zoos = [ ("Bindings Zoo", self.bindings_zoo_path), ("Personalities Zoo", self.personalities_zoo_path), - ("Models Zoo", self.models_zoo_path) + ("Models Zoo", self.models_zoo_path), + ("Servicesq Zoo", self.services_zoo_path) ] for i, (name, path) in enumerate(zoos): @@ -293,6 +298,12 @@ class LollmsPaths: ASCIIColors.info("No models found in your personal space.\nCloning the models zoo") subprocess.run(["git", "clone", models_zoo_repo, self.models_zoo_path]) + if not self.services_zoo_repo.exists(): + # Clone the repository to the target path + ASCIIColors.info("No services found in your personal space.\nCloning the services zoo") + subprocess.run(["git", "clone", services_zoo_repo, self.services_zoo_path]) + + if not self.functions_zoo_path.exists(): # Clone the repository to the target path ASCIIColors.info("No functions found in your personal space.\nCloning the functions zoo")