new version 6.6

This commit is contained in:
Saifeddine ALOUI 2023-10-02 02:18:57 +02:00
parent 09a345a14e
commit 42550cb526
10 changed files with 178 additions and 161 deletions

View File

@ -522,8 +522,8 @@ class LoLLMsAPPI(LollmsApplication):
ASCIIColors.error(f'Client {request.sid} requested cancelling generation')
terminate_thread(self.connections[client_id]['generation_thread'])
ASCIIColors.error(f'Client {request.sid} canceled generation')
self.cancel_gen = False
self.busy=False
@socketio.on('get_personality_files')
def get_personality_files(data):
client_id = request.sid
@ -591,7 +591,6 @@ class LoLLMsAPPI(LollmsApplication):
)
self.close_message(client_id)
@self.socketio.on('cancel_text_generation')
def cancel_text_generation(data):
client_id = request.sid
@ -628,6 +627,7 @@ class LoLLMsAPPI(LollmsApplication):
@self.socketio.on('generate_text')
def handle_generate_text(data):
client_id = request.sid
self.cancel_gen = False
ASCIIColors.info(f"Text generation requested by client: {client_id}")
if self.busy:
self.socketio.emit("busy", {"message":"I am busy. Come back later."}, room=client_id)
@ -782,12 +782,10 @@ class LoLLMsAPPI(LollmsApplication):
# Start the text generation task in a separate thread
task = self.socketio.start_background_task(target=generate_text)
@socketio.on('generate_msg')
def generate_msg(data):
client_id = request.sid
self.cancel_gen = False
self.connections[client_id]["generated_text"]=""
self.connections[client_id]["cancel_generation"]=False
self.connections[client_id]["continuing"]=False
@ -833,6 +831,7 @@ class LoLLMsAPPI(LollmsApplication):
@socketio.on('generate_msg_from')
def generate_msg_from(data):
client_id = request.sid
self.cancel_gen = False
self.connections[client_id]["continuing"]=False
self.connections[client_id]["first_chunk"]=True
@ -853,6 +852,7 @@ class LoLLMsAPPI(LollmsApplication):
@socketio.on('continue_generate_msg_from')
def handle_connection(data):
client_id = request.sid
self.cancel_gen = False
self.connections[client_id]["continuing"]=True
self.connections[client_id]["first_chunk"]=True

2
app.py
View File

@ -14,7 +14,7 @@ __github__ = "https://github.com/ParisNeo/lollms-webui"
__copyright__ = "Copyright 2023, "
__license__ = "Apache 2.0"
__version__ ="6.5"
__version__ ="6.6"
main_repo = "https://github.com/ParisNeo/lollms-webui.git"
import os

1
mPLUG-Owl Submodule

@ -0,0 +1 @@
Subproject commit 7f1d5f8148a0c9ea224548dfe0a72a823cdd2eae

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-fa3b8c0d.js"></script>
<link rel="stylesheet" href="/assets/index-c6ea07c5.css">
<script type="module" crossorigin src="/assets/index-95fccc16.js"></script>
<link rel="stylesheet" href="/assets/index-d3bc1609.css">
</head>
<body>
<div id="app"></div>

View File

@ -41,25 +41,18 @@ export default {
},
computed: {
formattedJson() {
console.log(typeof this.jsonData)
if (typeof this.jsonData==='string'){
let jsonData = JSON.stringify(JSON.parse(this.jsonData), null, '\t').replace(/\n/g, '<br>')
console.log(jsonData)
console.log(this.jsonFormText)
return jsonData;
}
else{
let jsonData = JSON.stringify(this.jsonData, null, '\t').replace(/\n/g, '<br>')
console.log(jsonData)
console.log(this.jsonFormText)
return jsonData;
}
},
isObject() {
console.log(typeof this.jsonData)
console.log(this.jsonData)
return typeof this.jsonData === 'object' && this.jsonData !== null;
},
isContentPresent() {

View File

@ -45,6 +45,9 @@ export const store = createStore({
}
},
mutations: {
setIsReady(state, ready) {
state.ready = ready;
},
setIsConnected(state, isConnected) {
state.isConnected = isConnected;
},
@ -208,6 +211,8 @@ export const store = createStore({
}
let mountedPersArr = []
// console.log('perrs listo',this.state.personalities)
const indicesToRemove = [];
console.log("Personalities", this.state.personalities)
for (let i = 0; i < this.state.config.personalities.length; i++) {
const full_path_item = this.state.config.personalities[i]
const parts = full_path_item.split(':')
@ -226,9 +231,21 @@ export const store = createStore({
}
}
else{
indicesToRemove.push(i)
console.log("Couldn't load personality : ",full_path_item)
}
}
// Remove the broken personalities using the collected indices
for (let i = indicesToRemove.length - 1; i >= 0; i--) {
console.log("Removing personality : ",this.state.config.personalities[indicesToRemove[i]])
this.state.config.personalities.splice(indicesToRemove[i], 1);
if(this.state.config.active_personality_id>indicesToRemove[i]){
this.state.config.active_personality_id -= 1;
}
}
console.log("Personalities", this.state.personalities)
console.log("Mounted personalities : ", mountedPersArr)
commit('setMountedPersArr', mountedPersArr);
@ -250,6 +267,50 @@ export const store = createStore({
}
commit('setModelsArr',modelsArr)
// Returns array of model filenames which are = to name of models zoo entry
for (let i = 0; i < this.state.modelsArr.length; i++) {
const customModel = this.state.modelsArr[i]
let index = this.state.models_zoo.findIndex(x => x.name == customModel)
if(index==-1){
// The customModel is not directly in the model zoo, so check its variants
for (let j = 0; j < this.state.models_zoo.length; j++) {
let v = this.state.models_zoo[j]["variants"]
if(v!=undefined){
index = v.findIndex(x => x.name == customModel);
if(index!=-1){
index=j
console.log(`Found ${customModel} at index ${index}`)
break;
}
}
else{
}
}
}
if (index == -1) {
let newModelEntry = {}
newModelEntry.name = customModel
newModelEntry.icon = ""
newModelEntry.isCustomModel = true
newModelEntry.isInstalled = true
this.state.models_zoo.push(newModelEntry)
}
else{
this.state.models_zoo[index].isInstalled=true;
}
}
this.state.models_zoo.sort((a, b) => {
if (a.isInstalled && !b.isInstalled) {
return -1; // a is installed, b is not installed, so a comes first
} else if (!a.isInstalled && b.isInstalled) {
return 1; // b is installed, a is not installed, so b comes first
} else {
return 0; // both models are either installed or not installed, maintain their original order
}
});
},
async refreshExtensionsZoo({ commit }) {
let extensionsZoo = await api_get_req("list_extensions")
@ -317,15 +378,12 @@ export const store = createStore({
},
async refreshModelsZoo({ commit }) {
console.log(`REFRESHING models using sorting ${this.state.sort_type}`)
this.state.refreshingModelsList=true;
axios.get('/get_available_models')
.then(response => {
console.log("HERE WE GO")
const response = await axios.get('/get_available_models');
let models_zoo = response.data
models_zoo = models_zoo.filter(model => model.variants && model.variants.length>0);
console.log("models_zoo")
console.log(models_zoo)
console.log(`REFRESHING models using sorting ${this.state.sort_type}`)
if(models_zoo.length>1){
if(this.state.sort_type==0){ // Sort by date
models_zoo.sort((a, b) => {
const dateA = new Date(a.last_commit_time);
@ -334,6 +392,7 @@ export const store = createStore({
// Compare the date objects to sort by last_commit_time
return dateB - dateA;
});
console.log("Sorted")
} else if(this.state.sort_type==1){ // Sort by rank
models_zoo.sort((a, b) => {
// Compare the date objects to sort by last_commit_time
@ -346,54 +405,15 @@ export const store = createStore({
models_zoo.sort((a, b) => a.name.localeCompare(b.name))
}
// models_zoo.sort((a, b) => a.name.localeCompare(b.name))
// Returns array of model filenames which are = to name of models zoo entry
for (let i = 0; i < this.state.modelsArr.length; i++) {
const customModel = this.state.modelsArr[i]
let index = models_zoo.findIndex(x => x.name == customModel)
if(index==-1){
// The customModel is not directly in the model zoo, so check its variants
for (let j = 0; j < models_zoo.length; j++) {
let v = models_zoo[j]["variants"]
if(v!=undefined){
index = v.findIndex(x => x.name == customModel);
if(index!=-1){
index=j
console.log(`Found ${customModel} at index ${index}`)
break;
}
console.log("Sorted")
}
else{
}
console.log("No sorting needed");
}
}
if (index == -1) {
let newModelEntry = {}
newModelEntry.name = customModel
newModelEntry.icon = ""
newModelEntry.isCustomModel = true
newModelEntry.isInstalled = true
models_zoo.push(newModelEntry)
}
else{
models_zoo[index].isInstalled=true;
}
}
console.log("models_zoo")
models_zoo.sort((a, b) => {
if (a.isInstalled && !b.isInstalled) {
return -1; // a is installed, b is not installed, so a comes first
} else if (!a.isInstalled && b.isInstalled) {
return 1; // b is installed, a is not installed, so b comes first
} else {
return 0; // both models are either installed or not installed, maintain their original order
}
});
models_zoo.forEach(model => {
if (model.name == this.state.config["model_name"]) {
@ -403,17 +423,12 @@ export const store = createStore({
model.selected = false;
}
});
console.log("models_zoo")
console.log(models_zoo)
commit('setModelsZoo', models_zoo)
this.state.refreshingModelsList=false;
})
.catch(error => {
console.log(error.message, 'fetchModels');
this.state.refreshingModelsList=false;
});
},
console.log("models_zoo")
console.log(this.state.models_zoo)
}
}
})
async function api_get_req(endpoint) {
@ -432,29 +447,28 @@ async function api_get_req(endpoint) {
let actionsExecuted = false;
app.mixin({
created() {
async created() {
if (!actionsExecuted) {
actionsExecuted = true;
console.log("Calling")
this.$store.dispatch('refreshConfig').then(async () => {
await this.$store.dispatch('refreshConfig');
console.log("recovered config : ${}");
await this.$store.dispatch('getVersion');
console.log("recovered version");
this.$store.dispatch('refreshBindings');
await this.$store.dispatch('refreshBindings');
this.$store.dispatch('refreshDiskUsage');
this.$store.dispatch('refreshRamUsage');
this.$store.dispatch('refreshVramUsage');
this.$store.dispatch('refreshModelsZoo');
this.$store.dispatch('refreshExtensionsZoo');
this.$store.dispatch('refreshModels');
await this.$store.dispatch('refreshDiskUsage');
await this.$store.dispatch('refreshRamUsage');
await this.$store.dispatch('refreshVramUsage');
await this.$store.dispatch('refreshExtensionsZoo');
await this.$store.dispatch('refreshModelsZoo');
await this.$store.dispatch('refreshModels');
await this.$store.dispatch('refreshPersonalitiesZoo')
this.$store.dispatch('refreshMountedPersonalities');
this.$store.state.ready = true
await this.$store.dispatch('refreshMountedPersonalities');
this.$store.state.ready = true;
console.log("store status = ", this.$store.state.ready);
console.log("done loading data")
});
}
},

View File

@ -1585,7 +1585,9 @@ export default {
console.log("Waiting to be ready")
while (this.$store.state.ready === false) {
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
console.log(this.$store.state.ready)
}
console.log("Ready")
// Constructor
this.setPageTitle()
await this.list_discussions()

View File

@ -1465,7 +1465,7 @@
:class="configFile.active_personality_id == configFile.personalities.indexOf(item.full_path) ? 'border-secondary' : 'border-transparent z-0'"
:title="item.name">
</button>
<button @click.stop="onPersonalityMount(item)">
<button @click.stop="unmountPersonality (item)">
<span
class="hidden group-hover:block top-0 left-7 absolute active:scale-90 bg-bg-light dark:bg-bg-dark rounded-full border-2 border-transparent"
@ -2120,10 +2120,10 @@ export default {
nextTick(() => {
feather.replace()
})
while (this.$store.state.ready === false) {
while (this.isReady === false) {
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
}
console.log("Ready")
if (this.configFile.model_name) {
this.isModelSelected = true
}
@ -2407,7 +2407,10 @@ 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.$store.dispatch('refreshModelsZoo').then(resp=>{
this.$store.dispatch('refreshModels');
console.log("Models refreshed")
});
}
else{
this.$refs.toast.showToast("Couldn't create reference", 4, false)
@ -2542,7 +2545,11 @@ export default {
model_object.uninstalling = false;
socket.off('install_progress', progressListener);
this.showProgress = false;
this.$store.dispatch('refreshModelsZoo');
this.$store.dispatch('refreshModelsZoo').then(resp=>{
this.$store.dispatch('refreshModels');
console.log("Models refreshed")
});
this.modelsFiltered = this.models
this.$refs.toast.showToast("Model:\n" + model_object.model.name + "\nwas uninstalled!", 4, true)
this.$store.dispatch('refreshDiskUsage');
@ -2578,13 +2585,6 @@ export default {
return
}
if (this.configFile.binding_name != binding_object.binding.folder) {
// disabled for now
// if (binding_object.binding.folder === 'backend_template' || binding_object.binding.folder === 'binding_template') {
// this.$refs.toast.showToast("Cannot select template", 4, false)
// return
// }
this.update_binding(binding_object.binding.folder)
}
},
@ -2891,13 +2891,14 @@ export default {
console.log("updated model")
this.configFile.model_name = null
this.$store.dispatch('refreshConfig');
this.$store.dispatch('refreshModelsZoo');
this.$refs.toast.showToast("Binding changed.", 4, true)
this.$forceUpdate();
this.$store.dispatch('refreshModelsZoo').then(resp=>{
this.$store.dispatch('refreshModels');
console.log("Models refreshed")
});
//this.fetchMainConfig();
//this.fetchBindings();
//this.fetchModels();
this.$forceUpdate();
this.$refs.toast.showToast("Binding changed.", 4, true)
});
nextTick(() => {
feather.replace()
@ -3323,6 +3324,12 @@ export default {
}
},
computed: {
isReady:{
get() {
return this.$store.state.ready;
},
},
isModelsLoading:{
get() {
return this.$store.state.isModelsLoading;