upgraded webui

This commit is contained in:
Saifeddine ALOUI 2023-07-10 22:01:20 +02:00
parent 9892504163
commit 1a2479d9d6
8 changed files with 461 additions and 339 deletions

View File

@ -109,7 +109,7 @@
<MountedPersonalities ref="mountedPers" :onShowPersList="onShowPersListFun" :onReady="onPersonalitiesReadyFun"/>
<!-- :onShowPersList="onShowPersListFun" -->
</div>
<div class="w-fit">
<div class="w-6">
<PersonalitiesCommands
v-if="personalities_ready"
:commandsList="this.$store.state.mountedPersArr[this.$store.state.config.active_personality_id].commands"

View File

@ -44,6 +44,8 @@ import { useStore } from 'vuex'; // Import the useStore function
import { computed } from 'vue'; // Import the computed function
import { watch, ref } from 'vue';
import feather from 'feather-icons'
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
@ -82,29 +84,24 @@ export default {
this.onShowPersList()
},
async constructor() {
const store = useStore();
this.configFile = store.state.config
console.log('configFile')
console.log(this.configFile)
await new Promise((resolve) => {
const waitForPersonalities = setInterval(() => {
if (store.state.personalities) {
clearInterval(waitForPersonalities);
resolve();
}
}, 100);
});
this.personalities = store.state.personalities
nextTick(() => {
feather.replace()
})
while (this.$store.state.personalities === null) {
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
}
this.configFile = this.$store.state.config
this.personalities = this.$store.state.personalities
console.log('personalities')
console.log(this.personalities)
let personality_path_infos = store.state.config.personalities[store.state.config.active_personality_id]
let personality_path_infos = this.$store.state.config.personalities[this.$store.state.config.active_personality_id].split('/')
console.log('personality_path_infos')
console.log(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"];
this.mountedPersArr = store.state.mountedPersArr
this.configFile.personality_language = personality_path_infos[0];
this.configFile.personality_category = personality_path_infos[1];
this.configFile.personality_folder = personality_path_infos[2];
this.mountedPersArr = this.$store.state.mountedPersArr
console.log(this.mountedPersArr);
console.log("Ready")
this.onReady();
@ -133,8 +130,11 @@ export default {
async getPersonalitiesArr() {
this.personalities = []
const dictionary = await this.api_get_req("get_all_personalities")
const config = await this.api_get_req("get_config")
while (this.$store.state.ready === false) {
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
}
const dictionary = this.$store.state.personalities
const config = this.$store.state.config
//this.configFile=config
//console.log('asdas',config)
// console.log("all_personalities")
@ -175,8 +175,6 @@ export default {
this.personalities.sort((a, b) => a.name.localeCompare(b.name))
this.getMountedPersonalities()
nextTick(()=>{

View File

@ -79,7 +79,7 @@ import defaultPersonalityImgPlaceholder from "../assets/logo.svg"
import PersonalityEntry from './PersonalityEntry.vue'
import Toast from './Toast.vue'
import UniversalForm from './UniversalForm.vue';
import feather from 'feather-icons'
import axios from "axios";
@ -144,7 +144,7 @@ export default {
console.log('personalities')
console.log(this.personalities)
let personality_path_infos = store.state.config.personalities[store.state.config.active_personality_id]
let personality_path_infos = this.$store.state.config.personalities[this.$store.state.config.active_personality_id]
console.log('personality_path_infos')
console.log(personality_path_infos)
this.configFile.personality_language = personality_path_infos["personality_language"];

View File

@ -1,5 +1,5 @@
<template>
<div class="container flex flex-col sm:flex-row item-center gap-2 py-1 ">
<div v-if="$store.state.ready" class="container flex flex-col sm:flex-row item-center gap-2 py-1 ">
<div class="items-center justify-between w-full flex-row md:w-auto md:order-1">
<ul class="flex flex-row font-medium p-0 mt-4 space-x-8 ">
@ -43,6 +43,7 @@
import { nextTick } from 'vue'
import feather from 'feather-icons'
import { RouterLink } from 'vue-router'
import { store } from '../main';
</script>

View File

@ -1,10 +1,10 @@
<template>
<div class="menu relative">
<div class="commands-menu-items-wrapper">
<button id="commands-menu" @click.prevent="toggleMenu" class="menu-button bg-blue-500 text-white dark:bg-blue-200 dark:text-gray-800 rounded-full flex items-center justify-center w-12 h-12 border-none cursor-pointer hover:bg-blue-400">
<i data-feather="command" class="w-6 h-6"></i>
<button id="commands-menu" @click.prevent="toggleMenu" class="menu-button bg-blue-500 text-white dark:bg-blue-200 dark:text-gray-800 rounded-full flex items-center justify-center w-6 h-6 border-none cursor-pointer hover:bg-blue-400 w-8 h-8 rounded-full object-fill text-red-700 border-2 active:scale-90 hover:z-20 hover:-translate-y-2 duration-150 border-gray-300 border-secondary cursor-pointer">
<i data-feather="command" class="w-5 h-5"></i>
</button>
<div v-if="showMenu" id="commands-menu-items" class="absolute mt-4 bg-white border border-gray-300 z-10">
<div v-if="showMenu" id="commands-menu-items" class="absolute mb-4 bg-white border border-gray-300 z-10 w-fit">
<button v-for="command in commands" :key="command.value" @click.prevent="execute_cmd(command.value)" class="menu-button py-2 px-4 cursor-pointer bg-blue-500 text-white dark:bg-blue-200 dark:text-gray-800 hover:bg-blue-400" :class="{ 'bg-blue-400 text-white': hoveredCommand === command.value }" :title="command.help" @mouseover="hoveredCommand = command.value" @mouseout="hoveredCommand = null">
{{ command.name }}
</button>
@ -50,7 +50,21 @@ data() {
commands: [],
};
},
async mounted() {
//this.fileSize = await this.getFileSize(this.model.path)
//console.log('model path', this.model.path)
nextTick(() => {
feather.replace()
})
},
methods: {
async constructor() {
nextTick(() => {
feather.replace()
})
},
toggleMenu() {
this.showMenu = !this.showMenu;
},
@ -58,18 +72,7 @@ methods: {
this.showMenu = !this.showMenu;
this.sendCommand(cmd);
},
showHelp(command) {
this.showHelpText = true;
this.helpText = command.help;
},
sendCommand(value) {
// Implement your send_command function here
console.log('Sending command:', value);
},
executeCommand(value) {
this.sendCommand(value);
this.$emit('command-executed', value);
},
handleClickOutside(event) {
const menuElement = this.$el.querySelector('.commands-menu-items-wrapper');
if (menuElement && !menuElement.contains(event.target)) {

View File

@ -14,15 +14,26 @@ export const store = createStore({
state () {
return {
// count: 0,
mountedPersonalities: [],
ready:false,
settingsChanged:false,
isConnected: false, // Add the isConnected property
config:null,
mountedPers:null,
bindingsArr:null,
modelsArr:null,
models_zoo:null,
personalities:null,
diskUsage:null,
ramUsage:null,
vramUsage:null,
}
},
mutations: {
setIsConnected(state, isConnected) {
state.isConnected = isConnected;
},
setConfig(state, config) {
state.config = config;
},
@ -32,21 +43,60 @@ export const store = createStore({
setMountedPers(state, mountedPers) {
state.mountedPers = mountedPers;
},
setBindingsArr(state, bindingsArr) {
state.bindingsArr = bindingsArr;
},
setModelsArr(state, modelsArr) {
state.modelsArr = modelsArr;
},
setDiskUsage(state, diskUsage) {
state.diskUsage = diskUsage;
},
setRamUsage(state, ramUsage) {
state.ramUsage = ramUsage;
},
setVramUsage(state, vramUsage) {
state.vramUsage = vramUsage;
},
setModelsZoo(state, modelsZoo) {
state.models_zoo = modelsZoo;
},
// increment (state) {
// state.count++
// }
},
getters: {
getConfig(state) {
return state.config
},
getIsConnected(state) {
return state.isConnected
},
getConfig(state) {
return state.config
},
getPersonalities(state) {
return state.personalities;
},
getMountedPers(state) {
return state.mountedPers;
}
},
getbindingsArr(state) {
return state.bindingsArr;
},
getModelsArr(state) {
return state.modelsArr;
},
getDiskUsage(state) {
return state.diskUsage;
},
getRamUsage(state) {
return state.ramUsage;
},
getVramUsage(state) {
return state.vramUsage;
},
getModelsZoo(state) {
return state.models_zoo;
},
},
actions: {
async refreshConfig({ commit }) {
@ -64,11 +114,8 @@ export const store = createStore({
},
async refreshPersonalitiesArr({ commit }) {
let personalities = []
console.log("Getting personalities 0")
const dictionary = await api_get_req("get_all_personalities")
console.log("Getting personalities 2")
const langkeys = Object.keys(dictionary); // returns languages folder names
console.log("Getting personalities 3")
for (let i = 0; i < langkeys.length; i++) {
const langkey = langkeys[i];
const catdictionary = dictionary[langkey];
@ -101,12 +148,12 @@ export const store = createStore({
}
}
console.log("Getting personalities 3")
personalities.sort((a, b) => a.name.localeCompare(b.name))
commit('setPersonalities',personalities)
this.state
commit('setPersonalities', personalities);
console.log("Done")
console.log("Done loading personalities")
},
refreshMountedPersonalities({ commit }) {
let mountedPersArr = []
@ -131,6 +178,139 @@ export const store = createStore({
this.state.mountedPers = this.state.personalities[this.state.personalities.findIndex(item => item.full_path == this.state.config.personalities[this.state.config.active_personality_id])]
},
async refreshBindings({ commit }) {
let bindingsArr = await api_get_req("list_bindings")
commit('setBindingsArr',bindingsArr)
},
async refreshModels({ commit }) {
let modelsArr = await api_get_req("list_models")
commit('setModelsArr',modelsArr)
},
async refreshDiskUsage({ commit }) {
this.state.diskUsage = await api_get_req("disk_usage")
},
async refreshRamUsage({ commit }) {
this.state.ramUsage = await api_get_req("ram_usage")
},
async refreshVramUsage({ commit }) {
console.log("getting gpu data")
const resp = await api_get_req("vram_usage")
// {
// "gpu_0_total_vram": 11811160064,
// "gpu_0_used_vram": 3177185280,
// "nb_gpus": 1
// }
const gpuArr = []
if (resp.nb_gpus > 0) {
// Get keys
const keys = Object.keys(resp)
// for each gpu
for (let i = 0; i < resp.nb_gpus; i++) {
const total_vram = resp[`gpu_${i}_total_vram`];
const used_vram = resp[`gpu_${i}_used_vram`];
const model = resp[`gpu_${i}_model`];
const percentage = (used_vram / total_vram) * 100
const available_space = total_vram - used_vram
gpuArr.push({
total_vram: total_vram,
used_vram: used_vram,
gpu_index: i,
gpu_model: model,
percentage: percentage.toFixed(2),
available_space: available_space
});
}
const result = {
"nb_gpus": resp.nb_gpus,
"gpus": gpuArr
}
console.log('gpu usage: ',result)
this.state.vramUsage = result
}
else{
const result = {
"nb_gpus": 0,
"gpus": []
}
console.log('gpu usage: ',result)
this.state.vramUsage = result
}
},
async refreshModelsZoo({ commit }) {
console.log("Refreshing models zoo")
axios.get('/get_available_models')
.then(response => {
console.log("found models")
let models_zoo = response.data
models_zoo.sort((a, b) => a.title.localeCompare(b.title))
// Returns array of model filenames which are = to title of models zoo entry
for (let i = 0; i < this.state.modelsArr.length; i++) {
const customModel = this.state.modelsArr[i]
const index = models_zoo.findIndex(x => x.title == customModel)
if (index == -1) {
let newModelEntry = {}
newModelEntry.title = customModel
newModelEntry.path = customModel
newModelEntry.icon = ""
newModelEntry.isCustomModel = true
newModelEntry.isInstalled = true
models_zoo.push(newModelEntry)
}
}
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.title == this.state.config["model_name"]) {
model.selected = true;
}
else{
model.selected = false;
}
});
commit('setModelsZoo',models_zoo)
console.log("Models zoo loaded successfully")
})
.catch(error => {
console.log(error.message, 'fetchModels');
});
},
fetchCustomModels({ commit }) {
axios.get('/list_models')
.then(response => {
})
.catch(error => {
console.log(error.message, 'fetchCustomModels');
});
},
}
})
async function api_get_req(endpoint) {
@ -149,21 +329,33 @@ async function api_get_req(endpoint) {
let actionsExecuted = false;
app.mixin({
beforeMount() {
created() {
if (!actionsExecuted) {
actionsExecuted = true;
console.log("Calling")
this.$store.dispatch('refreshConfig').then(() => {
this.$store.dispatch('refreshPersonalitiesArr').then(() => {
this.$store.dispatch('refreshMountedPersonalities');
this.$store.dispatch('refreshPersonalityPath');
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.state.ready = true
console.log("done loading data")
});
});
}
},
beforeMount() {
}
})
app.use(router)
app.use(store)
app.mount('#app')
app.mount('#app')

View File

@ -1,6 +1,29 @@
<template>
<div
class="relative flex flex-col no-scrollbar shadow-lg min-w-[24rem] max-w-[24rem] bg-bg-light-tone dark:bg-bg-dark-tone">
<transition name="fade-and-fly">
<div v-if="!$store.state.ready" class="fixed top-0 left-0 w-screen h-screen flex items-center justify-center">
<!-- SPINNER -->
<div role="status" class="text-center flex items-center">
<svg aria-hidden="true" class="w-6 h-6 animate-spin fill-secondary" viewBox="0 0 100 101"
fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor" />
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill" />
</svg>
<span class="text-2xl font-bold ml-4">Loading...</span>
</div>
</div>
</transition>
<button v-if="this.$store.state.ready" @click="togglePanel" class="absolute top-0 left-0 z-50 p-2 m-2 bg-white rounded-full shadow-md">
<div v-show="panelCollapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!panelCollapsed" ><i data-feather='chevron-left'></i></div>
</button>
<transition name="slide-right">
<div v-if="showPanel"
class="relative flex flex-col no-scrollbar shadow-lg min-w-[24rem] max-w-[24rem] bg-bg-light-tone dark:bg-bg-dark-tone"
>
<!-- LEFT SIDE PANEL -->
<div id="leftPanel" class="flex flex-col flex-grow overflow-y-scroll no-scrollbar "
@dragover.stop.prevent="setDropZoneDiscussion()">
@ -158,7 +181,8 @@
</div>
</div>
</div>
<div class="relative flex flex-col flex-grow " @dragover.stop.prevent="setDropZoneChat()">
</transition>
<div v-if="this.$store.state.ready===true" class="relative flex flex-col flex-grow " @dragover.stop.prevent="setDropZoneChat()">
<div class="z-20 h-max">
<DragDrop ref="dragdropChat" @panelDrop="setFileListChat"></DragDrop>
</div>
@ -203,6 +227,49 @@
<style scoped>
.slide-right-enter-active {
transition: transform 0.3s ease;
}
.slide-right-leave-active {
transition: transform 0.3s ease;
}
.slide-right-enter,
.slide-right-leave-to {
transform: translateX(-100%);
}
.fade-and-fly-enter-active {
animation: fade-and-fly-enter 0.5s ease;
}
.fade-and-fly-leave-active {
animation: fade-and-fly-leave 0.5s ease;
}
@keyframes fade-and-fly-enter {
0% {
opacity: 0;
transform: translateY(20px) scale(0.8);
}
100% {
opacity: 1;
transform: translateY(0) scale(1);
}
}
@keyframes fade-and-fly-leave {
0% {
opacity: 1;
transform: translateY(0) scale(1);
}
100% {
opacity: 0;
transform: translateY(-20px) scale(1.2);
}
}
/* THESE ARE FOR TransitionGroup components */
.list-move,
/* apply transition to moving elements */
@ -280,10 +347,14 @@ export default {
personalityAvatars: [], // object array of personality name: and avatar: props
fileList: [],
isDragOverDiscussion: false,
isDragOverChat: false
isDragOverChat: false,
panelCollapsed: false // left panel collapse
}
},
methods: {
togglePanel() {
this.panelCollapsed = !this.panelCollapsed;
},
socketIOConnected() {
console.log("socketIOConnected")
this.$store.state.isConnected=true;
@ -1196,35 +1267,10 @@ export default {
},
async getPersonalityAvatars() {
let personalities = []
const dictionary = await this.api_get_req("get_all_personalities")
const langkeys = Object.keys(dictionary); // returns languages folder names
for (let i = 0; i < langkeys.length; i++) {
const langkey = langkeys[i];
const catdictionary = dictionary[langkey];
const catkeys = Object.keys(catdictionary); // returns categories
for (let j = 0; j < catkeys.length; j++) {
const catkey = catkeys[j];
const personalitiesArray = catdictionary[catkey];
const modPersArr = personalitiesArray.map((item) => {
let newItem = {}
newItem = item
newItem.category = catkey // add new props to items
newItem.language = langkey // add new props to items
return newItem
})
if (personalities.length == 0) {
personalities = modPersArr
} else {
personalities = personalities.concat(modPersArr)
}
}
}
while (this.$store.state.personalities === null) {
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
}
let personalities = this.$store.state.personalities
this.personalityAvatars = personalities.map(item => {
const newItem = {
@ -1233,8 +1279,6 @@ export default {
}
return newItem
})
},
getAvatar(sender) {
const index = this.personalityAvatars.findIndex((x) => x.name === sender)
@ -1300,9 +1344,6 @@ export default {
},
async created() {
// Constructor
this.setPageTitle()
await this.list_discussions()
@ -1388,6 +1429,9 @@ export default {
},
computed: {
showPanel() {
return this.$store.state.ready && !this.panelCollapsed;
},
socketConnected() {
console.log(" --- > Websocket connected")
this.$store.state.isConnected=true;// ('setConnectionStatus', true);

View File

@ -66,7 +66,9 @@
<div class="flex flex-row p-3">
<button @click.stop="sc_collapsed = !sc_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 w-full text-left flex flex-row items-center ">
<i data-feather="chevron-right" class="mr-2 flex-shrink-0"></i>
<div v-show="sc_collapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!sc_collapsed" ><i data-feather='chevron-down'></i></div>
<h3 class="text-lg font-semibold cursor-pointer select-none mr-2">
System status</h3>
@ -213,7 +215,7 @@
id="path1182" />
</svg>
<h3 class="font-bold font-large text-lg">
<div>{{ item.used_vram }} / {{ item.total_vram }} ({{ item.percentage }}%)
<div>{{ computedFileSize(item.used_vram) }} / {{ computedFileSize(item.total_vram) }} ({{ item.percentage }}%)
</div>
</h3>
</div>
@ -518,7 +520,8 @@
<div class="flex flex-row p-3">
<button @click.stop="bzc_collapsed = !bzc_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 w-full text-left flex flex-row items-center">
<i data-feather="chevron-right" class="mr-2 flex-shrink-0"></i>
<div v-show="bzc_collapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!bzc_collapsed" ><i data-feather='chevron-down'></i></div>
<h3 class="text-lg font-semibold cursor-pointer select-none mr-2">
Binding zoo</h3>
@ -544,14 +547,14 @@
</div>
<div :class="{ 'hidden': bzc_collapsed }" class="flex flex-col mb-2 px-3 pb-0">
<div v-if="bindings.length > 0" class="mb-2">
<div v-if="bindingsArr.length > 0" class="mb-2">
<label for="binding" class="block ml-2 mb-2 text-sm font-medium text-gray-900 dark:text-white">
Bindings: ({{ bindings.length }})
Bindings: ({{ bindingsArr.length }})
</label>
<div class="overflow-y-auto no-scrollbar p-2 pb-0 grid lg:grid-cols-3 md:grid-cols-2 gap-4"
:class="bzl_collapsed ? '' : 'max-h-96'">
<TransitionGroup name="list">
<BindingEntry ref="bindingZoo" v-for="(binding, index) in bindings"
<BindingEntry ref="bindingZoo" v-for="(binding, index) in bindingsArr"
:key="'index-' + index + '-' + binding.folder" :binding="binding"
:on-selected="onSelectedBinding" :on-reinstall="onReinstallBinding"
:on-install="onInstallBinding" :on-settings="onSettingsBinding"
@ -583,7 +586,9 @@
<div class="flex flex-row p-3">
<button @click.stop="mzc_collapsed = !mzc_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 w-full text-left flex items-center">
<i :data-feather="mzc_collapsed ? 'chevron-right' : 'chevron-down'" class="mr-2 flex-shrink-0"></i>
<div v-show="mzc_collapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!mzc_collapsed" ><i data-feather='chevron-down'></i></div>
<h3 class="text-lg font-semibold cursor-pointer select-none mr-2">
Models zoo</h3>
<div class="flex flex-row items-center">
@ -730,7 +735,8 @@
<div class="flex flex-row p-3">
<button @click.stop="mzdc_collapsed = !mzdc_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 w-full text-left flex items-center">
<i :data-feather="mzdc_collapsed ? 'chevron-right' : 'chevron-down'" class="mr-2 flex-shrink-0"></i>
<div v-show="mzdc_collapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!mzdc_collapsed" ><i data-feather='chevron-down'></i></div>
<h3 class="text-lg font-semibold cursor-pointer select-none mr-2">
Add models for binding</h3>
<div v-if="!configFile.binding_name" class="text-base text-red-600 flex gap-3 items-center mr-2">
@ -872,7 +878,8 @@
<div class="flex flex-row p-3 items-center">
<button @click.stop="pzc_collapsed = !pzc_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 text-left w-full flex items-center">
<i :data-feather="pzc_collapsed ? 'chevron-right' : 'chevron-down'" class="mr-2 flex-shrink-0 "></i>
<div v-show="pzc_collapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!pzc_collapsed" ><i data-feather='chevron-down'></i></div>
<h3 class="text-lg font-semibold cursor-pointer select-none mr-2">
Personalities zoo</h3>
@ -1047,7 +1054,8 @@
<div class="flex flex-row">
<button @click.stop="mc_collapsed = !mc_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 w-full text-left flex items-center">
<i :data-feather="mc_collapsed ? 'chevron-right' : 'chevron-down'" class="mr-2"></i>
<div v-show="mc_collapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!mc_collapsed" ><i data-feather='chevron-down'></i></div>
<h3 class="text-lg font-semibold cursor-pointer select-none">
Model Configuration</h3>
</button>
@ -1294,6 +1302,8 @@ import socket from '@/services/websocket.js'
import defaultModelImgPlaceholder from "../assets/default_model.png"
import defaultPersonalityImgPlaceholder from "../assets/logo.svg"
import defaultImgPlaceholder from "../assets/default_model.png"
import AddModelDialog from "@/components/AddModelDialog.vue";
import UniversalForm from '../components/UniversalForm.vue';
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
@ -1318,11 +1328,8 @@ export default {
addModelDialogVisibility: false,
modelPath: '',
// Zoo stuff
models: [],
personalities: [],
personalitiesFiltered: [],
modelsFiltered: [],
bindings: [],
// Accordeon stuff
collapsedArr: [],
all_collapsed: true,
@ -1339,21 +1346,15 @@ export default {
pzl_collapsed: false,
bzl_collapsed: false,
// Settings stuff
bindingsArr: [],
modelsArr: [], // not used anymore but still have references in some methods
persLangArr: [],
persCatgArr: [],
persArr: [],
langArr: [],
configFile: {},
showConfirmation: false,
showToast: false,
isLoading: false,
settingsChanged: false,
isModelSelected: false,
diskUsage: {},
ramUsage: {},
vramUsage: {},
mountedPersArr: [],
isMounted: false, // Needed to wait for $refs to be rendered
bUrl: bUrl, // for personality images
@ -1379,11 +1380,13 @@ export default {
this.isLoading = true
nextTick(() => {
feather.replace()
})
while (this.$store.state.ready === false) {
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
}
this.configFile = await this.api_get_req("get_config")
let personality_path_infos = await this.api_get_req("get_current_personality_path_infos")
let personality_path_infos = this.configFile.personalities[this.configFile.active_personality_id]
//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"]
@ -1392,17 +1395,11 @@ export default {
if (this.configFile.model_name) {
this.isModelSelected = true
}
this.fetchModels();
this.bindingsArr = await this.api_get_req("list_bindings")
this.modelsArr = await this.api_get_req("list_models")
this.persLangArr = await this.api_get_req("list_personalities_languages")
this.persCatgArr = await this.api_get_req("list_personalities_categories")
this.persArr = await this.api_get_req("list_personalities")
this.langArr = await this.api_get_req("list_languages")
this.bindingsArr.sort((a, b) => a.name.localeCompare(b.name))
this.modelsArr.sort()
this.persLangArr.sort()
@ -1411,16 +1408,12 @@ export default {
this.langArr.sort()
await this.getPersonalitiesArr()
//await this.getPersonalitiesArr()
this.modelsFiltered = this.models
this.bindings = await this.api_get_req("list_bindings")
this.bindings.sort((a, b) => a.name.localeCompare(b.name))
//this.bindings = await this.api_get_req("list_bindings")
this.bindingsArr.sort((a, b) => a.name.localeCompare(b.name))
this.isLoading = false
this.diskUsage = await this.api_get_req("disk_usage")
this.ramUsage = await this.api_get_req("ram_usage")
this.vramUsage = await this.getVramUsage()
this.getMountedPersonalities()
this.isMounted = true
@ -1433,60 +1426,6 @@ export default {
},
async getVramUsage() {
const resp = await this.api_get_req("vram_usage")
// {
// "gpu_0_total_vram": 11811160064,
// "gpu_0_used_vram": 3177185280,
// "nb_gpus": 1
// }
const gpuArr = []
if (resp.nb_gpus > 0) {
// Get keys
const keys = Object.keys(resp)
// for each gpu
for (let i = 0; i < resp.nb_gpus; i++) {
const total_vram = resp[`gpu_${i}_total_vram`];
const used_vram = resp[`gpu_${i}_used_vram`];
const model = resp[`gpu_${i}_model`];
const percentage = (used_vram / total_vram) * 100
const available_space = total_vram - used_vram
gpuArr.push({
total_vram: this.computedFileSize(total_vram),
used_vram: this.computedFileSize(used_vram),
gpu_index: i,
gpu_model: model,
percentage: percentage.toFixed(2),
available_space: this.computedFileSize(available_space)
});
}
const result = {
"nb_gpus": resp.nb_gpus,
"gpus": gpuArr
}
//console.log('gpu usage: ',result)
return result
}
else{
const result = {
"nb_gpus": 0,
"gpus": []
}
//console.log('gpu usage: ',result)
return result
}
},
@ -1541,9 +1480,7 @@ export default {
this.$refs.toast.showToast("Model:\n" + model_object.title + "\ninstalled!", 4, true)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
} else if (response.status === 'failed') {
console.log("Install failed")
@ -1561,9 +1498,7 @@ export default {
}
console.error('Installation failed:', response.error);
this.$refs.toast.showToast("Model:\n" + model_object.title + "\nfailed to install!", 4, false)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
}
},
@ -1597,80 +1532,6 @@ export default {
this.mzdc_collapsed = val
},
fetchBindings() {
this.api_get_req("list_bindings")
then(response => {
this.bindings = response
this.bindings.sort((a, b) => a.name.localeCompare(b.name))
})
},
fetchMainConfig(){
this.api_get_req("get_config").then(response => {
this.getPersonalitiesArr().then(() => {
this.getMountedPersonalities()
})
console.log("Received config")
this.configFile = response
}).then(() => {
this.api_get_req("get_current_personality_path_infos").then(response => {
this.configFile.personality_language = response["personality_language"]
this.configFile.personality_category = response["personality_category"]
this.configFile.personality_folder = response["personality_name"]
console.log("received infos")
});
})
},
fetchModels() {
this.api_get_req("get_available_models")
axios.get('/get_available_models')
.then(response => {
this.models = response.data;
this.models.sort((a, b) => a.title.localeCompare(b.title))
this.fetchCustomModels()
this.models.forEach(model => {
if (model.title == this.configFile["model_name"]) {
model.selected = true;
}
else {
model.selected = false;
}
});
})
.catch(error => {
console.log(error.message, 'fetchModels');
});
},
fetchCustomModels() {
axios.get('/list_models')
.then(response => {
// Returns array of model filenames which are = to title of models zoo entry
for (let i = 0; i < response.data.length; i++) {
const customModel = response.data[i]
const index = this.models.findIndex(x => x.title == customModel)
if (index == -1) {
let newModelEntry = {}
newModelEntry.title = customModel
newModelEntry.path = customModel
newModelEntry.isCustomModel = true
newModelEntry.isInstalled = true
this.models.push(newModelEntry)
}
}
})
.catch(error => {
console.log(error.message, 'fetchCustomModels');
});
},
fetchPersonalities(){
this.api_get_req("list_personalities_categories").then(response => {
this.persCatgArr = response
@ -1684,13 +1545,8 @@ export default {
})
},
fetchHardwareInfos(){
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.api_get_req("ram_usage").then(response => {
this.ramUsage = response
})
this.$store.dispatch('refreshDiskUsage');
this.$store.dispatch('refreshRamUsage');
},
async onPersonalitySelected(pers) {
console.log('on pers', pers)
@ -1834,9 +1690,7 @@ export default {
// Update the isInstalled property of the corresponding model
this.$refs.toast.showToast("Model:\n" + model_object.title + "\ninstalled!", 4, true)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
} else {
socket.off('install_progress', progressListener);
@ -1847,9 +1701,7 @@ export default {
this.showProgress = false;
console.error('Installation failed:', response.error);
this.$refs.toast.showToast("Model:\n" + model_object.title + "\nfailed to install!", 4, false)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
};
@ -1897,9 +1749,7 @@ export default {
// Update the isInstalled property of the corresponding model
this.addModel = {}
this.$refs.toast.showToast("Model:\n" + this.addModel.model_name + "\ninstalled!", 4, true)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
} else {
socket.off('install_progress', progressListener);
@ -1910,9 +1760,7 @@ export default {
console.error('Installation failed:', response.error);
this.$refs.toast.showToast("Model:\n" + this.addModel.model_name + "\nfailed to install!", 4, false)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
};
@ -1959,9 +1807,7 @@ export default {
// Update the isInstalled property of the corresponding model
this.addModel = {}
this.$refs.toast.showToast("Model:\n" + this.addModel.model_name + "\ninstalled!", 4, true)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
} else {
socket.off('progress', progressListener);
@ -1972,9 +1818,7 @@ export default {
console.error('Installation failed:', response.error);
this.$refs.toast.showToast("Model:\n" + this.addModel.model_name + "\nfailed to install!", 4, false)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
};
@ -2011,9 +1855,7 @@ export default {
this.models = this.models.filter((model) => model.title !== model_object.title)
}
this.$refs.toast.showToast("Model:\n" + model_object.title + "\nwas uninstalled!", 4, true)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
} else {
console.log("uninstalling failed", response)
// Installation failed or encountered an error
@ -2023,9 +1865,7 @@ export default {
// eslint-disable-next-line no-undef
console.error('Uninstallation failed:', message.error);
this.$refs.toast.showToast("Model:\n" + model_object.title + "\nfailed to uninstall!", 4, false)
this.api_get_req("disk_usage").then(response => {
this.diskUsage = response
})
this.$store.dispatch('refreshDiskUsage');
}
};
@ -2038,6 +1878,7 @@ export default {
})
},
onSelectedBinding(binding_object) {
console.log("Binding selected")
if (!binding_object.binding.installed) {
this.$refs.toast.showToast("Binding is not installed:\n" + binding_object.binding.name, 4, false)
return
@ -2051,7 +1892,8 @@ export default {
// return
// }
this.update_binding(binding_object.binding.folder)
this.fetchModels();
this.$store.dispatch('refreshConfig');
this.$store.dispatch('refreshModelsZoo');
//console.log('lol',binding_object)
}
},
@ -2199,12 +2041,12 @@ export default {
},
// Refresh stuff
refresh() {
this.fetchMainConfig();
this.fetchBindings();
this.fetchModels();
this.fetchPersonalities();
this.fetchHardwareInfos();
console.log("Refreshing")
//this.fetchMainConfig();
//this.fetchBindings();
//this.fetchModels();
//this.fetchPersonalities();
//this.fetchHardwareInfos();
},
// Accordeon stuff
@ -2251,7 +2093,6 @@ export default {
item.installed = true
}
this.$refs.toast.showToast("Binding changed.", 4, true)
this.settingsChanged = true
this.isLoading = false
@ -2259,9 +2100,13 @@ export default {
this.update_model(null)
this.configFile.model_name = null
this.fetchMainConfig();
this.fetchBindings();
this.fetchModels();
this.$store.dispatch('refreshConfig');
this.$store.dispatch('refreshModelsZoo');
this.$refs.toast.showToast("Binding changed.", 4, true)
//this.fetchMainConfig();
//this.fetchBindings();
//this.fetchModels();
nextTick(() => {
feather.replace()
@ -2371,7 +2216,7 @@ export default {
this.isLoading = true
this.personalities = []
const dictionary = await this.api_get_req("get_all_personalities")
const config = await this.api_get_req("get_config")
const config = this.$store.config
//console.log('asdas',config)
// console.log("all_personalities")
// console.log(dictionary)
@ -2446,6 +2291,7 @@ export default {
},
async filterModels() {
if (!this.searchModel) {
console.log("Searching model")
this.modelsFiltered = this.models
this.modelsFiltered.sort()
this.searchModelInProgress = false
@ -2615,7 +2461,7 @@ export default {
//pers.isMounted = false
this.getMountedPersonalities()
this.$store.dispatch('refreshMountedPersonalities');
// Select some other personality
const lastPers = this.mountedPersArr[this.mountedPersArr.length - 1]
@ -2634,35 +2480,6 @@ export default {
this.isLoading = false
},
getMountedPersonalities() {
let mountedPersArr = []
console.log(this.configFile.personalities.length)
// console.log('perrs listo',this.personalities)
for (let i = 0; i < this.configFile.personalities.length; i++) {
const full_path_item = this.configFile.personalities[i]
const index = this.personalities.findIndex(item => item.full_path == full_path_item)
console.log('index', index)
console.log("i:", i)
const pers = this.personalities[index]
if (pers) {
mountedPersArr.push(pers)
}
else {
mountedPersArr.push(this.personalities[this.personalities.findIndex(item => item.full_path == "english/generic/lollms")])
}
}
this.mountedPersArr = []
this.mountedPersArr = mountedPersArr
//this.mountedPersArr = mountedPersArr
console.log('getMountedPersonalities', mountedPersArr)
//console.log('fig', this.configFile.personality_category)
nextTick(() => {
//console.log('accc', this.$refs.mountedPersonalities)
//this.$store.state.mountedPersonalities = this.$refs.mountedPersonalities
})
},
onPersonalityReinstall(persItem){
console.log('on reinstall ', persItem)
this.isLoading = true
@ -2740,10 +2557,77 @@ export default {
}
},
computed: {
configFile: {
get() {
return this.$store.state.config;
},
set(value) {
this.$store.commit('setConfig', value);
},
},
personalities:{
get() {
return this.$store.state.personalities;
},
set(value) {
this.$store.commit('setPersonalities', value);
}
},
bindingsArr: {
get() {
return this.$store.state.bindingsArr;
},
set(value) {
this.$store.commit('setBindingsArr', value);
}
},
modelsArr: {
get() {
return this.$store.state.modelsArr;
},
set(value) {
this.$store.commit('setModelsArr', value);
}
},
models: {
get() {
return this.$store.state.models_zoo;
},
set(value) {
this.$store.commit('setModelsZoo', value);
}
},
diskUsage: {
get() {
return this.$store.state.diskUsage;
},
set(value) {
this.$store.commit('setDiskUsage', value);
}
},
ramUsage: {
get() {
return this.$store.state.ramUsage;
},
set(value) {
this.$store.commit('setRamUsage', value);
}
},
vramUsage: {
get() {
return this.$store.state.vramUsage;
},
set(value) {
this.$store.commit('setVramUsage', value);
}
},
disk_available_space() {
return this.computedFileSize(this.diskUsage.available_space)
},
disk_binding_models_usage() {
console.log(`this.diskUsage : ${this.diskUsage}`)
return this.computedFileSize(this.diskUsage.binding_models_usage)
},
disk_percent_usage() {