mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-21 21:47:54 +00:00
now we can select bindings from personalities
This commit is contained in:
parent
f5cc2ba34b
commit
cfb18f6f10
@ -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()
|
||||||
|
|
||||||
|
@ -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
|
||||||
@ -3277,6 +3278,10 @@ fetch('/open_file', {
|
|||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user