enhanced ui

This commit is contained in:
Saifeddine ALOUI 2023-10-20 23:42:08 +02:00
parent bfc7995859
commit c20fdf7af6
11 changed files with 395 additions and 78 deletions

2
app.py
View File

@ -975,6 +975,8 @@ class LoLLMsWebUI(LoLLMsAPPI):
self.discussions_store.index()
ASCIIColors.yellow("3- Saving database")
self.discussions_store.save_to_json()
if self.config.data_vectorization_visualize_on_vectorization:
self.discussions_store.show_document(show_interactive_form=True)
ASCIIColors.yellow("Ready")
except Exception as ex:
ASCIIColors.error(f"Couldn't vectorize database:{ex}")

View File

@ -1,5 +1,5 @@
# =================== Lord Of Large Language Models Configuration file ===========================
version: 26
version: 27
binding_name: null
model_name: null
@ -13,7 +13,7 @@ port: 9600
discussion_prompt_separator: "!@>"
seed: -1
n_predict: 1024
ctx_size: 2048
ctx_size: 4084
min_n_predict: 256
temperature: 0.9
top_k: 50
@ -58,6 +58,7 @@ audio_silenceTimer: 5000
# Data vectorization
use_discussions_history: false # Activate vectorizing previous conversations
data_vectorization_visualize_on_vectorization: false
use_files: true # Activate using files
data_vectorization_activate: true # To activate/deactivate data vectorization
data_vectorization_method: "tfidf_vectorizer" #"model_embedding" or "tfidf_vectorizer"

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="64mm"
height="64mm"
viewBox="0 0 64 64"
version="1.1"
id="svg1"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
sodipodi:docname="brain_orange.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="0.55663503"
inkscape:cx="125.75565"
inkscape:cy="196.71777"
inkscape:window-width="1920"
inkscape:window-height="1009"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 26.917422,35.959579 c 0,-0.796055 1.159115,-1.37136 1.955165,-1.37136 h 7.303095"
id="path845"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csc" />
<path
sodipodi:nodetypes="csc"
inkscape:connector-curvature="0"
id="path847"
d="m 26.917422,33.216859 c 0,0.79605 1.159115,1.37136 1.955165,1.37136 h 7.303095"
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 41.937042,34.281884 c 2.660405,-0.72373 9.06735,-1.23098 8.401985,-6.12145 -0.252535,-1.856165 -1.849255,-2.836355 -3.24076,-3.32078 1.210355,-2.840455 -0.727205,-6.00171 -3.72088,-5.88139 -2.6259,0.105535 -3.85882,3.870325 -2.44058,5.681345"
id="path849"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cscsc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 41.728627,19.355254 c -1.11487,-4.205836 -5.17627,-3.591565 -6.673205,-2.077385 -1.223735,-3.046116 -5.750675,-4.143771 -7.64181,0.280065 -4.47775,-1.750545 -6.63282,2.26973 -5.641335,4.92116 -3.852755,0.722955 -5.20504,6.159225 0.360085,8.441995"
id="path851"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 24.951197,26.595269 c 1.33039,-0.830955 1.614125,-1.79275 1.754035,-2.772515 1.70159,1.36475 4.427895,1.246215 6.05427,-1.2448 0.9111,1.047805 1.897725,2.01694 4.583135,1.21651"
id="path853"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 44.401232,27.599599 c -1.87171,2.204045 -4.656555,2.41888 -7.41223,2.41888 h -11.64588 c -2.258645,0 -4.78117,2.33708 -4.78117,4.595715 0,2.284395 2.496775,4.70888 4.78117,4.70888 h 26.116705 c 3.476055,0 5.397205,-2.72965 4.922635,-6.249175"
id="path855"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csssssc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 51.969062,33.243644 c 7.86792,1.973925 7.397275,-7.159325 3.45149,-7.751725 2.738275,-3.22418 0.50359,-7.33604 -3.28174,-6.789825 1.358665,-3.846341 -2.31936,-6.685126 -5.545035,-5.318701 0.240115,-4.1360449 -3.861375,-5.6147599 -6.789825,-3.9041549"
id="path857"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 39.464457,13.072188 c 1.65178,-6.8297549 -5.986405,-7.7034498 -7.4971,-3.8758599 -1.46649,-4.0016399 -5.9227,-3.0323699 -7.58198,-0.3112 -2.487515,-3.1795699 -6.48695,-2.004885 -7.41223,1.5236899 -4.18271,-2.4645899 -7.5088195,2.159005 -6.16743,4.72861 -6.084589,0.442736 -4.451764,7.148311 -1.9364895,8.201866"
id="path859"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 21.980652,11.912258 c 1.63465,-1.812945 3.5807,-1.89096 5.743055,-0.763855"
id="path861"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 14.709872,18.588929 c 0.70723,-0.70574 1.565525,-1.28559 3.168585,-1.2448 -0.34692,-1.13439 -0.663915,-2.271506 -0.198035,-3.479791"
id="path863"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 6.986438,21.248284 c -4.10728,1.568505 -4.77052,6.12198 -1.244795,8.26095 -2.13183,2.661155 0.57789,7.09191 4.979204,5.884525 1.19975,1.771325 2.703925,2.720875 5.40357,1.78233"
id="path865"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 13.530327,22.018984 c -7.132619,-1.8328 -6.819994,9.256015 -0.18004,8.101915 1.398115,3.922245 5.833955,4.67311 8.72206,0.900215 h 0.02"
id="path867"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 16.303707,33.298219 c -1.09979,5.93442 3.06832,10.46966 8.166545,10.46966 h 5.57332"
id="path869"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 31.161062,39.354494 c -1.59489,2.66585 -1.0315,5.148545 0.367785,6.917135 4.224765,5.339785 8.00502,3.53637 11.528465,8.154425 l 1.75414,2.29909 c 1.547135,2.02778 4.70985,0.141905 3.67783,-2.319865 l -2.544185,-6.068825"
id="path871"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cssssc" />
<path
style="fill:none;fill-opacity:1;stroke:#ff9800;stroke-width:2.22539;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 47.798432,39.323074 c 2.681605,0 5.716665,0.7135 4.32102,5.161225 -0.866645,2.76187 -3.352745,3.8009 -5.801375,3.8009 h -3.745285 c -2.448625,0 -4.934725,-1.03903 -5.80137,-3.8009 -1.39565,-4.447725 1.639415,-5.161225 4.32102,-5.161225 z"
id="path873"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sssssss" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.7 KiB

File diff suppressed because one or more lines are too long

8
web/dist/assets/index-19262763.css vendored Normal file

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-7ae85bdb.js"></script>
<link rel="stylesheet" href="/assets/index-04a75dc0.css">
<script type="module" crossorigin src="/assets/index-fe322430.js"></script>
<link rel="stylesheet" href="/assets/index-19262763.css">
</head>
<body>
<div id="app"></div>

View File

@ -143,9 +143,43 @@
<span class="sr-only">Selecting model...</span>
</div>
</div>
<div class="w-fit">
<MountedPersonalities ref="mountedPers" :onShowPersList="onShowPersListFun" :onReady="onPersonalitiesReadyFun"/>
<div class="w-fit group relative">
<!-- :onShowPersList="onShowPersListFun" -->
<div class= "group w-full inline-flex absolute opacity-0 group-hover:opacity-100 transform group-hover:-translate-y-10 group-hover:translate-x-15 transition-all duration-300">
<div class="w-full"
v-for="(item, index) in this.$store.state.mountedPersArr" :key="index + '-' + item.name"
ref="mountedPersonalities">
<div v-if="index!=this.$store.state.config.active_personality_id" class="group items-center flex flex-row">
<button @click.prevent="onPersonalitySelected(item)" class="w-8 h-8">
<img :src="bUrl + item.avatar" @error="personalityImgPlacehodler"
class="w-8 h-8 rounded-full object-fill text-red-700 border-2 active:scale-90 hover:border-secondary "
:class="this.$store.state.active_personality_id == this.$store.state.personalities.indexOf(item.full_path) ? 'border-secondary' : 'border-transparent z-0'"
:title="item.name">
</button>
<!--
<button @click.prevent="unmountPersonality (item)">
<span
class="hidden hover:block top-3 left-9 absolute active:scale-90 bg-bg-light dark:bg-bg-dark rounded-full border-2 border-transparent"
title="Unmount personality">
<svg aria-hidden="true" class="w-4 h-4 text-red-600 hover:text-red-500 "
fill="currentColor" viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"></path>
</svg>
</span>
</button>
-->
</div>
</div>
</div>
<MountedPersonalities ref="mountedPers" :onShowPersList="onShowPersListFun" :onReady="onPersonalitiesReadyFun"/>
</div>
<div class="w-fit">
@ -263,7 +297,7 @@ import { useStore } from 'vuex'; // Import the useStore function
import { inject } from 'vue';
import socket from '@/services/websocket.js'
import Toast from '../components/Toast.vue'
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
export default {
name: 'ChatBox',
emits: ["messageSentEvent", "stopGenerating", "loaded", "createEmptyMessage"],
@ -288,6 +322,7 @@ export default {
},
data() {
return {
bUrl:bUrl,
message: "",
selecting_model:false,
selectedModel:'',
@ -327,6 +362,127 @@ export default {
}
},
methods: {
async unmountPersonality(pers) {
this.isLoading = true
if (!pers) { return }
const res = await this.unmount_personality(pers.personality || pers)
if (res.status) {
this.$store.state.config.personalities = res.personalities
this.$refs.toast.showToast("Personality unmounted", 4, true)
//pers.isMounted = false
this.$store.dispatch('refreshMountedPersonalities');
// Select some other personality
const lastPers = this.$store.state.mountedPersArr[this.$store.state.mountedPersArr.length - 1]
console.log(lastPers, this.$store.state.mountedPersArr.length)
// const res2 = await this.select_personality(lastPers.personality)
const res2 = await this.select_personality(pers.personality)
if (res2.status) {
this.$refs.toast.showToast("Selected personality:\n" + lastPers.name, 4, true)
}
} else {
this.$refs.toast.showToast("Could not unmount personality\nError: " + res.error, 4, false)
}
this.isLoading = false
},
async unmount_personality(pers) {
if (!pers) { return { 'status': false, 'error': 'no personality - unmount_personality' } }
const obj = {
language: pers.language,
category: pers.category,
folder: pers.folder
}
try {
const res = await axios.post('/unmount_personality', obj);
if (res) {
return res.data
}
} catch (error) {
console.log(error.message, 'unmount_personality - settings')
return
}
},
async onPersonalitySelected(pers) {
console.log('on pers', pers)
// eslint-disable-next-line no-unused-vars
console.log('selecting ', pers)
if (pers) {
if (pers.selected) {
this.$refs.toast.showToast("Personality already selected", 4, true)
return
}
//this.settingsChanged = true
if (pers.isMounted && this.$store.state.config.personalities.includes(pers.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)
} else {
this.$refs.toast.showToast("Error on select personality:\n" + pers.name, 4, false)
}
} else {
console.log('mounting pers')
this.mountPersonality(pers)
}
nextTick(() => {
feather.replace()
})
}
},
async select_personality(pers) {
if (!pers) { return { 'status': false, 'error': 'no personality - select_personality' } }
const id = this.$store.state.config.personalities.findIndex(item => item === pers.full_path)
const obj = {
id: id
}
try {
const res = await axios.post('/select_personality', obj);
if (res) {
this.$store.dispatch('refreshConfig').then(() => {
this.$store.dispatch('refreshPersonalitiesZoo').then(() => {
this.$store.dispatch('refreshMountedPersonalities');
});
});
return res.data
}
} catch (error) {
console.log(error.message, 'select_personality - settings')
return
}
},
emitloaded(){
this.$emit('loaded')
},

View File

@ -285,8 +285,6 @@ export default {
async mounted() {
nextTick(() => {
feather.replace()
})
},
methods: {
@ -331,6 +329,10 @@ export default {
},
toggleSelected(force=false) {
this.onSelected(this,force)
nextTick(() => {
feather.replace()
})
},
toggleCopy() {

View File

@ -96,7 +96,8 @@
</div>
<button v-if="!showBrainConfirmation" title="Activate Long term Memory" class="text-2xl hover:text-secondary duration-75 active:scale-90"
@click="toggleLTM()">
<img v-if="UseDiscussionHistory" :src="SVGGreenBrain" width="25" height="25">
<img v-if="isLoading" :src="SVGOrangeBrain" width="25" height="25">
<img v-else-if="UseDiscussionHistory" :src="SVGGreenBrain" width="25" height="25">
<img v-else :src="SVGRedBrain" width="25" height="25">
</button>
<div v-if="loading" title="Loading.." class="flex flex-row flex-grow justify-end">
@ -352,7 +353,9 @@
</style>
<script>
import SVGRedBrain from '@/assets/brain_red.svg';
import SVGOrangeBrain from '@/assets/brain_orange.svg';
import SVGGreenBrain from '@/assets/brain_green.svg';
export default {
setup() { },

View File

@ -795,7 +795,24 @@
>
</div>
</td>
</tr>
</tr>
<tr>
<td style="min-width: 200px;">
<label for="data_vectorization_visualize_on_vectorization" class="text-sm font-bold" style="margin-right: 1rem;">show vectorized data:</label>
</td>
<td>
<div class="flex flex-row">
<input
type="checkbox"
id="data_vectorization_visualize_on_vectorization"
required
v-model="configFile.data_vectorization_visualize_on_vectorization"
@change="settingsChanged=true"
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
>
</div>
</td>
</tr>
<tr>
<td style="min-width: 200px;">
<label for="data_vectorization_activate" class="text-sm font-bold" style="margin-right: 1rem;">Activate data Vectorization:</label>
@ -2555,7 +2572,7 @@ export default {
this.$refs.toast.showToast("Loading... please wait", 4, false)
}
this.isLoading = true
console.log('ppa', pers)
console.log('selecting ', pers)
if (pers) {
if (pers.selected) {