This commit is contained in:
Saifeddine ALOUI 2024-07-10 23:25:04 +02:00
parent c1bb1ad197
commit 66ecc7f256
7 changed files with 467 additions and 458 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

6
web/dist/index.html vendored
View File

@ -5,9 +5,9 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI - Welcome</title>
<script type="module" crossorigin src="/assets/index-635d7a9c.js"></script>
<link rel="stylesheet" href="/assets/index-e245928f.css">
<title>LoLLMS WebUI</title>
<script type="module" crossorigin src="/assets/index-a71c2ca5.js"></script>
<link rel="stylesheet" href="/assets/index-7f382e92.css">
</head>
<body>
<div id="app"></div>

View File

@ -5,7 +5,7 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI - Welcome</title>
<title>LoLLMS WebUI</title>
</head>
<body>
<div id="app"></div>

View File

@ -4,6 +4,7 @@ import axios from "axios";
import App from './App.vue'
import router from './router'
import socket from '@/services/websocket.js'
import './assets/tailwind.css'
//import './assets/tailwind_april_fool.css'
@ -240,7 +241,7 @@ export const store = createStore({
async refreshConfig({ commit }) {
console.log("Fetching configuration");
try {
const configFile = await api_post_req('get_config', {client_id:this.state.client_id})
const configFile = await api_post_req('get_config', this.state.client_id)
if(configFile.active_personality_id<0){
configFile.active_personality_id=0;
}
@ -589,113 +590,28 @@ async function refreshHardwareUsage(store) {
let actionsExecuted = false;
app.mixin({
async socketIOConnected(){
},
socketIODisconnected(){
this.$store.state.isConnected=false;
},
async created() {
if (!actionsExecuted) {
this.$store.state.api_get_req = api_get_req
this.$store.state.api_post_req = api_post_req
actionsExecuted = true;
console.log("Calling")
try{
this.$store.state.loading_infos = "Getting version"
this.$store.state.loading_progress = 30
await this.$store.dispatch('getVersion');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Loading Configuration"
this.$store.state.loading_progress = 10
await this.$store.dispatch('refreshConfig');
console.log("Config ready")
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Loading Database"
this.$store.state.loading_progress = 20
await this.$store.dispatch('refreshDatabase');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting Bindings list"
this.$store.state.loading_progress = 40
await this.$store.dispatch('refreshBindings');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting Hardware usage"
await refreshHardwareUsage(this.$store);
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting personalities zoo"
this.$store.state.loading_progress = 70
await this.$store.dispatch('refreshPersonalitiesZoo')
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting mounted personalities"
this.$store.state.loading_progress = 80
await this.$store.dispatch('refreshMountedPersonalities');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting models zoo"
this.$store.state.loading_progress = 90
await this.$store.dispatch('refreshModelsZoo');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting active models"
this.$store.state.loading_progress = 100
await this.$store.dispatch('refreshModels');
await this.$store.dispatch('refreshModelStatus');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
await this.$store.dispatch('fetchLanguages');
await this.$store.dispatch('fetchLanguage');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
await this.$store.dispatch('fetchisRTOn');
}
catch (ex){
console.log("Error cought:", ex)
}
this.$store.state.ready = true;
console.log("Main.js creation started")
}
console.log("Main.js created")
},
beforeMount() {
socket.on('connected',this.socketIOConnected)
socket.on('disconnected',this.socketIODisconnected)
console.log("Main.js before mount")
},
mounted() {
console.log("Main.js mounted")
}
})

View File

@ -1266,11 +1266,9 @@ export default {
}
},
socketIOConnected() {
async socketIOConnected() {
console.log("socketIOConnected")
this.$store.state.isConnected=true;
this.$store.state.client_id = socket.id
return true
},
socketIODisconnected() {
console.log("socketIOConnected")
@ -2132,6 +2130,7 @@ export default {
},
},
async created() {
console.log("Created discussions view")
const response = await axios.get('/get_versionID');
const serverVersionId = response.data.versionId;
if (this.versionId !== serverVersionId) {
@ -2144,6 +2143,142 @@ export default {
this.$nextTick(() => {
feather.replace();
});
console.log("Connected to socket io")
try{
this.$store.state.loading_infos = "Getting version"
this.$store.state.loading_progress = 30
await this.$store.dispatch('getVersion');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Loading Configuration"
this.$store.state.client_id = socket.id
console.log(this.$store.state.client_id)
await this.$store.dispatch('refreshConfig');
console.log("Config ready")
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Loading Database"
this.$store.state.loading_progress = 20
await this.$store.dispatch('refreshDatabase');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting Bindings list"
this.$store.state.loading_progress = 40
await this.$store.dispatch('refreshBindings');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting Hardware usage"
await refreshHardwareUsage(this.$store);
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting personalities zoo"
this.$store.state.loading_progress = 70
await this.$store.dispatch('refreshPersonalitiesZoo')
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting mounted personalities"
this.$store.state.loading_progress = 80
await this.$store.dispatch('refreshMountedPersonalities');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting models zoo"
this.$store.state.loading_progress = 90
await this.$store.dispatch('refreshModelsZoo');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
this.$store.state.loading_infos = "Getting active models"
this.$store.state.loading_progress = 100
await this.$store.dispatch('refreshModels');
await this.$store.dispatch('refreshModelStatus');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
await this.$store.dispatch('fetchLanguages');
await this.$store.dispatch('fetchLanguage');
}
catch (ex){
console.log("Error cought:", ex)
}
try{
await this.$store.dispatch('fetchisRTOn');
}
catch (ex){
console.log("Error cought:", ex)
}
this.$store.state.isConnected=true;
this.$store.state.client_id = socket.id
console.log("Ready")
// Constructor
this.setPageTitle()
await this.list_discussions()
this.loadLastUsedDiscussion()
this.isCreated = true
this.$store.state.ready = true;
socket.on('connected',this.socketIOConnected)
socket.on('disconnected',this.socketIODisconnected)
console.log("Added events")
// socket responses
socket.on('show_progress', this.show_progress)
socket.on('hide_progress', this.hide_progress)
socket.on('update_progress', this.update_progress)
socket.on('notification', this.notify)
socket.on('new_message', this.new_message)
socket.on('update_message', this.streamMessageContent)
socket.on('close_message', this.finalMsgEvent)
socket.onopen = () => {
console.log('WebSocket connection established.');
if (this.currentDiscussion!=null){
this.setPageTitle(item)
localStorage.setItem('selected_discussion', this.currentDiscussion.id)
this.load_discussion(item.id, ()=>{
if (this.discussionArr.length > 1) {
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
this.changeTitleUsingUserMSG(this.currentDiscussion.id, this.discussionArr[1].content)
}
}
});
}
};
socket.on('disucssion_renamed',(event)=>{
console.log('Received new title', event.discussion_id, event.title);
const index = this.list.findIndex((x) => x.id == event.discussion_id)
@ -2175,48 +2310,6 @@ export default {
this.socketIODisconnected();
socket.disconnect();
};
socket.on('connected',this.socketIOConnected)
socket.on('disconnected',this.socketIODisconnected)
console.log("Added events")
console.log("Waiting to be ready")
while (this.$store.state.ready === false) {
await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms
}
console.log("Ready")
// Constructor
this.setPageTitle()
await this.list_discussions()
this.loadLastUsedDiscussion()
// socket responses
socket.on('show_progress', this.show_progress)
socket.on('hide_progress', this.hide_progress)
socket.on('update_progress', this.update_progress)
socket.on('notification', this.notify)
socket.on('new_message', this.new_message)
socket.on('update_message', this.streamMessageContent)
socket.on('close_message', this.finalMsgEvent)
socket.onopen = () => {
console.log('WebSocket connection established.');
if (this.currentDiscussion!=null){
this.setPageTitle(item)
localStorage.setItem('selected_discussion', this.currentDiscussion.id)
this.load_discussion(item.id, ()=>{
if (this.discussionArr.length > 1) {
if (this.currentDiscussion.title === '' || this.currentDiscussion.title === null) {
this.changeTitleUsingUserMSG(this.currentDiscussion.id, this.discussionArr[1].content)
}
}
});
}
};
this.isCreated = true
},
async mounted() {
// let serverAddress = "http://localhost:9600/";

View File

@ -1,6 +1,6 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig,loadEnv } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'