added lollms services zoo

This commit is contained in:
Saifeddine ALOUI 2025-03-08 00:58:42 +01:00
parent 3e53eb6964
commit 744a7f912b
2 changed files with 61 additions and 2 deletions

View File

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

View File

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