mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-18 20:17:50 +00:00
Upgraded
This commit is contained in:
parent
328b9f6d2e
commit
7a9ccac548
@ -1480,11 +1480,17 @@ class LoLLMsAPI(LollmsApplication):
|
||||
|
||||
|
||||
|
||||
def notify(self, content, status=True, duration=4, client_id=None):
|
||||
def notify(self, content, status=True, duration=4, client_id=None, notification_type=0):
|
||||
"""
|
||||
notification type is:
|
||||
0 : suddle
|
||||
1 : Critical (shows a message box )
|
||||
"""
|
||||
self.socketio.emit('notification', {
|
||||
'content': content,# self.connections[client_id]["generated_text"],
|
||||
'status': status,
|
||||
"duration": duration
|
||||
"duration": duration,
|
||||
'notification_type':notification_type
|
||||
}, room=client_id
|
||||
)
|
||||
|
||||
|
121
app.py
121
app.py
@ -269,6 +269,7 @@ try:
|
||||
|
||||
self.add_endpoint("/install_model_from_path", "install_model_from_path", self.install_model_from_path, methods=["GET"])
|
||||
|
||||
self.add_endpoint("/install_binding", "install_binding", self.install_binding, methods=["POST"])
|
||||
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"])
|
||||
@ -917,6 +918,32 @@ try:
|
||||
elif setting_name== "override_personality_model_parameters":
|
||||
self.config["override_personality_model_parameters"]=bool(data['setting_value'])
|
||||
|
||||
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']
|
||||
try:
|
||||
if self.binding:
|
||||
self.binding.destroy_model()
|
||||
self.binding = None
|
||||
self.model = None
|
||||
for per in self.mounted_personalities:
|
||||
per.model = None
|
||||
gc.collect()
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.INSTALL_IF_NECESSARY, self.notify)
|
||||
self.model = None
|
||||
self.config.save_config()
|
||||
ASCIIColors.green("Binding loaded successfully")
|
||||
except Exception as ex:
|
||||
ASCIIColors.error(f"Couldn't build binding: [{ex}]")
|
||||
trace_exception(ex)
|
||||
return jsonify({"status":False, 'error':str(ex)})
|
||||
else:
|
||||
if self.config["debug"]:
|
||||
print(f"Configuration {data['setting_name']} set to {data['setting_value']}")
|
||||
return jsonify({'setting_name': data['setting_name'], "status":True})
|
||||
|
||||
|
||||
elif setting_name == "model_name":
|
||||
ASCIIColors.yellow(f"Changing model to: {data['setting_value']}")
|
||||
self.config["model_name"]=data['setting_value']
|
||||
@ -933,30 +960,6 @@ try:
|
||||
except Exception as ex:
|
||||
self.notify("It looks like you we couldn't load the model.\nThis can hapen when you don't have enough VRAM. Please restart the program.",False,30)
|
||||
|
||||
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']
|
||||
try:
|
||||
if self.binding:
|
||||
self.binding.destroy_model()
|
||||
self.binding = None
|
||||
self.model = None
|
||||
for per in self.mounted_personalities:
|
||||
per.model = None
|
||||
gc.collect()
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, self.notify)
|
||||
self.model = None
|
||||
self.config.save_config()
|
||||
ASCIIColors.green("Model loaded successfully")
|
||||
except Exception as ex:
|
||||
ASCIIColors.error(f"Couldn't build binding: [{ex}]")
|
||||
trace_exception(ex)
|
||||
return jsonify({"status":False, 'error':str(ex)})
|
||||
else:
|
||||
if self.config["debug"]:
|
||||
print(f"Configuration {data['setting_name']} set to {data['setting_value']}")
|
||||
return jsonify({'setting_name': data['setting_name'], "status":True})
|
||||
|
||||
else:
|
||||
if data['setting_name'] in self.config.config.keys():
|
||||
@ -1264,10 +1267,10 @@ try:
|
||||
save_db=True
|
||||
)
|
||||
ASCIIColors.yellow("1- Exporting discussions")
|
||||
self.notify("Exporting discussions",True, None)
|
||||
self.notify("Exporting discussions")
|
||||
discussions = self.db.export_all_as_markdown_list_for_vectorization()
|
||||
ASCIIColors.yellow("2- Adding discussions to vectorizer")
|
||||
self.notify("Adding discussions to vectorizer",True, None)
|
||||
self.notify("Adding discussions to vectorizer")
|
||||
index = 0
|
||||
nb_discussions = len(discussions)
|
||||
|
||||
@ -1557,6 +1560,35 @@ try:
|
||||
else:
|
||||
return jsonify({})
|
||||
|
||||
def install_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"- Reinstalling binding {data['name']}...")
|
||||
try:
|
||||
ASCIIColors.info("Unmounting binding and model")
|
||||
ASCIIColors.info("Reinstalling binding")
|
||||
old_bn = self.config.binding_name
|
||||
self.config.binding_name = data['name']
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.FORCE_INSTALL, self.notify)
|
||||
ASCIIColors.success("Binding reinstalled successfully")
|
||||
self.notify("Please reboot the application so that the binding installation can be taken into consideration",True, 30, notification_type=1)
|
||||
del self.binding
|
||||
self.binding = None
|
||||
self.config.binding_name = old_bn
|
||||
if old_bn is not None:
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, self.notify)
|
||||
self.model = self.binding.build_model()
|
||||
for per in self.mounted_personalities:
|
||||
per.model = self.model
|
||||
return jsonify({"status": True})
|
||||
except Exception as ex:
|
||||
ASCIIColors.error(f"Couldn't build binding: [{ex}]")
|
||||
trace_exception(ex)
|
||||
return jsonify({"status":False, 'error':str(ex)})
|
||||
|
||||
def reinstall_binding(self):
|
||||
try:
|
||||
@ -1568,8 +1600,7 @@ try:
|
||||
ASCIIColors.info(f"- Reinstalling binding {data['name']}...")
|
||||
try:
|
||||
ASCIIColors.info("Unmounting binding and model")
|
||||
GG = AdvancedGarbageCollector()
|
||||
GG.safeHardCollect("binding", self)
|
||||
del self.binding
|
||||
self.binding = None
|
||||
gc.collect()
|
||||
ASCIIColors.info("Reinstalling binding")
|
||||
@ -1577,7 +1608,7 @@ try:
|
||||
self.config.binding_name = data['name']
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.FORCE_INSTALL, self.notify)
|
||||
ASCIIColors.success("Binding reinstalled successfully")
|
||||
self.notify("<b>Please reboot the application so that the binding installation</b>",True, 30)
|
||||
self.notify("Please reboot the application so that the binding installation can be taken into consideration",True, 30, 1)
|
||||
self.config.binding_name = old_bn
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, self.notify)
|
||||
self.model = self.binding.build_model()
|
||||
@ -1596,26 +1627,28 @@ try:
|
||||
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']}...")
|
||||
ASCIIColors.info(f"- Reinstalling 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.notify)
|
||||
if self.binding is not None:
|
||||
del self.binding
|
||||
self.binding = None
|
||||
gc.collect()
|
||||
ASCIIColors.info("Uninstalling binding")
|
||||
old_bn = self.config.binding_name
|
||||
self.config.binding_name = data['name']
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, InstallOption.NEVER_INSTALL, self.notify)
|
||||
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")
|
||||
ASCIIColors.green("Uninstalled successful")
|
||||
if old_bn!=self.config.binding_name:
|
||||
self.config.binding_name = old_bn
|
||||
self.binding = BindingBuilder().build_binding(self.config, self.lollms_paths, self.notify)
|
||||
self.model = self.binding.build_model()
|
||||
for per in self.mounted_personalities:
|
||||
per.model = self.model
|
||||
return jsonify({"status": True})
|
||||
except Exception as ex:
|
||||
ASCIIColors.error(f"Couldn't uninstall binding: [{ex}]")
|
||||
ASCIIColors.error(f"Couldn't build binding: [{ex}]")
|
||||
trace_exception(ex)
|
||||
return jsonify({"status":False, 'error':str(ex)})
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 8388d197d2b72a42f270761fd4ba9fd7b757e321
|
||||
Subproject commit dfb5470d8d63927de91d0589229712290e13a6e4
|
@ -1 +1 @@
|
||||
Subproject commit 425f7614df835e6bb9d01e8be1ea45593beb9b3a
|
||||
Subproject commit 65236d13731c2d890073979dfae0d934dfa5e7d5
|
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
4
web/dist/index.html
vendored
@ -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-db4abb7a.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-ad7cb3e8.css">
|
||||
<script type="module" crossorigin src="/assets/index-86f0c808.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index-cb75143a.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -373,10 +373,10 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
host:"",
|
||||
progress_visibility_val : true,
|
||||
progress_value : 0,
|
||||
// To be synced with the backend database types
|
||||
msgTypes: {
|
||||
progress_visibility_val : true,
|
||||
progress_value : 0,
|
||||
// Messaging
|
||||
MSG_TYPE_CHUNK : 0, // A chunk of a message (used for classical chat)
|
||||
MSG_TYPE_FULL : 1, // A full message (for some personality the answer is sent in bulk)
|
||||
@ -1197,8 +1197,13 @@ export default {
|
||||
nextTick(() => {
|
||||
const msgList = document.getElementById('messages-list')
|
||||
this.scrollBottom(msgList)
|
||||
})
|
||||
this.$refs.toast.showToast(notif.content, notif.duration, notif.status)
|
||||
})
|
||||
if(notif.notification_type==0){
|
||||
this.$refs.toast.showToast(notif.content, notif.duration, notif.status)
|
||||
}
|
||||
else if(notif.notification_type==1){
|
||||
this.$refs.messageBox.showMessage(notif.content)
|
||||
}
|
||||
this.chime.play()
|
||||
},
|
||||
streamMessageContent(msgObj) {
|
||||
|
@ -1757,7 +1757,7 @@ import YesNoDialog from "@/components/YesNoDialog.vue";
|
||||
import Toast from '../components/Toast.vue'
|
||||
import ModelEntry from '@/components/ModelEntry.vue';
|
||||
import PersonalityViewer from '@/components/PersonalityViewer.vue';
|
||||
import PersonalityEntry from "../components/PersonalityEntry.vue";
|
||||
import PersonalityEntry from "@/components/PersonalityEntry.vue";
|
||||
import BindingEntry from "../components/BindingEntry.vue";
|
||||
import socket from '@/services/websocket.js'
|
||||
import defaultModelImgPlaceholder from "../assets/default_model.png"
|
||||
@ -1884,10 +1884,23 @@ export default {
|
||||
async created() {
|
||||
socket.on('loading_text',this.on_loading_text);
|
||||
this.updateHasUpdates();
|
||||
socket.on('notification', this.notify)
|
||||
//await socket.on('install_progress', this.progressListener);
|
||||
//refreshHardwareUsage()
|
||||
},
|
||||
methods: {
|
||||
notify(notif){
|
||||
nextTick(() => {
|
||||
const msgList = document.getElementById('messages-list')
|
||||
this.scrollBottom(msgList)
|
||||
})
|
||||
if(notif.notification_type==0){
|
||||
this.$refs.toast.showToast(notif.content, notif.duration, notif.status)
|
||||
}
|
||||
else if(notif.notification_type==1){
|
||||
this.$refs.messageBox.showMessage(notif.content)
|
||||
}
|
||||
},
|
||||
load_more_models(){
|
||||
if(this.models_zoo_initialLoadCount+10<this.models_zoo.length){
|
||||
this.models_zoo_initialLoadCount+=10
|
||||
@ -2623,30 +2636,63 @@ export default {
|
||||
|
||||
// return
|
||||
// }
|
||||
this.isLoading = true
|
||||
|
||||
if (binding_object.disclaimer){
|
||||
this.$refs.yesNoDialog.askQuestion(binding_object.disclaimer, 'Proceed', 'Cancel')
|
||||
if (res) {
|
||||
this.update_binding(binding_object.binding.folder)
|
||||
}
|
||||
}
|
||||
axios.post('/install_binding', { name: binding_object.binding.folder }).then((res) => {
|
||||
|
||||
if (res) {
|
||||
this.isLoading = false
|
||||
console.log('install_binding', res)
|
||||
if (res.data.status) {
|
||||
this.$refs.toast.showToast("Installed binding successfully!", 4, true)
|
||||
this.update_binding(binding_object.binding.folder);
|
||||
} else {
|
||||
this.$refs.toast.showToast("Could not reinstall binding", 4, false)
|
||||
}
|
||||
this.isLoading = false
|
||||
|
||||
return res.data;
|
||||
}
|
||||
else{
|
||||
this.update_binding(binding_object.binding.folder)
|
||||
}
|
||||
//console.log('lol',binding_object)
|
||||
this.isLoading = 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 }
|
||||
}); //console.log('lol',binding_object)
|
||||
}
|
||||
else{
|
||||
this.update_binding(binding_object.binding.folder);
|
||||
}
|
||||
},
|
||||
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)
|
||||
const index = this.bindingsZoo.findIndex(item => item.folder == binding_object.binding.folder)
|
||||
const item = this.bindingsZoo[index]
|
||||
if (item) {
|
||||
item.installed = true
|
||||
}
|
||||
else{
|
||||
item.installed = false
|
||||
}
|
||||
|
||||
this.settingsChanged = true
|
||||
|
||||
this.binding_changed = true;
|
||||
this.$refs.toast.showToast("Binding uninstalled successfully!", 4, true)
|
||||
} else {
|
||||
this.$refs.toast.showToast("Could not reinstall binding", 4, false)
|
||||
this.$refs.toast.showToast("Could not uninstall binding", 4, false)
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
@ -2658,7 +2704,7 @@ export default {
|
||||
|
||||
.catch(error => {
|
||||
this.isLoading = false
|
||||
this.$refs.toast.showToast("Could not reinstall binding\n" + error.message, 4, false)
|
||||
this.$refs.toast.showToast("Could not uninstall binding\n" + error.message, 4, false)
|
||||
return { 'status': false }
|
||||
});
|
||||
},
|
||||
@ -2890,7 +2936,7 @@ export default {
|
||||
this.isLoading = false
|
||||
console.log('update_setting', res)
|
||||
if(res['status']){
|
||||
this.$refs.toast.showToast("Setting updated successfully.\nDon't forget to save to keep the setting permanently.", 4, true)
|
||||
this.$refs.toast.showToast("Setting updated successfully.\n", 4, true)
|
||||
}
|
||||
else{
|
||||
this.$refs.toast.showToast("Setting update failed.\nPlease view the console for more details.", 4, false)
|
||||
@ -3033,6 +3079,9 @@ export default {
|
||||
if (item) {
|
||||
item.installed = true
|
||||
}
|
||||
else{
|
||||
item.installed = false
|
||||
}
|
||||
|
||||
this.settingsChanged = true
|
||||
this.isLoading = false
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 8978a42f56eba0e3df8edf429ae5d30a400363fd
|
||||
Subproject commit 3a251d29f9939f4693a4282f7e97d98fa740ebee
|
Loading…
Reference in New Issue
Block a user