This commit is contained in:
saloui 2023-06-26 12:45:46 +02:00
parent a85ea36954
commit c56bf45a7e
2 changed files with 45 additions and 11 deletions

View File

@ -107,16 +107,20 @@ class LoLLMsAPPI():
if config.model_name is None: if config.model_name is None:
self.menu.select_model() self.menu.select_model()
self.model = self.binding.build_model()
self.mounted_personalities = [] self.mounted_personalities = []
self.mounted_personalities = self.rebuild_personalities() try:
if self.config["active_personality_id"]<len(self.mounted_personalities): self.model = self.binding.build_model()
self.personality:AIPersonality = self.mounted_personalities[self.config["active_personality_id"]] self.mounted_personalities = self.rebuild_personalities()
else: if self.config["active_personality_id"]<len(self.mounted_personalities):
self.personality:AIPersonality = None self.personality:AIPersonality = self.mounted_personalities[self.config["active_personality_id"]]
if config["debug"]: else:
print(print(f"{self.personality}")) self.personality:AIPersonality = None
if config["debug"]:
print(print(f"{self.personality}"))
except Exception as ex:
ASCIIColors.error(f"Couldn't load model:\nException generated:{ex}")
self.model = None
self.config_file_path = config_file_path self.config_file_path = config_file_path
self.cancel_gen = False self.cancel_gen = False

34
app.py
View File

@ -41,6 +41,9 @@ from flask import (
stream_with_context, stream_with_context,
send_from_directory send_from_directory
) )
from tkinter import Tk
from tkinter.filedialog import askopenfilename
from flask_socketio import SocketIO, emit from flask_socketio import SocketIO, emit
from pathlib import Path from pathlib import Path
import yaml import yaml
@ -88,7 +91,9 @@ class LoLLMsWebUI(LoLLMsAPPI):
# Endpoints # Endpoints
# ========================================================================================= # =========================================================================================
self.add_endpoint("/install_model_from_path", "install_model_from_path", self.install_model_from_path, methods=["GET"])
self.add_endpoint("/reinstall_binding", "reinstall_binding", self.reinstall_binding, methods=["POST"]) self.add_endpoint("/reinstall_binding", "reinstall_binding", self.reinstall_binding, methods=["POST"])
@ -800,13 +805,38 @@ class LoLLMsWebUI(LoLLMsAPPI):
"active_personality_id":self.config["active_personality_id"] "active_personality_id":self.config["active_personality_id"]
}) })
def install_model_from_path(self):
ASCIIColors.info(f"- Selecting model ...")
# Define the file types
filetypes = [
("Model file", self.binding.file_extension),
]
# Create the Tkinter root window
root = Tk()
# Hide the root window
root.withdraw()
# Open the file dialog
file_path = askopenfilename(filetypes=filetypes)
file_path = Path(file_path)
#
with open(str(self.lollms_paths.personal_models_path/self.config.binding_name/(file_path.stem+".reference")),"w") as f:
f.write(file_path)
return jsonify({
"status": True
})
def reinstall_binding(self): def reinstall_binding(self):
try: try:
data = request.get_json() data = request.get_json()
# Further processing of the data # Further processing of the data
except Exception as e: except Exception as e:
print(f"Error occurred while parsing JSON: {e}") print(f"Error occurred while parsing JSON: {e}")
return return jsonify({"status":False, 'error':str(ex)})
ASCIIColors.info(f"- Reinstalling binding {data['name']}...") ASCIIColors.info(f"- Reinstalling binding {data['name']}...")
try: try:
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.FORCE_INSTALL) self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.FORCE_INSTALL)