enhanced ui

This commit is contained in:
Saifeddine ALOUI 2023-12-28 22:35:11 +01:00
parent 24e56537ff
commit 864416925d
11 changed files with 224 additions and 180 deletions

17
app.py
View File

@ -33,7 +33,7 @@ from lollms.config import InstallOption
from lollms.main_config import LOLLMSConfig
from lollms.paths import LollmsPaths, gptqlora_repo
from lollms.com import NotificationType, NotificationDisplayType
from lollms.utilities import AdvancedGarbageCollector, reinstall_pytorch_with_cuda, convert_language_name
from lollms.utilities import AdvancedGarbageCollector, reinstall_pytorch_with_cuda, convert_language_name, find_first_available_file_index
lollms_paths = LollmsPaths.find_paths(force_local=True, custom_default_cfg_path="configs/config.yaml")
# Configuration loading part
config = LOLLMSConfig.autoload(lollms_paths)
@ -788,8 +788,17 @@ try:
def read(self):
# Get the JSON data from the POST request.
try:
from lollms.audio_gen_modules.lollms_xtts import LollmsXTTS
if self.tts is None:
self.tts = LollmsXTTS(self, voice_samples_path=Path(__file__).parent/"voices")
except:
return jsonify({"url": None})
data = request.get_json()
voice=data.get("voice",self.config.current_voice)
index = find_first_available_file_index(self.tts.output_folder, "voice_sample_",".wav")
output_fn=data.get("fn",f"voice_sample_{index}.wav")
if voice is None:
voice = "main_voice"
self.info("Starting to build voice")
@ -803,10 +812,8 @@ try:
else:
voices_folder = Path(__file__).parent/"voices"
self.tts.set_speaker_folder(voices_folder)
fn = self.personality.name.lower().replace(' ',"_").replace('.','')
fn = f"playground_voice.wav"
url = f"audio/{fn}"
self.tts.tts_to_file(data['text'], f"{voice}.wav", f"{fn}", language=language)
url = f"audio/{output_fn}"
self.tts.tts_to_file(data['text'], f"{voice}.wav", f"{output_fn}", language=language)
self.info("Voice file ready")
return jsonify({"url": url})
except:

@ -1 +1 @@
Subproject commit 1a49dd9dfc07c42c8329fc637274f7f4fc71dc36
Subproject commit f1fd6521e3840a11e2e2f626d01a6c44ad39bc93

BIN
web/dist/assets/bash_block-7ca80e4e.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

2
web/dist/index.html vendored
View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -72,6 +72,15 @@
title="Edit message" @click.stop="editMsgMode = true">
<i data-feather="edit"></i>
</div>
<div v-if="editMsgMode" class="text-lg hover:text-secondary duration-75 active:scale-90 p-2"
title="Add python block" @click.stop="addPythonBlock()">
<img :src="python_block" width="25" height="25">
</div>
<div v-if="editMsgMode" class="text-lg hover:text-secondary duration-75 active:scale-90 p-2"
title="Add bash block" @click.stop="addBashBlock()">
<img :src="bash_block" width="25" height="25">
</div>
<div class="text-lg hover:text-secondary duration-75 active:scale-90 p-2"
title="Copy message to clipboard" @click.stop="copyContentToClipboard()">
<i data-feather="copy"></i>
@ -133,7 +142,7 @@
<i data-feather="volume-2"></i>
</div>
</div>
<div v-if="enable_voice_service" class="flex flex-row items-center">
<div v-if="this.$store.state.config.enable_voice_service" class="flex flex-row items-center">
<div class="text-lg hover:text-red-600 duration-75 active:scale-90 p-2"
title="read"
@click.stop="read()"
@ -169,7 +178,7 @@
</textarea>
</div>
<div v-if="message.metadata !== null">
<div v-for="(metadata, index) in message.metadata" :key="'json-' + message.id + '-' + index" class="json font-bold">
<JsonViewer :jsonFormText="metadata.title" :jsonData="metadata.content" />
@ -177,7 +186,7 @@
</div>
<DynamicUIRenderer v-if="message.ui !== null && message.ui !== undefined && message.ui !== ''" class="w-full h-full" :code="message.ui"></DynamicUIRenderer>
<audio controls autoplay v-if="audio_url!=null">
<audio controls autoplay v-if="audio_url!=null" ref="audio_player">
<source :src="audio_url" type="audio/wav">
Your browser does not support the audio element.
</audio>
@ -229,6 +238,9 @@ import RenderHTMLJS from './RenderHTMLJS.vue';
import JsonViewer from "./JsonViewer.vue";
import Step from './Step.vue';
import axios from 'axios'
import python_block from '@/assets/python_block.png';
import bash_block from '@/assets/bash_block.png';
import DynamicUIRenderer from "./DynamicUIRenderer.vue"
export default {
@ -253,6 +265,8 @@ export default {
},
data() {
return {
python_block:python_block,
bash_block:bash_block,
audio_url:null,
audio:null,
msg:null,
@ -314,7 +328,8 @@ export default {
},
read(){
if(this.isSpeaking){
this.audio.pause()
this.$refs.audio_player.pause()
this.isSpeaking=false
}
else{
this.isSpeaking=true
@ -410,6 +425,31 @@ export default {
toggleModel() {
this.expanded = !this.expanded;
},
addBashBlock(){
let p =this.$refs.mdTextarea.selectionStart
if(p==0 || this.message.content[p-1]=="\n"){
this.message.content = this.message.content.slice(0, p) + "```bash\n\n```\n" + this.message.content.slice(p)
}
else{
this.message.content = this.message.content.slice(0, p) + "\n```bash\n\n```\n" + this.message.content.slice(p)
}
p = p+9
this.$refs.mdTextarea.focus();
this.$refs.mdTextarea.selectionStart = this.$refs.mdTextarea.selectionEnd = p;
},
addPythonBlock() {
let p =this.$refs.mdTextarea.selectionStart
if(p==0 || this.message.content[p-1]=="\n"){
this.message.content = this.message.content.slice(0, p) + "```python\n\n```\n" + this.message.content.slice(p)
}
else{
this.message.content = this.message.content.slice(0, p) + "\n```python\n\n```\n" + this.message.content.slice(p)
}
p = p+11
this.$refs.mdTextarea.focus();
this.$refs.mdTextarea.selectionStart = this.$refs.mdTextarea.selectionEnd = p;
},
copyContentToClipboard() {
this.$emit('copy', this)
@ -544,11 +584,6 @@ export default {
},
computed: {
enable_voice_service:{
get(){
this.$store.state.config.enable_voice_service
}
},
editMsgMode:{
get(){
if(this.message.hasOwnProperty('open'))

@ -1 +1 @@
Subproject commit 6fd7581f87cb15ff00345106dca6b8e83e9d0256
Subproject commit 0fc7d955702e842c69b82ffeac09fd4b9e342a63