enhanced ui

This commit is contained in:
Saifeddine ALOUI 2023-11-11 22:21:40 +01:00
parent 911f2e9567
commit bb5794d475
7 changed files with 60 additions and 93 deletions

41
app.py
View File

@ -13,7 +13,7 @@ __github__ = "https://github.com/ParisNeo/lollms-webui"
__copyright__ = "Copyright 2023, "
__license__ = "Apache 2.0"
__version__ ="7.0 (Alpha)"
__version__ ="7.0 (Beta)"
main_repo = "https://github.com/ParisNeo/lollms-webui.git"
import os
@ -235,11 +235,11 @@ try:
self.add_endpoint("/reload_binding", "reload_binding", self.reload_binding, methods=["POST"])
self.add_endpoint("/restart_program", "restart_program", self.restart_program, methods=["GET"])
self.add_endpoint("/update_software", "update_software", self.update_software, methods=["GET"])
self.add_endpoint("/clear_uploads", "clear_uploads", self.clear_uploads, methods=["GET"])
self.add_endpoint("/selectdb", "selectdb", self.selectdb, methods=["GET"])
self.add_endpoint("/restart_program", "restart_program", self.restart_program, methods=["GET"])
self.add_endpoint("/check_update", "check_update", self.check_update, methods=["GET"])
@ -1640,42 +1640,6 @@ try:
ASCIIColors.error(f"Couldn't clear the upload folder.\nMaybe some files are opened somewhere else.\Try doing it manually")
return {"status": False, 'error': "Couldn't clear the upload folder.\nMaybe some files are opened somewhere else.\Try doing it manually"}
def update_software(self):
ASCIIColors.info("")
ASCIIColors.info("")
ASCIIColors.info("")
ASCIIColors.info(" ╔══════════════════════════════════════════════════╗")
ASCIIColors.info(" ║ Upgrading backend ║")
ASCIIColors.info(" ╚══════════════════════════════════════════════════╝")
ASCIIColors.info("")
ASCIIColors.info("")
ASCIIColors.info("")
# Perform a 'git pull' to check for updates
try:
# Execute 'git pull' and redirect the output to the console
process = subprocess.Popen(['git', 'pull'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
# Read and print the output in real-time
while True:
output = process.stdout.readline()
if output == '' and process.poll() is not None:
break
if output:
print(output.strip())
# Wait for the process to finish and get the return code
return_code = process.poll()
if return_code == 0:
return {"status": True}
else:
return {"status": False, 'error': f"git pull failed with return code {return_code}"}
except subprocess.CalledProcessError as ex:
# There was an error in 'git pull' command
return {"status": False, 'error': str(ex)}
def selectdb(self):
from tkinter import Tk, filedialog
# Initialize Tkinter
@ -1705,7 +1669,6 @@ try:
run_restart_script(self.args)
def update_software(self):
ASCIIColors.info("")
ASCIIColors.info("")

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-0e1cb70c.js"></script>
<link rel="stylesheet" href="/assets/index-78770f39.css">
<script type="module" crossorigin src="/assets/index-24ca9f97.js"></script>
<link rel="stylesheet" href="/assets/index-875a93ad.css">
</head>
<body>
<div id="app"></div>

View File

@ -1314,10 +1314,10 @@
v-for="(item, index) in mountedExtensions" :key="index + '-' + item.name"
ref="mountedExtensions">
<div class="group items-center flex flex-row">
<button @click.stop="onPersonalitySelected(item)">
<button @click.stop="onExtensionSelected(item)">
<img :src="bUrl + item.avatar" @error="personalityImgPlacehodler"
class="w-8 h-8 rounded-full object-fill text-red-700 border-2 active:scale-90 group-hover:border-secondary "
:class="configFile.active_personality_id == configFile.personalities.indexOf(item.full_path) ? 'border-secondary' : 'border-transparent z-0'"
:class="configFile.active_personality_id == configFile.extensions.indexOf(item.full_path) ? 'border-secondary' : 'border-transparent z-0'"
:title="item.name">
</button>
<button @click.stop="unmountExtension (item)">
@ -1878,6 +1878,9 @@ export default {
methods: {
async modelsZooToggleCollapse(){
this.mzc_collapsed = !this.mzc_collapsed
if (!this.mzc_collapsed){
this.refreshModelsZoo();
}
},
async selectSortOption(index){
this.$store.state.sort_type=index
@ -2017,6 +2020,17 @@ export default {
}
},
async restart_software() {
console.log("Posting")
const res = await this.api_get_req('restart_program')
console.log("Posting done")
if(res.status){
this.$refs.toast.showToast("Success!", 4, true)
}
else{
this.$refs.toast.showToast("Failure!", 4, false)
}
},
on_loading_text(text){
console.log("Loading text",text)
@ -2056,12 +2070,6 @@ export default {
this.extCatgArr = []
}
// this.bindingsArr.sort((a, b) => a.name.localeCompare(b.name))
// this.modelsArr.sort()
// this.persCatgArr.sort()
// this.persArr.sort()
console.log("models_zoo:")
console.log(this.models_zoo)
//await this.getPersonalitiesArr()
@ -2069,18 +2077,10 @@ export default {
this.personalitiesFiltered = this.personalities.filter((item) => item.category === this.configFile.personality_category)
// this.personalitiesFiltered.sort()
//mountedPersArr
console.log("Extensions zoo")
console.log(this.$store.state.extensionsZoo)
this.modelsFiltered = this.models_zoo
this.extension_category = this.configFile.extension_category
this.extensionsFiltererd = this.$store.state.extensionsZoo.filter((item) => item.category === this.configFile.extension_category )
console.log("Extensions filtered")
console.log(this.extensionsFiltererd)
//this.bindings = await this.api_get_req("list_bindings")
// this.bindingsArr.sort((a, b) => a.name.localeCompare(b.name))
this.isLoading = false
this.isMounted = true
@ -2314,7 +2314,6 @@ export default {
},
onSelected(model_object, force=false) {
// eslint-disable-next-line no-unused-vars
if (this.isLoading) {
this.$refs.toast.showToast("Loading... please wait", 4, false)
@ -2327,13 +2326,12 @@ export default {
console.log("update_model",res)
this.configFile.model_name = model_object.model.name
if(res.status){
this.refreshModelsZoo().then(()=>{
this.updateModelsZoo();
this.$refs.toast.showToast("Selected model:\n" + model_object.name, 4, true)
nextTick(() => {
feather.replace()
})
this.$refs.toast.showToast("Selected model:\n" + model_object.name, 4, true)
nextTick(() => {
feather.replace()
this.is_loading_zoo = false
})
self.updateModelsZoo()
}else{
this.$refs.toast.showToast("Couldn't select model:\n" + model_object.name, 4, false)
nextTick(() => {
@ -2403,7 +2401,8 @@ export default {
axios.post("/add_reference_to_local_model",{"path": this.reference_path}).then((resp)=>{
if(resp.status){
this.$refs.toast.showToast("Reference created", 4, true)
this.refreshModelsZoo().then(()=>{this.updateModelsZoo();})
this.is_loading_zoo = true;
this.refreshModelsZoo().then(()=>{this.updateModelsZoo(); this.is_loading_zoofalse;})
}
else{
this.$refs.toast.showToast("Couldn't create reference", 4, false)
@ -2538,7 +2537,8 @@ export default {
model_object.uninstalling = false;
socket.off('install_progress', progressListener);
this.showProgress = false;
this.refreshModelsZoo().then(()=>{this.updateModelsZoo();})
this.is_loading_zoo = true;
this.refreshModelsZoo().then(()=>{this.updateModelsZoo(); this.is_loading_zoo = false;})
this.modelsFiltered = this.models_zoo
this.$refs.toast.showToast("Model:\n" + model_object.model.name + "\nwas uninstalled!", 4, true)
@ -2875,17 +2875,22 @@ export default {
},
async refreshModelsZoo() {
this.models_zoo = []
console.log("refreshing models")
this.is_loading_zoo = true;
await this.$store.dispatch('refreshModelsZoo');
console.log("ModelsZoo refreshed")
await this.$store.dispatch('refreshModels');
console.log("Models refreshed")
this.updateModelsZoo()
console.log("Models updated")
this.is_loading_zoo = false;
},
async updateModelsZoo(){
let models_zoo = this.$store.state.modelsZoo
if(models_zoo.length==0)
return
console.log("loading models_zoo", models_zoo)
let index = models_zoo.findIndex(item => item.name == this.configFile.model_name)
if (index>0){
this.imgModel = models_zoo[index].icon
@ -2924,9 +2929,7 @@ export default {
}
console.log("models_zoo")
models_zoo.forEach(model => {
if (model.name == this.$store.state.config["model_name"]) {
model.selected = true;
@ -2937,8 +2940,6 @@ export default {
});
this.models_zoo = models_zoo
console.log("models_zoo")
console.log(this.models_zoo)
// Returns array of model filenames which are = to name of models zoo entry
@ -2972,7 +2973,7 @@ export default {
this.models_zoo.push(newModelEntry)
}
else{
this.models_zoo[index].isInstalled=true;
this.models_zoo[index].isInstalled=true;
}
}
this.models_zoo.sort((a, b) => {
@ -2995,8 +2996,8 @@ export default {
this.update_setting('binding_name', value, async (res) => {
console.log("updated binding_name")
await this.$store.dispatch('refreshConfig');
await this.refreshModelsZoo();
await this.updateModelsZoo();
this.models_zoo = []
this.mzc_collapsed = true;
const index = this.bindingsArr.findIndex(item => item.folder == value)
const item = this.bindingsArr[index]
if (item) {
@ -3585,7 +3586,6 @@ export default {
}, async mounted() {
console.log("Getting voices")
this.getVoices();
this.updateModelsZoo();
console.log("Constructing")
this.load_everything()
},
@ -3777,7 +3777,7 @@ export default {
},
mountedExtensions:{
get() {
return this.$store.state.config.extensions;
return this.$store.state.mountedExtensions;
},
set(value) {
this.$store.commit('setActiveExtensions', value);

View File

@ -10,6 +10,10 @@ export default async ({ mode }) => {
try {
const response = await fetch('/get_server_address'); // Replace with the actual endpoint on your Flask server
const serverAddress = await response.text();
if(serverAddress.includes('<')){
console.log(`Server address not found`)
return process.env.VITE_LOLLMS_API
}
console.log(`Server address: ${serverAddress}`)
return `${serverAddress}`; // Construct the full server address dynamically
} catch (error) {

@ -1 +1 @@
Subproject commit ba1306e8e955b8c8822f0f7f2d4a032d4e4de1d0
Subproject commit 0fbc134c58f5e8263adf2d8365646952feb40cb1