From 5bdf39f102c218e20284d9976a06e58e9baa930a Mon Sep 17 00:00:00 2001 From: saloui Date: Wed, 24 May 2023 16:17:00 +0200 Subject: [PATCH] Bugfix: Model set and personality set errors --- app.py | 12 +++++++----- gpt4all_api/api.py | 17 +++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index db86d25d..b4cac01e 100644 --- a/app.py +++ b/app.py @@ -454,7 +454,10 @@ class Gpt4AllWebUI(GPT4AllAPI): 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): backends_dir = Path('./backends') # replace with the actual path to the models folder @@ -701,7 +704,7 @@ class Gpt4AllWebUI(GPT4AllAPI): # Build chatbot return jsonify(self.process.set_config(self.config)) - return jsonify({"status": "error"}) + return jsonify({"status": "succeeded"}) def update_model_params(self): data = request.get_json() @@ -716,7 +719,6 @@ class Gpt4AllWebUI(GPT4AllAPI): self.config['backend'] = backend self.config['model'] = model - self.process.set_config(self.config) self.config['personality_language'] = personality_language self.config['personality_category'] = personality_category @@ -739,7 +741,7 @@ class Gpt4AllWebUI(GPT4AllAPI): save_config(self.config, self.config_file_path) - self.process.set_config(self.config) + # Fixed missing argument 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("==============================================") - return jsonify({"status":"ok"}) + return jsonify(self.process.set_config(self.config)) def get_available_models(self): diff --git a/gpt4all_api/api.py b/gpt4all_api/api.py index 24f44506..3008bf65 100644 --- a/gpt4all_api/api.py +++ b/gpt4all_api/api.py @@ -179,8 +179,6 @@ class ModelProcess: print("Couldn't build backend.") print(ex) backend = None - self._set_config_result['backend_status'] ='failed' - self._set_config_result['errors'].append(f"couldn't build backend:{ex}") return backend def _rebuild_model(self): @@ -200,16 +198,18 @@ class ModelProcess: print("Couldn't build model") print(ex) self.model = None - self._set_config_result['model_status'] ='failed' - self._set_config_result['errors'].append(f"couldn't build model:{ex}") + self._set_config_result['status'] ='failed' + self._set_config_result['backend_status'] ='failed' + self._set_config_result['errors'].append(f"couldn't build backend:{ex}") except Exception as ex: traceback.print_exc() print("Couldn't build backend") print(ex) self.backend = None self.model = None - self._set_config_result['model_status'] ='failed' - self._set_config_result['errors'].append(f"couldn't build model:{ex}") + self._set_config_result['status'] ='failed' + self._set_config_result['backend_status'] ='failed' + self._set_config_result['errors'].append(f"couldn't build backend:{ex}") def rebuild_personality(self): try: @@ -239,8 +239,9 @@ class ModelProcess: if self.config["debug"]: print(ex) self.personality = AIPersonality() - self._set_config_result['personality_status'] ='failed' - self._set_config_result['errors'].append(f"couldn't load personality:{ex}") + self._set_config_result['status'] ='failed' + 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): self.generation_queue.put((text,self.id, message_type))