This commit is contained in:
Saifeddine ALOUI 2023-12-31 00:03:03 +01:00
parent 5ef1a35224
commit e2951eab6b
10 changed files with 234 additions and 196 deletions

37
app.py
View File

@ -22,7 +22,7 @@ main_repo = "https://github.com/ParisNeo/lollms-webui.git"
import os import os
import platform import platform
import sys import sys
from flask import request, jsonify from flask import request, jsonify, url_for
import io import io
import sys import sys
import time import time
@ -33,7 +33,7 @@ from lollms.config import InstallOption
from lollms.main_config import LOLLMSConfig from lollms.main_config import LOLLMSConfig
from lollms.paths import LollmsPaths, gptqlora_repo from lollms.paths import LollmsPaths, gptqlora_repo
from lollms.com import NotificationType, NotificationDisplayType from lollms.com import NotificationType, NotificationDisplayType
from lollms.utilities import AdvancedGarbageCollector, reinstall_pytorch_with_cuda, convert_language_name, find_first_available_file_index, add_period from lollms.utilities import PackageManager, AdvancedGarbageCollector, reinstall_pytorch_with_cuda, convert_language_name, find_first_available_file_index, add_period
lollms_paths = LollmsPaths.find_paths(force_local=True, custom_default_cfg_path="configs/config.yaml") lollms_paths = LollmsPaths.find_paths(force_local=True, custom_default_cfg_path="configs/config.yaml")
# Configuration loading part # Configuration loading part
config = LOLLMSConfig.autoload(lollms_paths) config = LOLLMSConfig.autoload(lollms_paths)
@ -518,6 +518,10 @@ try:
"/execute_code", "execute_code", self.execute_code, methods=["POST"] "/execute_code", "execute_code", self.execute_code, methods=["POST"]
) )
self.add_endpoint(
"/install_xtts", "install_xtts", self.install_xtts, methods=["GET"]
)
self.add_endpoint( self.add_endpoint(
"/open_code_folder", "open_code_folder", self.open_code_folder, methods=["POST"] "/open_code_folder", "open_code_folder", self.open_code_folder, methods=["POST"]
) )
@ -570,7 +574,16 @@ try:
def get_server_address(self): def get_server_address(self):
server_address = request.host_url server_address = request.host_url
return server_address return server_address
def install_xtts(self):
try:
self.ShowBlockingMessage("Installing xTTS api server\nPlease stand by")
PackageManager.install_package("xtts-api-server")
self.HideBlockingMessage()
return jsonify({"status":True})
except Exception as ex:
self.HideBlockingMessage()
return jsonify({"status":False, 'error':str(ex)})
def execute_python(self, code, discussion_id, message_id): def execute_python(self, code, discussion_id, message_id):
def spawn_process(code): def spawn_process(code):
"""Executes Python code and returns the output as JSON.""" """Executes Python code and returns the output as JSON."""
@ -637,12 +650,18 @@ try:
pdflatex_command = self.config.pdf_latex_path pdflatex_command = self.config.pdf_latex_path
else: else:
pdflatex_command = 'pdflatex' pdflatex_command = 'pdflatex'
# Set the execution path to the folder containing the tmp_file
execution_path = tmp_file.parent
# Run the pdflatex command with the file path # Run the pdflatex command with the file path
subprocess.run([pdflatex_command, tmp_file], check=True) result = subprocess.run([pdflatex_command, "-interaction=nonstopmode", tmp_file], check=True, capture_output=True, text=True, cwd=execution_path)
# Check the return code of the pdflatex command
if result.returncode != 0:
error_message = result.stderr.strip()
execution_time = time.time() - start_time
error_json = {"output": f"Error occurred while compiling LaTeX: {error_message}", "execution_time": execution_time}
return json.dumps(error_json)
# If the compilation is successful, you will get a PDF file # If the compilation is successful, you will get a PDF file
pdf_file = pdflatex_command.with_suffix('.pdf') pdf_file = tmp_file.with_suffix('.pdf')
print(f"PDF file generated: {pdf_file}") print(f"PDF file generated: {pdf_file}")
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
@ -654,7 +673,9 @@ try:
execution_time = time.time() - start_time execution_time = time.time() - start_time
# The child process was successful. # The child process was successful.
output_json = {"output": f"Pdf file generated at: {pdf_file}", "execution_time": execution_time} pdf_file=str(pdf_file)
url = f"{url_for('main')[:-4]}{pdf_file[pdf_file.index('outputs'):]}"
output_json = {"output": f"Pdf file generated at: {pdf_file}\n<a href='{url}'>Click here to show</a>", "execution_time": execution_time}
return json.dumps(output_json) return json.dumps(output_json)
return spawn_process(code) return spawn_process(code)

View File

Binary file not shown.

@ -1 +1 @@
Subproject commit 6d1189920683571c9df7954e41a00403ac020850 Subproject commit ce44d0c87d3750bc61d6ada70491efb8e4c15bf6

8
web/dist/assets/index-ba9f58be.css vendored Normal file

File diff suppressed because one or more lines are too long

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"> <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-5caae1db.js"></script> <script type="module" crossorigin src="/assets/index-c1cddf3b.js"></script>
<link rel="stylesheet" href="/assets/index-cefe48d9.css"> <link rel="stylesheet" href="/assets/index-ba9f58be.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@ -731,6 +731,16 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="min-width: 200px;">
<label for="install_xtts_service" class="text-sm font-bold" style="margin-right: 1rem;">Reinstall xTTS service:</label>
</td>
<td>
<div class="flex flex-row">
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallAudioService">Reinstall xtts service</button>
</div>
</td>
</tr>
<tr>
<td style="min-width: 200px;"> <td style="min-width: 200px;">
<label for="xtts_base_url" class="text-sm font-bold" style="margin-right: 1rem;">xtts base url:</label> <label for="xtts_base_url" class="text-sm font-bold" style="margin-right: 1rem;">xtts base url:</label>
</td> </td>
@ -1270,8 +1280,6 @@
<!-- PERSONALITY ZOO --> <!-- PERSONALITY ZOO -->
<div <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"> 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 items-center"> <div class="flex flex-row p-3 items-center">
<button @click.stop="pzc_collapsed = !pzc_collapsed" <button @click.stop="pzc_collapsed = !pzc_collapsed"
class="text-2xl hover:text-primary p-2 -m-2 text-left w-full flex items-center"> class="text-2xl hover:text-primary p-2 -m-2 text-left w-full flex items-center">
@ -2009,6 +2017,15 @@ export default {
//refreshHardwareUsage() //refreshHardwareUsage()
}, },
methods: { methods: {
reinstallAudioService(){
axios.get('install_xtts')
.then(response => {
})
.catch(error => {
console.error(error);
});
},
getSeviceVoices() { getSeviceVoices() {
axios.get('list_voices') axios.get('list_voices')
.then(response => { .then(response => {

@ -1 +1 @@
Subproject commit d4bb8f243945b8987d715868a2b81cebb75b553e Subproject commit 8ca6f513073eaea1db4bcd09c8b41e9f8abe2cc2