Merge branch 'main' into small-fixes

This commit is contained in:
AndzejsP 2023-05-24 17:44:51 +03:00
commit c4cb9dc9bd
2 changed files with 17 additions and 10 deletions

21
app.py
View File

@ -683,15 +683,18 @@ class Gpt4AllWebUI(GPT4AllAPI):
print("New backend selected") print("New backend selected")
self.config['backend'] = backend self.config['backend'] = backend
backend_ =self.process.load_backend(config["backend"]) try:
models = backend_.list_models(self.config) backend_ =self.process.load_backend(config["backend"],True)
if len(models)>0: models = backend_.list_models(self.config)
self.backend = backend_ if len(models)>0:
self.config['model'] = models[0] self.backend = backend_
# Build chatbot self.config['model'] = models[0]
return jsonify(self.process.set_config(self.config)) # Build chatbot
else: return jsonify(self.process.set_config(self.config))
return jsonify({"status": "no_models_found"}) else:
return jsonify({"status": "no_models_found"})
except :
return jsonify({"status": "failed"})
return jsonify({"status": "error"}) return jsonify({"status": "error"})

View File

@ -155,6 +155,10 @@ class ModelProcess:
self.model = model_path self.model = model_path
def set_config(self, config): def set_config(self, config):
try:
self.set_config_result_queue.get_nowait()
except:
pass
self.set_config_queue.put(config) self.set_config_queue.put(config)
# Wait for it t o be consumed # Wait for it t o be consumed
while self.set_config_result_queue.empty(): while self.set_config_result_queue.empty():