version 3.1

This commit is contained in:
Saifeddine ALOUI 2023-07-16 18:57:30 +02:00
parent 0bfab577cc
commit d75112bcdf
18 changed files with 341 additions and 88 deletions

View File

@ -27,7 +27,7 @@ import requests
from tqdm import tqdm
import traceback
import sys
from lollms.console import MainMenu
from lollms.terminal import MainMenu
import urllib
import gc
import ctypes
@ -401,8 +401,9 @@ class LoLLMsAPPI(LollmsApplication):
self.current_discussion = self.db.load_last_discussion()
message = data["prompt"]
ump = "!@>"+self.config.user_name+": " if self.config.use_user_name_in_discussions else self.personality.user_message_prefix
message_id = self.current_discussion.add_message(
"user",
ump,
message,
message_type=MSG_TYPE.MSG_TYPE_FULL.value,
parent=self.message_id
@ -676,13 +677,15 @@ class LoLLMsAPPI(LollmsApplication):
def get_discussion_to(self, message_id=-1):
messages = self.current_discussion.get_messages()
self.full_message_list = []
ump = "!@>"+self.config.user_name+": " if self.config.use_user_name_in_discussions else self.personality.user_message_prefix
for message in messages:
if message["id"]<= message_id or message_id==-1:
if message["type"]!=MSG_TYPE.MSG_TYPE_FULL_INVISIBLE_TO_USER:
if message["sender"]==self.personality.name:
self.full_message_list.append(self.personality.ai_message_prefix+message["content"])
else:
self.full_message_list.append(self.personality.user_message_prefix + message["content"])
self.full_message_list.append(ump + message["content"])
link_text = self.personality.link_text

50
app.py
View File

@ -122,6 +122,10 @@ class LoLLMsWebUI(LoLLMsAPPI):
# =========================================================================================
self.add_endpoint("/reload_binding", "reload_binding", self.reload_binding, methods=["POST"])
self.add_endpoint("/update_software", "update_software", self.update_software, methods=["GET"])
self.add_endpoint("/selectdb", "selectdb", self.selectdb, methods=["GET"])
self.add_endpoint("/install_model_from_path", "install_model_from_path", self.install_model_from_path, methods=["GET"])
@ -470,6 +474,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
def update_setting(self):
data = request.get_json()
setting_name = data['setting_name']
if setting_name== "temperature":
self.config["temperature"]=float(data['setting_value'])
elif setting_name== "n_predict":
@ -555,9 +560,12 @@ class LoLLMsWebUI(LoLLMsAPPI):
return jsonify({'setting_name': data['setting_name'], "status":True})
else:
if self.config["debug"]:
print(f"Configuration {data['setting_name']} couldn't be set to {data['setting_value']}")
return jsonify({'setting_name': data['setting_name'], "status":False})
if data['setting_name'] in self.config.config.keys():
data['setting_name'] = data['setting_value']
else:
if self.config["debug"]:
print(f"Configuration {data['setting_name']} couldn't be set to {data['setting_value']}")
return jsonify({'setting_name': data['setting_name'], "status":False})
if self.config["debug"]:
print(f"Configuration {data['setting_name']} set to {data['setting_value']}")
@ -938,6 +946,42 @@ class LoLLMsWebUI(LoLLMsAPPI):
print(f"Couldn't build binding: [{ex}]")
return jsonify({"status":False, 'error':str(ex)})
def update_software(self):
# Perform a 'git pull' to check for updates
try:
# Execute 'git pull' and redirect the output to the console
process = subprocess.Popen(['git', 'pull'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
# Read and print the output in real-time
while True:
output = process.stdout.readline()
if output == '' and process.poll() is not None:
break
if output:
print(output.strip())
# Wait for the process to finish and get the return code
return_code = process.poll()
if return_code == 0:
return {"status": True}
else:
return {"status": False, 'error': f"git pull failed with return code {return_code}"}
except subprocess.CalledProcessError as ex:
# There was an error in 'git pull' command
return {"status": False, 'error': str(ex)}
def selectdb(self):
from tkinter import Tk, filedialog
# Initialize Tkinter
root = Tk()
root.withdraw()
# Show file selection dialog
file_path = filedialog.askopenfilename()
def reload_binding(self):
try:
data = request.get_json()

View File

@ -1,5 +1,5 @@
# =================== Lord Of Large Language Models Configuration file ===========================
version: 7
version: 9
binding_name: null
model_name: null
@ -25,7 +25,13 @@ active_personality_id: 0
override_personality_model_parameters: false #if true the personality parameters are overriden by those of the configuration (may affect personality behaviour)
user_name: user
user_description: ""
use_user_name_in_discussions: false
user_avatar: default_user.svg
# UI parameters
debug: False
db_path: database.db
db_path: database.db
# Automatic update
auto_update: false

View File

@ -1,4 +1,4 @@
VITE_GPT4ALL_API = http://localhost:9600 # http://localhost:9600
VITE_GPT4ALL_API_CHANGE_ORIGIN = 0 # FALSE
VITE_GPT4ALL_API_SECURE = 0 # FALSE
VITE_GPT4ALL_API_BASEURL = /
VITE_LOLLMS_API = http://localhost:9600 # http://localhost:9600
VITE_LOLLMS_API_CHANGE_ORIGIN = 0 # FALSE
VITE_LOLLMS_API_SECURE = 0 # FALSE
VITE_LOLLMS_API_BASEURL = /

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-d843c7fd.js"></script>
<link rel="stylesheet" href="/assets/index-7d5b903d.css">
<script type="module" crossorigin src="/assets/index-7a2b8295.js"></script>
<link rel="stylesheet" href="/assets/index-414390ac.css">
</head>
<body>
<div id="app"></div>

View File

@ -119,7 +119,7 @@ import { nextTick } from 'vue'
import feather from 'feather-icons'
import botImgPlaceholder from "../assets/logo.svg"
import userImgPlaceholder from "../assets/default_user.svg"
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
export default {
props: {
binding: {},

View File

@ -170,7 +170,7 @@
<script>
import botImgPlaceholder from "../assets/logo.svg"
import userImgPlaceholder from "../assets/default_user.svg"
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
import { nextTick } from 'vue'
import feather from 'feather-icons'
import MarkdownRenderer from './MarkdownRenderer.vue';

View File

@ -254,7 +254,7 @@ import axios from "axios";
import { nextTick } from 'vue'
import feather from 'feather-icons'
import defaultImgPlaceholder from "../assets/default_model.png"
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
export default {
props: {
title: String,

View File

@ -46,8 +46,8 @@ 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
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_LOLLMS_API_BASEURL
export default {

View File

@ -85,8 +85,8 @@ import feather from 'feather-icons'
import axios from "axios";
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_LOLLMS_API_BASEURL
export default {
props: {
onTalk:Function,

View File

@ -90,7 +90,7 @@ import { nextTick } from 'vue'
import feather from 'feather-icons'
import botImgPlaceholder from "../assets/logo.svg"
import userImgPlaceholder from "../assets/default_user.svg"
const bUrl = import.meta.env.VITE_GPT4ALL_API_BASEURL
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
export default {
props: {
personality: {},

View File

@ -1,16 +1,18 @@
<template>
<div class="step flex items-center mb-4">
<div class="checkbox flex items-center justify-center w-6 h-6 rounded border border-gray-300 mr-2">
<i
<div class="flex items-center justify-center w-6 h-6 rounded border border-gray-300 mr-2">
<div v-if="!done">
<i
data-feather="square"
v-if="!done"
class="text-gray-400 w-4 h-4"
></i>
<i
</div>
<div v-if="done">
<i
data-feather="check-square"
v-if="done"
class="text-green-500 w-4 h-4"
></i>
</div>
</div>
<div class="content flex-1" :class="{'text-green-500': done, 'text-yellow-500': !done}">{{ message }}</div>
<div class="loader w-6 h-6 border-t-4 border-b-4 border-blue-500 rounded-full animate-spin ml-2" v-if="!done"></div>

View File

@ -7,7 +7,7 @@
import io from 'socket.io-client';
// fixes issues when people not hosting this site on local network
const URL = process.env.NODE_ENV === "production" ? undefined : (import.meta.env.VITE_GPT4ALL_API);
const URL = process.env.NODE_ENV === "production" ? undefined : (import.meta.env.VITE_LOLLMS_API);
const socket = new io(URL);
socket.onopen = () => {

View File

@ -1,20 +1,40 @@
<template>
<transition name="fade-and-fly">
<div v-if="!isReady" class="fixed top-0 left-0 w-screen h-screen flex items-center justify-center">
<div v-if="!isReady" 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 class="flex flex-col text-center">
<div class="flex flex-col text-center items-center">
<div class="flex items-center gap-3 text-5xl drop-shadow-md align-middle pt-24 ">
<img class="w-24 animate-bounce" title="LoLLMS WebUI" src="@/assets/logo.png" alt="Logo">
<div class="flex flex-col items-start">
<p class="text-2xl ">Lord of Large Language Models</p>
<p class="text-gray-400 text-base">One tool to rule them all</p>
</div>
</div>
<hr
class=" mt-1 w-96 h-1 mx-auto my-2 md:my-2 dark:bg-bg-dark-tone-panel bg-bg-light-tone-panel border-0 rounded ">
<p class="text-2xl">Welcome</p>
<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>
</div>
</transition>
<button v-if="isReady" @click="togglePanel" class="absolute top-0 left-0 z-50 p-2 m-2 bg-white rounded-full shadow-md bg-bg-light-tone dark:bg-bg-dark-tone hover:bg-primary-light dark:hover:bg-primary">
<div v-show="panelCollapsed" ><i data-feather='chevron-right'></i></div>
@ -1571,5 +1591,5 @@ onMounted(() => {
initFlowbite()
})
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_LOLLMS_API_BASEURL
</script>

View File

@ -513,8 +513,133 @@
</div>
</div>
<!-- MAIN CONFIGS -->
<div
class="flex flex-col mb-2 rounded-lg bg-bg-light-tone dark:bg-bg-dark-tone hover:bg-bg-light-tone-panel hover:dark:bg-bg-dark-tone-panel duration-150 shadow-lg">
<div class="flex flex-row p-3">
<button @click.stop="minconf_collapsed = !minconf_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 w-full text-left flex flex-row items-center">
<div v-show="minconf_collapsed" ><i data-feather='chevron-right'></i></div>
<div v-show="!minconf_collapsed" ><i data-feather='chevron-down'></i></div>
<h3 class="text-lg font-semibold cursor-pointer select-none mr-2">
Main configurations</h3>
</button>
</div>
<div :class="{ 'hidden': minconf_collapsed }" class="flex flex-col mb-2 px-3 pb-0">
<table style="width: 100%;">
<!-- Row 1 -->
<tr>
<td style="min-width: 200px;">
<label for="auto_update" class="text-sm font-bold" style="margin-right: 1rem;">Auto update:</label>
</td>
<td>
<input
type="checkbox"
id="auto_update"
required
v-model="auto_update"
class="mt-1 px-2 py-1 border border-gray-300 rounded"
>
</td>
<td style="min-width: 300px;">
<button
class="hover:text-secondary bg-blue-100 m-2 p-2 duration-75 flex justify-center w-full hover:bg-bg-light-tone hover:dark:bg-bg-dark-tone rounded-lg"
@click="update_setting('auto_update', auto_update)"
>
Validate
</button>
</td>
</tr>
<!-- Row 2 -->
<tr>
<td style="min-width: 200px;">
<label for="db_path" class="text-sm font-bold" style="margin-right: 1rem;">Database path:</label>
</td>
<td style="width: 100%;">
<input
type="text"
id="db_path"
required
v-model="db_path"
class="w-full mt-1 px-2 py-1 border border-gray-300 rounded"
>
</td>
<td style="min-width: 300px;">
<button
class="hover:text-secondary bg-blue-100 m-2 p-2 duration-75 flex justify-center w-full hover:bg-bg-light-tone hover:dark:bg-bg-dark-tone rounded-lg"
@click="update_setting('db_path', db_path)"
>
Select Database
</button>
</td>
</tr>
<!-- Row 3 -->
<tr>
<td style="min-width: 200px;">
<label for="user_name" class="text-sm font-bold" style="margin-right: 1rem;">User name:</label>
</td>
<td style="width: 100%;">
<input
type="text"
id="user_name"
required
v-model="userName"
class="w-full mt-1 px-2 py-1 border border-gray-300 rounded"
>
</td>
<td style="min-width: 300px;">
<button
class="hover:text-secondary bg-blue-100 m-2 p-2 duration-75 flex justify-center w-full hover:bg-bg-light-tone hover:dark:bg-bg-dark-tone rounded-lg"
@click="update_setting('user_name', userName)"
>
Validate
</button>
</td>
</tr>
<!-- Row 4 -->
<tr>
<td style="min-width: 200px;">
<label for="use_user_name_in_discussions" class="text-sm font-bold" style="margin-right: 1rem;">Use User Name in discussions:</label>
</td>
<td>
<input
type="checkbox"
id="use_user_name_in_discussions"
required
v-model="use_user_name_in_discussions"
class=" mt-1 px-2 py-1 border border-gray-300 rounded"
>
</td>
<td style="min-width: 300px;">
<button
class="hover:text-secondary bg-blue-100 m-2 p-2 duration-75 flex justify-center w-full hover:bg-bg-light-tone hover:dark:bg-bg-dark-tone rounded-lg"
@click="update_setting('use_user_name_in_discussions', use_user_name_in_discussions)"
>
Validate
</button>
</td>
</tr>
</table>
</div>
</div>
<!-- BINDING ZOO -->
<div
class="flex flex-col mb-2 rounded-lg bg-bg-light-tone dark:bg-bg-dark-tone hover:bg-bg-light-tone-panel hover:dark:bg-bg-dark-tone-panel duration-150 shadow-lg">
@ -1305,8 +1430,8 @@ 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
axios.defaults.baseURL = import.meta.env.VITE_GPT4ALL_API_BASEURL
const bUrl = import.meta.env.VITE_LOLLMS_API_BASEURL
axios.defaults.baseURL = import.meta.env.VITE_LOLLMS_API_BASEURL
export default {
components: {
AddModelDialog,
@ -1337,6 +1462,7 @@ export default {
// Accordeon stuff
collapsedArr: [],
all_collapsed: true,
minconf_collapsed: true, // Main configuration
bec_collapsed: true,
mzc_collapsed: true, // models zoo
mzdc_collapsed: true, // models zoo download
@ -1379,6 +1505,18 @@ export default {
//await socket.on('install_progress', this.progressListener);
}, methods: {
async update_software() {
console.log("Posting")
const res = await this.api_get_req('update_software')
console.log("Posting done")
if(res.status){
this.$refs.toast.showToast("Success!", 4, true)
}
else{
this.$refs.toast.showToast("Failure!", 4, false)
}
},
on_loading_text(text){
console.log("Loading text",text)
@ -1531,6 +1669,7 @@ export default {
this.addModelDialogVisibility = false;
},
collapseAll(val) {
this.minconf_collapsed = val
this.bec_collapsed = val
this.mzc_collapsed = val
this.pzc_collapsed = val
@ -2103,6 +2242,7 @@ export default {
this.showAccordion = !this.showAccordion;
},
async update_setting(setting_name_val, setting_value_val, next) {
console.log("Updating setting", setting_name_val, ":", setting_value_val)
this.isLoading = true
const obj = {
setting_name: setting_name_val,
@ -2611,7 +2751,45 @@ export default {
this.$store.commit('setConfig', value);
},
},
userName: {
get() {
return this.$store.state.config.user_name;
},
set(value) {
// You should not set the value directly here; use the updateSetting method instead
this.$store.state.config.user_name = value
},
},
auto_update:{
get() {
return this.$store.state.config.auto_update;
},
set(value) {
// You should not set the value directly here; use the updateSetting method instead
this.$store.state.config.auto_update = value
},
},
use_user_name_in_discussions: {
get() {
return this.$store.state.config.use_user_name_in_discussions;
},
set(value) {
// You should not set the value directly here; use the updateSetting method instead
this.$store.state.config.use_user_name_in_discussions = value
},
},
db_path: {
get() {
return this.$store.state.config.db_path;
},
set(value) {
// You should not set the value directly here; use the updateSetting method instead
this.$store.state.config.db_path = value
},
},
personalities:{
get() {
return this.$store.state.personalities;

View File

@ -21,15 +21,15 @@ export default ({ mode }) => {
server: {
proxy: {
"/api/": {
target: process.env.VITE_GPT4ALL_API,
changeOrigin: process.env.VITE_GPT4ALL_API_CHANGE_ORIGIN,
secure: process.env.VITE_GPT4ALL_API_SECURE,
target: process.env.VITE_LOLLMS_API,
changeOrigin: process.env.VITE_LOLLMS_API_CHANGE_ORIGIN,
secure: process.env.VITE_LOLLMS_API_SECURE,
rewrite: (path) => path.replace(/^\/api/, ""),
},
// "/": {
// target: process.env.VITE_GPT4ALL_API,
// changeOrigin: process.env.VITE_GPT4ALL_API_CHANGE_ORIGIN,
// secure: process.env.VITE_GPT4ALL_API_SECURE,
// target: process.env.VITE_LOLLMS_API,
// changeOrigin: process.env.VITE_LOLLMS_API_CHANGE_ORIGIN,
// secure: process.env.VITE_LOLLMS_API_SECURE,
// },