now we can select bindings from personalities

This commit is contained in:
Saifeddine ALOUI 2024-04-21 23:58:23 +02:00
parent f5cc2ba34b
commit cfb18f6f10
2 changed files with 36 additions and 2 deletions

View File

@ -23,7 +23,7 @@ import subprocess
import importlib import importlib
import sys, os import sys, os
import platform import platform
import gc
class LollmsApplication(LoLLMsCom): class LollmsApplication(LoLLMsCom):
def __init__( def __init__(
@ -130,6 +130,35 @@ class LollmsApplication(LoLLMsCom):
self.mount_personalities() self.mount_personalities()
self.mount_extensions() self.mount_extensions()
def select_model(self, binding_name, model_name):
self.config["binding_name"] = binding_name
self.config["model_name"] = model_name
print(f"New binding selected : {binding_name}")
try:
if self.binding:
self.binding.destroy_model()
self.binding = None
self.model = None
for per in self.mounted_personalities:
if per is not None:
per.model = None
gc.collect()
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.INSTALL_IF_NECESSARY, lollmsCom=self)
self.config["model_name"] = model_name
self.model = self.binding.build_model()
for per in self.mounted_personalities:
if per is not None:
per.model = self.model
self.config.save_config()
ASCIIColors.green("Binding loaded successfully")
return True
except Exception as ex:
ASCIIColors.error(f"Couldn't build binding: [{ex}]")
trace_exception(ex)
return False
def add_discussion_to_skills_library(self, client: Client): def add_discussion_to_skills_library(self, client: Client):
messages = client.discussion.get_messages() messages = client.discussion.get_messages()

View File

@ -20,6 +20,7 @@ import pkg_resources
from pathlib import Path from pathlib import Path
from PIL import Image from PIL import Image
import re import re
from datetime import datetime from datetime import datetime
import importlib import importlib
import shutil import shutil
@ -3276,7 +3277,11 @@ fetch('/open_file', {
return compress_python(code) return compress_python(code)
def compress_html(self, code): def compress_html(self, code):
return compress_html(code) return compress_html(code)
# ===========================================================
def select_model(self, binding_name, model_name):
self.personality.app.select_model(binding_name, model_name)
class AIPersonalityInstaller: class AIPersonalityInstaller:
def __init__(self, personality:AIPersonality) -> None: def __init__(self, personality:AIPersonality) -> None:
self.personality = personality self.personality = personality