upgraded tool

This commit is contained in:
Saifeddine ALOUI 2023-09-24 01:05:03 +02:00
parent 7394d876d7
commit 251dbf76b4
8 changed files with 137 additions and 64 deletions

37
app.py
View File

@ -243,6 +243,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
self.add_endpoint("/install_model_from_path", "install_model_from_path", self.install_model_from_path, methods=["GET"])
self.add_endpoint("/unInstall_binding", "unInstall_binding", self.unInstall_binding, methods=["POST"])
self.add_endpoint("/reinstall_binding", "reinstall_binding", self.reinstall_binding, methods=["POST"])
self.add_endpoint("/reinstall_personality", "reinstall_personality", self.reinstall_personality, methods=["POST"])
@ -988,6 +989,13 @@ class LoLLMsWebUI(LoLLMsAPPI):
bnd["ui"]=text_content
else:
bnd["ui"]=None
disclaimer_file_path = f/"disclaimer.md"
if disclaimer_file_path.exists():
with disclaimer_file_path.open("r") as file:
text_content = file.read()
bnd["disclaimer"]=text_content
else:
bnd["disclaimer"]=None
icon_file = self.find_extension(self.lollms_paths.bindings_zoo_path/f"{f.name}", "logo", [".svg",".gif",".png"])
if icon_file is not None:
icon_path = Path(f"bindings/{f.name}/logo{icon_file.suffix}")
@ -1287,6 +1295,35 @@ class LoLLMsWebUI(LoLLMsAPPI):
trace_exception(ex)
return jsonify({"status":False, 'error':str(ex)})
def unInstall_binding(self):
try:
data = request.get_json()
# Further processing of the data
except Exception as e:
print(f"Error occurred while parsing JSON: {e}")
return jsonify({"status":False, 'error':str(e)})
ASCIIColors.info(f"- UnInstalling binding {data['name']}...")
try:
ASCIIColors.info("Unmounting binding and model")
self.binding = None
self.model = None
for per in self.mounted_personalities:
per.model = None
gc.collect()
ASCIIColors.info("UnInstalling binding")
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.FORCE_INSTALL)
self.binding.uninstall()
ASCIIColors.success("Binding UnInstalled successfully")
self.config.binding_name= None
if self.config.auto_save:
ASCIIColors.info("Saving configuration")
self.config.save_config()
ASCIIColors.info("Please select a binding")
return jsonify({"status": True})
except Exception as ex:
ASCIIColors.error(f"Couldn't uninstall binding: [{ex}]")
trace_exception(ex)
return jsonify({"status":False, 'error':str(ex)})
def clear_uploads(self):
ASCIIColors.info("")

File diff suppressed because one or more lines are too long

8
web/dist/assets/index-1c21f712.css vendored Normal file

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-74b12ab0.js"></script>
<link rel="stylesheet" href="/assets/index-9d0cda62.css">
<script type="module" crossorigin src="/assets/index-1b4fff03.js"></script>
<link rel="stylesheet" href="/assets/index-1c21f712.css">
</head>
<body>
<div id="app"></div>

View File

@ -56,10 +56,16 @@
<span class="sr-only">Click to install</span>
</button>
<button v-if="binding.installed" title="Click to Reinstall binding" type="button" @click.stop="toggleReinstall"
class="inline-flex items-center gap-2 px-3 py-2 text-xs font-medium text-center focus:outline-none text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 rounded-lg dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900">
Reinstall binding
class="inline-flex items-center gap-2 px-3 py-2 text-xs font-medium text-center focus:outline-none text-white bg-green-700 hover:bg-red-800 focus:ring-4 focus:ring-green-300 rounded-lg dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-red-900">
Reinstall
<span class="sr-only">Reinstall binding</span>
<span class="sr-only">Reinstall</span>
</button>
<button v-if="binding.installed" title="Click to Reinstall binding" type="button" @click.stop="toggleUnInstall"
class="inline-flex items-center gap-2 px-3 py-2 text-xs font-medium text-center focus:outline-none text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 rounded-lg dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900">
Uninstall
<span class="sr-only">UnInstall</span>
</button>
<button v-if="selected" title="Click to open Settings" type="button" @click.stop="toggleSettings"
class="inline-flex items-center gap-2 px-3 py-2 text-xs font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
@ -130,6 +136,7 @@ export default {
onSelected: Function,
onReinstall: Function,
onInstall: Function,
onUnInstall: Function,
onSettings: Function,
onReloadBinding: Function,
selected: Boolean,
@ -165,6 +172,9 @@ export default {
toggleInstall() {
this.onInstall(this)
},
toggleUnInstall() {
this.onUnInstall(this)
},
toggleReinstall() {
this.onReinstall(this)
},

View File

@ -1,6 +1,6 @@
<template>
<div
class="relative items-start p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg border-2 cursor-pointer select-none"
class="relative items-start p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg border-2 select-none"
:class="computed_classes"
:title="model.name">
<!-- CUSTOM MODEL VIEW -->
@ -31,13 +31,7 @@
</button>
Custom model
</div>
<button v-if="model.isInstalled" type="button" title="Select"
@click="toggleSelected"
class="hover:text-secondary duration-75 active:scale-90 font-medium rounded-lg text-sm p-2 text-center inline-flex items-center " @click.stop="">
<i data-feather="check" :class="selected?'border-2 border-blue-300 rounded bg-green-300 w-5':'border-2 border-blue-300 rounded bg-gray-100 w-5'"></i>
<span class="sr-only">Select</span>
</button>
<input v-model="model.selected" @click.stop="toggleSelected" type="checkbox" class='cursor-pointer border-2 border-blue-300 rounded w-10 h-10'>
<div>
<button v-if="model.isInstalled" title="Delete file from disk" type="button" @click.stop="toggleInstall"
class="inline-flex items-center gap-2 px-3 py-2 text-xs font-medium text-center focus:outline-none text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 rounded-lg dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900">
@ -117,12 +111,7 @@
<div class="grow">
<!-- EMPTY SPACE FILLER -->
</div>
<button v-if="model.isInstalled" type="button" title="Select"
@click="toggleSelected"
class="hover:text-secondary duration-75 active:scale-90 font-medium rounded-lg text-sm p-2 text-center inline-flex items-center " @click.stop="">
<i data-feather="check" :class="selected?'border-2 border-blue-300 rounded bg-green-300 w-5':'border-2 border-blue-300 rounded bg-gray-100 w-5'"></i>
<span class="sr-only">Select</span>
</button>
<input v-model="model.selected" @click.stop="toggleSelected" type="checkbox" class='cursor-pointer border-2 border-blue-300 rounded w-10 h-10'>
<InteractiveMenu :commands="commandsList" :force_position=2 title="Menu">

View File

@ -1084,6 +1084,7 @@
<BindingEntry ref="bindingZoo" v-for="(binding, index) in bindingsArr"
:key="'index-' + index + '-' + binding.folder" :binding="binding"
:on-selected="onSelectedBinding" :on-reinstall="onReinstallBinding"
:on-unInstall="onUnInstallBinding"
:on-install="onInstallBinding" :on-settings="onSettingsBinding"
:on-reload-binding="onReloadBinding"
:selected="binding.folder === configFile.binding_name">
@ -2597,10 +2598,45 @@ export default {
// return
// }
this.update_binding(binding_object.binding.folder)
if (binding_object.disclaimer){
this.$refs.yesNoDialog.askQuestion(binding_object.disclaimer, 'Proceed', 'Cancel')
if (res) {
this.update_binding(binding_object.binding.folder)
}
}
else{
this.update_binding(binding_object.binding.folder)
}
//console.log('lol',binding_object)
}
},
onUnInstallBinding(binding_object){
this.isLoading = true
axios.post('/unInstall_binding', { name: binding_object.binding.folder }).then((res) => {
if (res) {
this.isLoading = false
console.log('unInstall_binding', res)
if (res.data.status) {
this.$refs.toast.showToast("Reinstalled binding successfully!", 4, true)
} else {
this.$refs.toast.showToast("Could not reinstall binding", 4, false)
}
return res.data;
}
this.isLoading = false
binding_object.isInstalled=False
})
// eslint-disable-next-line no-unused-vars
.catch(error => {
this.isLoading = false
this.$refs.toast.showToast("Could not reinstall binding\n" + error.message, 4, false)
return { 'status': false }
});
},
onReinstallBinding(binding_object) {
this.isLoading = true
axios.post('/reinstall_binding', { name: binding_object.binding.folder }).then((res) => {