found culprit

This commit is contained in:
AndzejsP 2023-06-28 13:10:43 +03:00
parent e7dee8a58a
commit 48ccc5a982
6 changed files with 87 additions and 59 deletions

View File

@ -86,7 +86,7 @@
</button>
</div>
<div v-if="showPersonalities" class="flex items-center mx-1">
<div v-if="showPersonalities" class="container">
<MountedPersonalitiesList ref="mountedPersList" />
</div>
<!-- CHAT BOX -->

View File

@ -10,7 +10,7 @@
<img :src="bUrl + mountedPers.avatar" @error="personalityImgPlacehodler"
class="w-8 h-8 rounded-full object-fill text-red-700 border-2 active:scale-90 group-hover:border-secondary border-secondary"
:title="mountedPers.name">
:title="mountedPers.name" :key="mountedPers.key">
<div class="flex items-center justify-center w-8 h-8 cursor-pointer text-xs font-medium text-white bg-gray-700 border-2 border-white rounded-full hover:bg-gray-600 dark:border-gray-800"
@click.stop="toggleShowPersList" title="Click to show more">+{{ mountedPersArr.length - 1 }}</div>
@ -18,7 +18,7 @@
<div class="flex -space-x-4 " v-if="mountedPersArr.length == 1">
<img :src="bUrl + mountedPers.avatar" @error="personalityImgPlacehodler"
class="w-8 h-8 rounded-full object-fill text-red-700 border-2 active:scale-90 group-hover:border-secondary cursor-pointer border-secondary"
:title="mountedPers.name" @click.stop="toggleShowPersList">
:title="mountedPers.name" @click.stop="toggleShowPersList" :key="mountedPers.key">
</div>
</div>
@ -27,6 +27,7 @@
<script>
import axios from "axios";
import defaultPersonalityImgPlaceholder from "../assets/logo.svg"
import { nextTick } from "vue";
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
@ -65,13 +66,9 @@ export default {
this.onShowPersList(this)
},
async constructor() {
this.api_get_req("get_config").then((res)=>{
this.configFile =res
this.getPersonalitiesArr().then(() => {
this.getMountedPersonalities()
this.$forceUpdate()
})
})
this.configFile = await this.api_get_req("get_config")
this.getPersonalitiesArr()
let personality_path_infos = await this.api_get_req("get_current_personality_path_infos")
this.configFile.personality_language = personality_path_infos["personality_language"]
this.configFile.personality_category = personality_path_infos["personality_category"]
@ -143,7 +140,11 @@ export default {
// this.personalitiesFiltered = this.personalities.filter((item) => item.category === this.configFile.personality_category && item.language === this.configFile.personality_language)
// this.personalitiesFiltered.sort()
this.getMountedPersonalities()
nextTick(()=>{
this.$forceUpdate()
})
},
personalityImgPlacehodler(event) {
@ -385,7 +386,8 @@ export default {
console.log('fig', this.configFile.personality_category)
this.mountedPers = this.personalities[this.personalities.findIndex(item => item.full_path == this.configFile.personalities[this.configFile.active_personality_id])]
const dd = new Date()
this.mountedPers.key = dd.getTime()
},
}
}

View File

@ -7,11 +7,12 @@
<label for="model" class="block ml-2 mb-2 text-sm font-medium text-gray-900 dark:text-white">
Mounted Personalities: ({{ mountedPersArr.length }})
</label>
<div class="overflow-y-auto no-scrollbar p-2 pb-0 grid lg:grid-cols-4 md:grid-cols-2 gap-4 max-h-96">
<div class="overflow-y-auto no-scrollbar p-2 pb-0 grid lg:grid-cols-1 md:grid-cols-1 gap-4 max-h-96">
<TransitionGroup name="bounce">
<personality-entry ref="personalitiesZoo" v-for="(pers, index) in mountedPersArr"
:key="'index-' + index + '-' + pers.name" :personality="pers" :full_path="pers.full_path"
:selected="configFile.personalities[configFile.active_personality_id]==pers.full_path"
:key="'index-' + index + '-' + pers.name + new Date().getTime()" :personality="pers"
:full_path="pers.full_path"
:selected="configFile.personalities[configFile.active_personality_id] === pers.full_path"
:on-selected="onPersonalitySelected" :on-mounted="onPersonalityMounted"
:on-settings="onSettingsPersonality" />
</TransitionGroup>
@ -25,13 +26,38 @@
<UniversalForm ref="universalForm" class="z-20" />
</div>
</template>
<style scoped>
.bounce-enter-active {
animation: bounce-in 0.5s;
}
<script>
import axios from "axios";
.bounce-leave-active {
animation: bounce-in 0.5s reverse;
}
@keyframes bounce-in {
0% {
transform: scale(0);
}
50% {
transform: scale(1.25);
}
100% {
transform: scale(1);
}
}
</style>
<script >
import defaultPersonalityImgPlaceholder from "../assets/logo.svg"
import PersonalityEntry from './PersonalityEntry.vue'
import Toast from './Toast.vue'
import UniversalForm from './UniversalForm.vue';
import axios from "axios";
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
export default {
@ -46,7 +72,7 @@ export default {
UniversalForm,
},
name: 'MountedPersonalitiesList',
setup() {
data() {
return {
@ -59,7 +85,7 @@ export default {
}
},
async mounted() {
await this.constructor()
await this.constructor()
this.isMounted = true
},
async activated() {
@ -69,20 +95,18 @@ export default {
},
methods: {
async constructor() {
this.api_get_req("get_config").then((res)=>{
this.configFile=res
this.getPersonalitiesArr().then(() => {
this.getMountedPersonalities()
this.$forceUpdate()
})
})
async constructor() {
this.configFile = await this.api_get_req("get_config")
this.getPersonalitiesArr()
let personality_path_infos = await this.api_get_req("get_current_personality_path_infos")
this.configFile.personality_language = personality_path_infos["personality_language"]
this.configFile.personality_category = personality_path_infos["personality_category"]
this.configFile.personality_folder = personality_path_infos["personality_name"]
await this.getPersonalitiesArr()
this.$forceUpdate()
//await this.getPersonalitiesArr()
},
async api_get_req(endpoint) {
try {
@ -101,7 +125,7 @@ export default {
},
async getPersonalitiesArr() {
this.isLoading = true
this.personalities = []
const dictionary = await this.api_get_req("get_all_personalities")
const config = await this.api_get_req("get_config")
@ -147,10 +171,10 @@ export default {
this.personalitiesFiltered = this.personalities.filter((item) => item.category === this.configFile.personality_category && item.language === this.configFile.personality_language)
this.personalitiesFiltered.sort()
this.isLoading = false
// this.getMountedPersonalities()
// this.$forceUpdate()
this.getMountedPersonalities()
this.$forceUpdate()
},
personalityImgPlacehodler(event) {
@ -175,14 +199,11 @@ export default {
}
this.isLoading = true
this.$forceUpdate()
},
async onPersonalitySelected(pers) {
// eslint-disable-next-line no-unused-vars
if (this.isLoading) {
this.$refs.toast.showToast("Loading... please wait", 4, false)
}
this.isLoading = true
console.log('ppa', pers)
if (pers) {
@ -192,7 +213,7 @@ export default {
}
this.settingsChanged = true
if (pers.isMounted) {
@ -202,7 +223,7 @@ export default {
await this.constructor()
this.$refs.toast.showToast("Selected personality:\n" + pers.name, 4, true)
console.log('ssss', this.configFile)
}
}
@ -213,15 +234,15 @@ export default {
}
this.isLoading = false
}
},
onSettingsPersonality(persEntry) {
try {
this.isLoading = true
axios.get('/get_active_personality_settings').then(res => {
this.isLoading = false
if (res) {
console.log('pers sett', res)
@ -240,27 +261,27 @@ export default {
} else {
this.$refs.toast.showToast("Did not get Personality settings responses.\n" + response, 4, false)
this.isLoading = false
}
})
} catch (error) {
this.$refs.toast.showToast("Did not get Personality settings responses.\n Endpoint error: " + error.message, 4, false)
this.isLoading = false
}
})
} else {
this.$refs.toast.showToast("Personality has no settings", 4, false)
this.isLoading = false
}
}
})
} catch (error) {
this.isLoading = false
this.$refs.toast.showToast("Could not open personality settings. Endpoint error: " + error.message, 4, false)
}
@ -298,11 +319,12 @@ export default {
try {
this.isLoading = true
const res = await axios.post('/unmount_personality', obj);
this.isLoading = false
if (res) {
this.$forceUpdate()
return res.data
}
} catch (error) {
@ -330,6 +352,7 @@ export default {
this.configFile.personality_language = personality_path_infos["personality_language"]
this.configFile.personality_category = personality_path_infos["personality_category"]
this.configFile.personality_folder = personality_path_infos["personality_name"]
this.$forceUpdate()
return res.data
}
@ -340,7 +363,7 @@ export default {
},
async mountPersonality(pers) {
this.isLoading = true
console.log('mount pers', pers)
if (!pers) { return }
@ -367,11 +390,11 @@ export default {
pers.isMounted = false
this.$refs.toast.showToast("Could not mount personality\nError: " + res.error, 4, false)
}
this.isLoading = false
},
async unmountPersonality(pers) {
this.isLoading = true
if (!pers) { return }
const res = await this.unmount_personality(pers.personality || pers)
@ -396,7 +419,7 @@ export default {
this.$refs.personalitiesZoo[persIdZoo].isMounted = false
}
this.$forceUpdate()
//pers.isMounted = false
this.getMountedPersonalities()
@ -416,7 +439,7 @@ export default {
this.$refs.toast.showToast("Could not unmount personality\nError: " + res.error, 4, false)
}
this.isLoading = false
},
getMountedPersonalities() {

View File

@ -1,7 +1,7 @@
<template>
<div
class=" items-start p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg border-2 cursor-pointer active:scale-95 duration-75 select-none"
@click.stop="toggleSelected" :class="selected ? 'border-primary-light' : 'border-transparent'"
class=" min-w-96 items-start p-4 hover:bg-primary-light rounded-lg mb-2 shadow-lg border-2 cursor-pointer active:scale-95 duration-75 select-none"
@click.stop="toggleSelected" :class="selected_computed ? 'border-primary-light' : 'border-transparent'"
:title="!personality.installed ? 'Not installed' : ''">
<div :class="!personality.installed ? 'opacity-50' : ''">
@ -24,7 +24,7 @@
<i data-feather="slash" class="w-5"></i>
<span class="sr-only">Not installed</span>
</button>
<button v-if="selected" type="button" title="Settings"
<button v-if="selected_computed" type="button" title="Settings"
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="toggleSettings">
<i data-feather="sliders" class="w-5"></i>
@ -112,7 +112,9 @@ export default {
})
},
computed: {
selected_computed(){
return this.selected
}
},
methods: {
getImgUrl() {

View File

@ -12,7 +12,7 @@ const store = createStore({
state () {
return {
// count: 0,
mountedPersonalities: {},
mountedPersonalities: [],
settingsChanged:false
}
},

View File

@ -1291,7 +1291,7 @@ export default {
if (pers.isMounted && this.configFile.personalities.includes(pers.personality.full_path)) {
const res = await this.select_personality(pers)
console.log('pers is mounted',res)
if (res && res.status && res.active_personality_id > -1) {
this.$refs.toast.showToast("Selected personality:\n" + pers.name, 4, true)
@ -1301,6 +1301,7 @@ export default {
this.isLoading = false
} else {
console.log('mounting pers')
this.onPersonalityMounted(pers)
}