updated code

This commit is contained in:
Saifeddine ALOUI 2023-08-31 02:02:36 +02:00
parent c79ba08227
commit 460c0143b6
7 changed files with 102 additions and 60 deletions

View File

@ -654,7 +654,7 @@ class LoLLMsAPPI(LollmsApplication):
tk = model.tokenize(prompt)
n_tokens = len(tk)
fd = model.detokenize(tk[-min(self.config.ctx_size-n_predicts,n_tokens):])
fd = model.detokenize(tk[-min(self.config.ctx_size-n_predicts,n_tokens, len(tk)):])
try:
ASCIIColors.print("warming up", ASCIIColors.color_bright_cyan)

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-9c673d5e.js"></script>
<link rel="stylesheet" href="/assets/index-489786d6.css">
<script type="module" crossorigin src="/assets/index-04bf888d.js"></script>
<link rel="stylesheet" href="/assets/index-5d272872.css">
</head>
<body>
<div id="app"></div>

View File

@ -122,11 +122,12 @@
</div>
<!-- CHAT BOX -->
<div class="flex flex-row flex-grow items-center gap-2 overflow-visible">
<select v-model="selectedModel" @change="setModel" class="bg-white dark:bg-black m-0 border-2 rounded-md shadow-sm w-0">
<option v-for="model in models" :key="model" :value="model">
{{ model }}
</option>
</select>
<InteractiveMenu
:title="selectedModel"
:sendCommand="setModel"
:icon="models_menu_icon"
:commands="commandify(models)"
:selected_entry="selectedModel"></InteractiveMenu>
<div v-if="selecting_model" title="Selecting model" class="flex flex-row flex-grow justify-end">
<!-- SPINNER -->
<div role="status">
@ -249,6 +250,7 @@ import filesize from '../plugins/filesize'
import MountedPersonalities from '@/components/MountedPersonalities.vue'
import MountedPersonalitiesList from '@/components/MountedPersonalitiesList.vue'
import PersonalitiesCommands from '@/components/PersonalitiesCommands.vue';
import InteractiveMenu from '@/components/InteractiveMenu.vue';
import { useStore } from 'vuex'; // Import the useStore function
import { inject } from 'vue';
import socket from '@/services/websocket.js'
@ -268,7 +270,8 @@ export default {
Toast,
MountedPersonalities,
MountedPersonalitiesList,
PersonalitiesCommands
PersonalitiesCommands,
InteractiveMenu
},
setup() {
@ -288,6 +291,7 @@ export default {
showFileList: true,
showPersonalities: false,
personalities_ready: false,
models_menu_icon:'#M'
}
},
computed: {
@ -314,15 +318,39 @@ export default {
}
},
methods: {
setModel(){
methods: {
showModels(event){
// Prevent the default button behavior
event.preventDefault();
// Programmatically trigger the click event on the select element
const selectElement = this.$refs.modelsSelectionList;
console.log(selectElement)
const event_ = new MouseEvent("click");
selectElement.dispatchEvent(event_);
},
commandify(list_of_strings){
let list_of_dicts=[]
for (var i = 0; i < list_of_strings.length; i++) {
let dict={}
dict["name"]=list_of_strings[i]
dict["value"]=list_of_strings[i]
list_of_dicts.push(dict)
}
return list_of_dicts
},
setModel(selectedModel){
this.selecting_model=true
this.selectedModel = selectedModel
axios.post("/update_setting", {
setting_name: "model_name",
setting_value: this.selectedModel
setting_value: selectedModel
}).then((response) => {
console.log(response);
this.$refs.toast.showToast(`Model changed to ${this.selectedModel}`,4,true)
this.$refs.toast.showToast(`Model changed to ${selectedModel}`,4,true)
this.selecting_model=false
}).catch(err=>{
this.$refs.toast.showToast(`Error ${err}`,4,true)

View File

@ -1,15 +1,17 @@
<template>
<div class="menu-container">
<button @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" ref="menuButton">
<img v-if="icon && !icon.includes('feather')" :src="command.icon" :alt="command.name" class="w-5 h-5">
<i v-if="icon && icon.includes('feather')" :data-feather="command.icon.split(':')[1]" class="w-5 h-5"></i>
<i data-feather="command" ></i>
<button @click.prevent="toggleMenu" :title="title" class="menu-button m-0 p-0 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" ref="menuButton">
<img v-if="icon && !icon.includes('#') && !icon.includes('feather')" :src="icon" class="w-5 h-5 p-0 m-0 shadow-lg bold">
<i v-else-if="icon && icon.includes('feather')" :data-feather="icon.split(':')[1]" class="w-5 h-5"></i>
<p v-else-if="icon && icon.includes('#')" class="w-5 h-5">{{ icon.split('#')[1] }}</p>
<i v-else data-feather="command" ></i>
</button>
<transition name="slide">
<div v-if="isMenuOpen" class="menu-list flex-grow" :style="menuPosition" ref="menu">
<ul class="flex-grow menu-ul">
<li v-for="(command, index) in commands" :key="index" @click="executeCommand(command)" class="menu-command menu-li flex-grow hover:bg-blue-400 ">
<img v-if="command.icon && !command.icon.includes('feather') && !command.is_file" :src="command.icon" :alt="command.name" class="menu-icon">
<i v-if="selected_entry==command.name" data-feather="check"></i>
<img v-else-if="command.icon && !command.icon.includes('feather') && !command.is_file" :src="command.icon" :alt="command.name" class="menu-icon">
<i v-if="command.icon && command.icon.includes('feather') && !command.is_file" :data-feather="command.icon.split(':')[1]" class="mr-2"></i>
<span v-else class="menu-icon"></span>
<span>{{ command.name }}</span>
@ -25,10 +27,15 @@ import { nextTick } from 'vue'
import feather from 'feather-icons'
export default {
props: {
title: {
type:String,
required:false,
value:"menu"
},
icon: {
type:String,
required:false,
value:"feather:command"
value:"feather:menu"
},
commands: {
type: Array,
@ -41,6 +48,10 @@ export default {
execute_cmd: {
type: Function, // The execute_cmd property should be a function
required: false
},
selected_entry: {
type: String,
required: false
}
},
data() {

View File

@ -1677,12 +1677,10 @@
</div>
</div>
</div>
<Toast ref="toast" />
<YesNoDialog ref="yesNoDialog" class="z-20" />
<AddModelDialog ref="addmodeldialog" />
<MessageBox ref="messageBox" />
<Toast ref="toast" />
<UniversalForm ref="universalForm" class="z-20" />
<ChoiceDialog class="z-20"
:show="variantSelectionDialogVisible"
@ -2438,7 +2436,12 @@ export default {
const index = this.models.findIndex((model) => model.path === model_object.path);
this.models[index].isInstalled = false;
if (model_object.model.isCustomModel) {
this.models = this.models.filter((model) => model.title !== model_object.title)
try{
this.models = this.models.filter((model) => model.title !== model_object.title)
}
catch{
this.models = model
}
}
this.$refs.toast.showToast("Model:\n" + model_object.title + "\nwas uninstalled!", 4, true)
this.$store.dispatch('refreshDiskUsage');