This commit is contained in:
Saifeddine ALOUI 2023-06-23 02:02:37 +02:00
parent ec1b743988
commit 9d22a7b95f
6 changed files with 67 additions and 56 deletions

View File

@ -153,6 +153,12 @@ class LoLLMsAPPI():
def disconnect():
ASCIIColors.error(f'Client {request.sid} disconnected')
@socketio.on('cancel_generation')
def cancel_generation():
self.cancel_gen = True
ASCIIColors.error(f'Client {request.sid} canceled generation')
@socketio.on('install_model')
def install_model(data):
room_id = request.sid
@ -209,6 +215,7 @@ class LoLLMsAPPI():
file.save(save_path)
# File saved successfully
socketio.emit('progress', {'status':True, 'progress': 100})
else:
# Personality doesn't support file sending
socketio.emit('progress', {'status':False, 'error': "Personality doesn't support file sending"})
@ -239,7 +246,7 @@ class LoLLMsAPPI():
ASCIIColors.green("Starting message generation by"+self.personality.name)
task = self.socketio.start_background_task(self.start_message_generation, message, message_id)
ASCIIColors.info("Started generation task")
#tpe = threading.Thread(target=self.start_message_generation, args=(message, message_id))
#tpe.start()
else:

47
app.py
View File

@ -76,8 +76,6 @@ class LoLLMsWebUI(LoLLMsAPPI):
self.app = _app
self.cancel_gen = False
self.binding_changed = False
self.model_changed = False
app.template_folder = "web/dist"
if config["active_personality_id"]>=len(config["personalities"]):
@ -317,11 +315,11 @@ class LoLLMsWebUI(LoLLMsAPPI):
personalities = {}
for language_folder in personalities_folder.iterdir():
lang = language_folder.stem
if language_folder.is_dir():
if language_folder.is_dir() and not language_folder.stem.startswith('.'):
personalities[language_folder.name] = {}
for category_folder in language_folder.iterdir():
cat = category_folder.stem
if category_folder.is_dir():
if category_folder.is_dir() and not category_folder.stem.startswith('.'):
personalities[language_folder.name][category_folder.name] = []
for personality_folder in category_folder.iterdir():
pers = personality_folder.stem
@ -329,11 +327,13 @@ class LoLLMsWebUI(LoLLMsAPPI):
personality_info = {"folder":personality_folder.stem}
config_path = personality_folder / 'config.yaml'
if not config_path.exists():
"""
try:
shutil.rmtree(str(config_path.parent))
ASCIIColors.warning(f"Deleted useless personality: {config_path.parent}")
except Exception as ex:
ASCIIColors.warning(f"Couldn't delete personality ({ex})")
"""
continue
try:
with open(config_path) as config_file:
@ -483,14 +483,30 @@ class LoLLMsWebUI(LoLLMsAPPI):
elif setting_name== "model_name":
self.config["model_name"]=data['setting_value']
self.model_changed = True
try:
self.binding.build_model()
except Exception as ex:
print(f"Couldn't load model: [{ex}]")
return jsonify({ "status":False, 'error':str(ex)})
print("update_settings : New model selected")
elif setting_name== "binding_name":
if self.config['binding_name']!= data['setting_value']:
print(f"New binding selected : {data['setting_value']}")
self.config["binding_name"]=data['setting_value']
self.binding_changed = True
try:
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths)
try:
self.binding.build_model()
except Exception as ex:
print(f"Couldn't load model: [{ex}]")
return jsonify({ "status":False, 'error':str(ex)})
except Exception as ex:
print(f"Couldn't build binding: [{ex}]")
return jsonify({"status":False, 'error':str(ex)})
else:
if self.config["debug"]:
print(f"Configuration {data['setting_name']} set to {data['setting_value']}")
@ -512,25 +528,6 @@ class LoLLMsWebUI(LoLLMsAPPI):
def apply_settings(self):
ASCIIColors.success("OK")
if self.binding_changed:
try:
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths)
try:
self.binding.build_model()
except Exception as ex:
print(f"Couldn't load model: [{ex}]")
return jsonify({ "status":False, 'error':str(ex)})
except Exception as ex:
print(f"Couldn't build binding: [{ex}]")
return jsonify({"status":False, 'error':str(ex)})
else:
if self.model_changed:
try:
self.binding.build_model()
except Exception as ex:
print(f"Couldn't load model: [{ex}]")
return jsonify({ "status":False, 'error':str(ex)})
self.rebuild_personalities()
return jsonify({"status":True})

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
web/dist/index.html vendored
View File

@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI - Welcome</title>
<script type="module" crossorigin src="/assets/index-067e1b5a.js"></script>
<link rel="stylesheet" href="/assets/index-4a05d245.css">
<script type="module" crossorigin src="/assets/index-21ad23f2.js"></script>
<link rel="stylesheet" href="/assets/index-97886d16.css">
</head>
<body>
<div id="app"></div>

View File

@ -373,8 +373,11 @@ export default {
return {}
}
},
async stop_gen() {
try {
socket.emit('cancel_generation', {});
const res = await axios.get('/stop_gen')
if (res) {