This commit is contained in:
saloui 2023-09-28 15:56:41 +02:00
parent 9327c49c98
commit 2c15c559a1
7 changed files with 92 additions and 76 deletions

6
app.py
View File

@ -610,6 +610,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
return jsonify({"personality":self.personality.as_dict()})
def get_all_personalities(self):
ASCIIColors.yellow("Listing all personalities")
personalities_folder = self.lollms_paths.personalities_zoo_path
personalities = {}
@ -1025,7 +1026,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
try:
models = self.binding.list_models(self.config)
index = models.index(self.config.model_name)
ASCIIColors.yellow("Listing models")
ASCIIColors.yellow("Listing active models")
return jsonify({"model":models[index],"index":index})
except Exception as ex:
return jsonify(None)
@ -1040,8 +1041,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
def list_personalities(self):
category = request.args.get('category')
if not category:
return jsonify([])
return jsonify([])
try:
personalities_dir = self.lollms_paths.personalities_zoo_path/f'{category}' # replace with the actual path to the models folder
personalities = [f.stem for f in personalities_dir.iterdir() if f.is_dir() and not f.name.startswith(".")]

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-210a2834.js"></script>
<link rel="stylesheet" href="/assets/index-5acc5bc6.css">
<script type="module" crossorigin src="/assets/index-a5d4fd66.js"></script>
<link rel="stylesheet" href="/assets/index-5e4931f7.css">
</head>
<body>
<div id="app"></div>

View File

@ -87,9 +87,11 @@ import PersonalityEntry from './PersonalityEntry.vue'
import Toast from './Toast.vue'
import UniversalForm from './UniversalForm.vue';
import feather from 'feather-icons'
import {logObjectProperties} from "../main.js"
import axios from "axios";
import { nextTick } from "vue";
import markdownItAttrs from "markdown-it-attrs";
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_LOLLMS_API_BASEURL
@ -239,17 +241,14 @@ export default {
async onPersonalitySelected(pers) {
// eslint-disable-next-line no-unused-vars
feather.replace()
console.log('ppa', pers)
console.log('Selected personality : ', JSON.stringify(pers.personality))
if (pers) {
if (pers.selected) {
this.$refs.toast.showToast("Personality already selected", 4, true)
return
}
if (pers.isMounted) {
const res = await this.select_personality(pers)
if (res) {
if (res.status) {
@ -389,33 +388,37 @@ export default {
},
async select_personality(pers) {
if (!pers) { return { 'status': false, 'error': 'no personality - select_personality' } }
const id = this.configFile.personalities.findIndex(item => item === pers.full_path || item === pers.full_path+':'+pers.language)
console.log('id', JSON.stringify(id))
const obj = {
id: id
}
try {
const res = await axios.post('/select_personality', obj);
if (res) {
this.$store.dispatch('refreshConfig').then(() => {
console.log("recovered config", this.configFile.active_personality_id);
this.$store.dispatch('refreshPersonalitiesArr').then(() => {
this.$store.dispatch('refreshMountedPersonalities');
});
});
return res.data
const id = this.configFile.personalities.findIndex(item => item === pers.full_path || item.split(':')[0] === pers.full_path)
if(id>-1){
console.log('Selecting personality with id:', JSON.stringify(id))
const obj = {
id: id
}
} catch (error) {
console.log(error, 'select_personality - settings')
return
}
try {
const res = await axios.post('/select_personality', obj);
if (res) {
this.$store.dispatch('refreshConfig').then(() => {
console.log("recovered config", this.configFile.active_personality_id);
this.$store.dispatch('refreshPersonalitiesArr').then(() => {
this.$store.dispatch('refreshMountedPersonalities');
});
});
return res.data
}
} catch (error) {
console.log(error, 'select_personality - settings')
return
}
}
else{
console.log('Personalituy id is wrong')
this.$refs.toast.showToast("Personality id is wrong!", 4, false)
return { 'status': false, 'error': 'Personality id is wrong' }
}
},
async mountPersonality(pers) {

View File

@ -196,13 +196,15 @@ export const store = createStore({
if(this.state.config.active_personality_id<0){
this.state.config.active_personality_id=0;
}
let mountedPersArr = []
// console.log('perrs listo',this.state.personalities)
for (let i = 0; i < this.state.config.personalities.length; i++) {
const full_path_item = this.state.config.personalities[i]
const index = this.state.personalities.findIndex(item => item.full_path == full_path_item || item.full_path+':'+item.language == full_path_item)
let mountedPersArr = []
// console.log('perrs listo',this.state.personalities)
for (let i = 0; i < this.state.config.personalities.length; i++) {
const full_path_item = this.state.config.personalities[i]
const index = this.state.personalities.findIndex(item => item.full_path == full_path_item || item.full_path+':'+item.language == full_path_item)
if(index>=0){
const pers = this.state.personalities[index]
console.log("Found personality : ", JSON.stringify(pers))
// console.log(`Personality : ${JSON.stringify(pers)}`)
if (pers) {
mountedPersArr.push(pers)
@ -210,12 +212,16 @@ export const store = createStore({
else {
mountedPersArr.push(this.state.personalities[this.state.personalities.findIndex(item => item.full_path == "generic/lollms")])
}
}
commit('setMountedPersArr', mountedPersArr);
this.state.mountedPers = this.state.personalities[this.state.personalities.findIndex(item => item.full_path == this.state.config.personalities[this.state.config.active_personality_id] || item.full_path+':'+item.language ==this.state.config.personalities[this.state.config.active_personality_id])]
// console.log(`${this.state.config.personalities[this.state.config.active_personality_id]}`)
// console.log(`Mounted personality: ${this.state.mountedPers}`)
}
else{
console.log("Couldn't load personality : ",full_path_item)
}
}
commit('setMountedPersArr', mountedPersArr);
this.state.mountedPers = this.state.personalities[this.state.personalities.findIndex(item => item.full_path == this.state.config.personalities[this.state.config.active_personality_id] || item.full_path+':'+item.language ==this.state.config.personalities[this.state.config.active_personality_id])]
// console.log(`${this.state.config.personalities[this.state.config.active_personality_id]}`)
// console.log(`Mounted personality: ${this.state.mountedPers}`)
},
async refreshBindings({ commit }) {
let bindingsArr = await api_get_req("list_bindings")
@ -394,15 +400,7 @@ export const store = createStore({
console.log(error.message, 'fetchModels');
this.state.refreshingModelsList=false;
});
},
fetchCustomModels({ commit }) {
axios.get('/list_models')
.then(response => {
})
.catch(error => {
console.log(error.message, 'fetchCustomModels');
});
},
},
}
})
async function api_get_req(endpoint) {
@ -429,18 +427,17 @@ app.mixin({
console.log("recovered config : ${}");
await this.$store.dispatch('getVersion');
console.log("recovered version");
await this.$store.dispatch('refreshPersonalitiesArr')
this.$store.dispatch('refreshMountedPersonalities');
this.$store.dispatch('refreshBindings');
this.$store.dispatch('refreshModels');
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('refreshPersonalitiesArr')
this.$store.dispatch('refreshMountedPersonalities');
this.$store.state.ready = true
console.log("done loading data")
@ -451,7 +448,26 @@ app.mixin({
beforeMount() {
}
})
function logObjectProperties(obj) {
if (typeof obj !== 'object' || obj === null) {
console.log('Invalid object');
return;
}
let logString = "Object parameters and values:\n";
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key) && typeof obj[key] !== 'function') {
logString += `${key}: ${obj[key]}\n`;
}
}
console.log(logString);
}
app.use(router)
app.use(store)
app.mount('#app')
export{logObjectProperties}

View File

@ -1971,7 +1971,7 @@ export default {
methods: {
async selectSortOption(index){
this.$store.state.sort_type=index
this.$store.dispatch('refreshModelsZoo');
//this.$store.dispatch('refreshModelsZoo');
this.modelsFiltered = this.models
console.log(`Selected sorting:${index}`)
},
@ -2876,9 +2876,6 @@ export default {
console.log("updating binding_name")
this.update_setting('binding_name', value, (res) => {
console.log("updated binding_name")
this.$store.dispatch('refreshModels');
const index = this.bindingsArr.findIndex(item => item.folder == value)
const item = this.bindingsArr[index]
if (item) {