Bugfix: Model set and personality set errors

This commit is contained in:
saloui 2023-05-24 16:17:00 +02:00
parent 4c5b162a71
commit 5bdf39f102
2 changed files with 16 additions and 13 deletions

12
app.py
View File

@ -454,7 +454,10 @@ class Gpt4AllWebUI(GPT4AllAPI):
def apply_settings(self): def apply_settings(self):
return jsonify(self.process.set_config(self.config)) result = self.process.set_config(self.config)
print("Set config results:")
print(result)
return jsonify(result)
def list_backends(self): def list_backends(self):
backends_dir = Path('./backends') # replace with the actual path to the models folder backends_dir = Path('./backends') # replace with the actual path to the models folder
@ -701,7 +704,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
# Build chatbot # Build chatbot
return jsonify(self.process.set_config(self.config)) return jsonify(self.process.set_config(self.config))
return jsonify({"status": "error"}) return jsonify({"status": "succeeded"})
def update_model_params(self): def update_model_params(self):
data = request.get_json() data = request.get_json()
@ -716,7 +719,6 @@ class Gpt4AllWebUI(GPT4AllAPI):
self.config['backend'] = backend self.config['backend'] = backend
self.config['model'] = model self.config['model'] = model
self.process.set_config(self.config)
self.config['personality_language'] = personality_language self.config['personality_language'] = personality_language
self.config['personality_category'] = personality_category self.config['personality_category'] = personality_category
@ -739,7 +741,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
save_config(self.config, self.config_file_path) save_config(self.config, self.config_file_path)
self.process.set_config(self.config)
# Fixed missing argument # Fixed missing argument
self.backend = self.process.rebuild_backend(self.config) self.backend = self.process.rebuild_backend(self.config)
@ -761,7 +763,7 @@ class Gpt4AllWebUI(GPT4AllAPI):
print(f"\trepeat_last_n:{self.config['repeat_last_n']}") print(f"\trepeat_last_n:{self.config['repeat_last_n']}")
print("==============================================") print("==============================================")
return jsonify({"status":"ok"}) return jsonify(self.process.set_config(self.config))
def get_available_models(self): def get_available_models(self):

View File

@ -179,8 +179,6 @@ class ModelProcess:
print("Couldn't build backend.") print("Couldn't build backend.")
print(ex) print(ex)
backend = None backend = None
self._set_config_result['backend_status'] ='failed'
self._set_config_result['errors'].append(f"couldn't build backend:{ex}")
return backend return backend
def _rebuild_model(self): def _rebuild_model(self):
@ -200,16 +198,18 @@ class ModelProcess:
print("Couldn't build model") print("Couldn't build model")
print(ex) print(ex)
self.model = None self.model = None
self._set_config_result['model_status'] ='failed' self._set_config_result['status'] ='failed'
self._set_config_result['errors'].append(f"couldn't build model:{ex}") self._set_config_result['backend_status'] ='failed'
self._set_config_result['errors'].append(f"couldn't build backend:{ex}")
except Exception as ex: except Exception as ex:
traceback.print_exc() traceback.print_exc()
print("Couldn't build backend") print("Couldn't build backend")
print(ex) print(ex)
self.backend = None self.backend = None
self.model = None self.model = None
self._set_config_result['model_status'] ='failed' self._set_config_result['status'] ='failed'
self._set_config_result['errors'].append(f"couldn't build model:{ex}") self._set_config_result['backend_status'] ='failed'
self._set_config_result['errors'].append(f"couldn't build backend:{ex}")
def rebuild_personality(self): def rebuild_personality(self):
try: try:
@ -239,8 +239,9 @@ class ModelProcess:
if self.config["debug"]: if self.config["debug"]:
print(ex) print(ex)
self.personality = AIPersonality() self.personality = AIPersonality()
self._set_config_result['personality_status'] ='failed' self._set_config_result['status'] ='failed'
self._set_config_result['errors'].append(f"couldn't load personality:{ex}") self._set_config_result['backend_status'] ='failed'
self._set_config_result['errors'].append(f"couldn't build backend:{ex}")
def step_callback(self, text, message_type): def step_callback(self, text, message_type):
self.generation_queue.put((text,self.id, message_type)) self.generation_queue.put((text,self.id, message_type))