Added new stuff

This commit is contained in:
Saifeddine ALOUI 2024-03-27 00:15:09 +01:00
parent 9b7955a56d
commit b597e7f42e
6 changed files with 226 additions and 187 deletions

View File

@ -18,7 +18,7 @@ from ascii_colors import ASCIIColors
from lollms.personality import MSG_TYPE, AIPersonality from lollms.personality import MSG_TYPE, AIPersonality
from lollms.types import MSG_TYPE, SENDER_TYPES from lollms.types import MSG_TYPE, SENDER_TYPES
from lollms.utilities import load_config, trace_exception, gc from lollms.utilities import load_config, trace_exception, gc
from lollms.utilities import find_first_available_file_index, convert_language_name from lollms.utilities import find_first_available_file_index, convert_language_name, PackageManager
from lollms_webui import LOLLMSWebUI from lollms_webui import LOLLMSWebUI
from pathlib import Path from pathlib import Path
from typing import List from typing import List
@ -52,6 +52,18 @@ def add_events(sio:socketio):
lollmsElfServer.session.get_client(client_id).discussion = lollmsElfServer.db.load_last_discussion() lollmsElfServer.session.get_client(client_id).discussion = lollmsElfServer.db.load_last_discussion()
if lollmsElfServer.personality.welcome_message!="": if lollmsElfServer.personality.welcome_message!="":
if lollmsElfServer.personality.welcome_audio_path.exists():
for voice in lollmsElfServer.personality.welcome_audio_path.iterdir():
if voice.suffix.lower() in [".wav",".mp3"]:
try:
if not PackageManager.check_package_installed("pygame"):
PackageManager.install_package("pygame")
import pygame
pygame.mixer.init()
pygame.mixer.music.load(voice)
pygame.mixer.music.play()
except Exception as ex:
pass
if lollmsElfServer.config.force_output_language_to_be and lollmsElfServer.config.force_output_language_to_be.lower().strip() !="english": if lollmsElfServer.config.force_output_language_to_be and lollmsElfServer.config.force_output_language_to_be.lower().strip() !="english":
welcome_message = lollmsElfServer.personality.fast_gen(f"!@>instruction: Translate the following text to {lollmsElfServer.config.force_output_language_to_be.lower()}:\n{lollmsElfServer.personality.welcome_message}\n!@>translation:") welcome_message = lollmsElfServer.personality.fast_gen(f"!@>instruction: Translate the following text to {lollmsElfServer.config.force_output_language_to_be.lower()}:\n{lollmsElfServer.personality.welcome_message}\n!@>translation:")
else: else:

@ -1 +1 @@
Subproject commit 72c296e5332ec0a251ba0aa07a1e175654f432a2 Subproject commit 17e4f99094f498c7e4bc20714003e2d9cae7e4e2

File diff suppressed because one or more lines are too long

2
web/dist/index.html vendored
View File

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI - Welcome</title> <title>LoLLMS WebUI - Welcome</title>
<script type="module" crossorigin src="/assets/index-1a9b6579.js"></script> <script type="module" crossorigin src="/assets/index-3442c1ad.js"></script>
<link rel="stylesheet" href="/assets/index-8b7a6d49.css"> <link rel="stylesheet" href="/assets/index-8b7a6d49.css">
</head> </head>
<body> <body>

View File

@ -25,6 +25,8 @@
class="w-6 hover:text-secondary duration-75 active:scale-90 cursor-pointer"> class="w-6 hover:text-secondary duration-75 active:scale-90 cursor-pointer">
<i data-feather="volume-2"></i> <i data-feather="volume-2"></i>
</button> </button>
<input type="file" ref="fileInput" @change="handleFileUpload" style="display: none;" accept=".wav, .mp3" />
<button title="Upload a voice" @click="triggerFileUpload"><i data-feather="speaker"></i></button>
<button <button
type="button" type="button"
title="Start audio to audio" title="Start audio to audio"
@ -581,6 +583,31 @@ export default {
}, },
}, },
methods:{ methods:{
triggerFileUpload() {
this.$refs.fileInput.click();
},
handleFileUpload(event) {
this.file = this.$refs.fileInput.files[0];
this.buttonText = this.file.name;
this.uploadFile()
},
uploadFile() {
const formData = new FormData();
formData.append('file', this.file);
axios.post('http://localhost:8000/upload_voice/', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
})
.then(response => {
console.log(response);
this.buttonText = 'Upload a voice';
})
.catch(error => {
console.error(error);
});
},
addBlock(bloc_name){ addBlock(bloc_name){
let ss =this.$refs.mdTextarea.selectionStart let ss =this.$refs.mdTextarea.selectionStart
let se =this.$refs.mdTextarea.selectionEnd let se =this.$refs.mdTextarea.selectionEnd

@ -1 +1 @@
Subproject commit c93f1bd03d5d0af34f9c89cc11a9b50484320554 Subproject commit e95f92498f0a333be67ae638cd3e4bb3c8b8a7cd