Now the backends are automatically installed when selected

This commit is contained in:
Saifeddine ALOUI 2023-05-23 20:03:54 +02:00
parent 0241d300b8
commit 2137170278
2 changed files with 9 additions and 3 deletions

8
app.py
View File

@ -284,6 +284,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
personalities[language_folder.name][category_folder.name].append(personality_info)
return json.dumps(personalities)
# Settings (data: {"setting_name":<the setting name>,"setting_value":<the setting value>})
def update_setting(self):
data = request.get_json()
@ -371,10 +372,11 @@ class Gpt4AllWebUI(GPT4AllAPI):
elif setting_name== "backend":
if self.config['backend']!= data['setting_value']:
print("New backend selected")
print(f"New backend selected : {data['setting_value']}")
self.config["backend"]=data['setting_value']
try:
self.backend = self.process.load_backend(self.config["backend"])
self.backend = self.process.load_backend(self.config["backend"], install=True)
except Exception as ex:
print("Couldn't build backend")
return jsonify({'setting_name': data['setting_name'], "status":False, 'error':str(ex)})
@ -391,7 +393,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
if self.config["debug"]:
print(f"Configuration {data['setting_name']} set to {data['setting_value']}")
print("Configuration updated")
print(f"Configuration {data['setting_name']} updated")
# Tell that the setting was changed
return jsonify({'setting_name': data['setting_name'], "status":True})

View File

@ -108,6 +108,10 @@ class ModelProcess:
}
def load_backend(self, backend_name:str, install=False):
if install:
print(f"Loading backend {backend_name} install ON")
else:
print(f"Loading backend : {backend_name} install is off")
backend_path = Path("backends")/backend_name
if install:
# first find out if there is a requirements.txt file