upgraded linting

This commit is contained in:
Saifeddine ALOUI
2024-12-19 13:48:57 +01:00
parent 87b878fda9
commit 3669be503f
56 changed files with 4096 additions and 2497 deletions

View File

@ -3,35 +3,41 @@ Project: lollms_installer
Author: ParisNeo
Description: This tool is designed to install and configure the LoLLMS system on your machine. LoLLMS is a multi-bindings, multi-personalities LLM full-stack system for AI applications in robotics. It provides a user-friendly interface for setting up and managing the system.
"""
import webbrowser
from pathlib import Path
import socketio
import uvicorn
from ascii_colors import ASCIIColors
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel
import uvicorn
from lollms.paths import LollmsPaths
from lollms.main_config import LOLLMSConfig
from lollms.utilities import check_and_install_torch, PackageManager, check_torch_version, reinstall_pytorch_with_cuda, reinstall_pytorch_with_cpu, reinstall_pytorch_with_rocm
from lollms.com import NotificationType, NotificationDisplayType, LoLLMsCom
from lollms.types import MSG_OPERATION_TYPE, SENDER_TYPES
from lollms.app import LollmsApplication
from pathlib import Path
from ascii_colors import ASCIIColors
from pathlib import Path
import webbrowser
import socketio
from fastapi import FastAPI
from lollms.com import LoLLMsCom, NotificationDisplayType, NotificationType
from lollms.main_config import LOLLMSConfig
from lollms.paths import LollmsPaths
from lollms.types import MSG_OPERATION_TYPE, SENDER_TYPES
from lollms.utilities import (PackageManager, check_and_install_torch,
check_torch_version, reinstall_pytorch_with_cpu,
reinstall_pytorch_with_cuda,
reinstall_pytorch_with_rocm)
from pydantic import BaseModel
from socketio import ASGIApp
root_path = Path(__file__).parent.parent.parent.parent
global_path = root_path/"global_paths_cfg.yaml"
global_path = root_path / "global_paths_cfg.yaml"
if global_path.exists():
ASCIIColors.yellow(f"global_path: {global_path}")
lollms_paths = LollmsPaths(global_path, prepare_configuration=False)
config = LOLLMSConfig.autoload(lollms_paths,lollms_paths.personal_configuration_path/"local_config.yaml")
config = LOLLMSConfig.autoload(
lollms_paths, lollms_paths.personal_configuration_path / "local_config.yaml"
)
else:
ASCIIColors.yellow(f"global_path: {global_path}")
lollms_paths = LollmsPaths(global_path, prepare_configuration=False)
config = LOLLMSConfig.autoload(lollms_paths,lollms_paths.personal_configuration_path/"local_config.yaml")
config = LOLLMSConfig.autoload(
lollms_paths, lollms_paths.personal_configuration_path / "local_config.yaml"
)
ASCIIColors.red(" ")
@ -43,28 +49,31 @@ ASCIIColors.red(" Configurator ")
ASCIIColors.red(" LoLLMS configuratoin tool")
ASCIIColors.yellow(f"Root dir : {root_path}")
sio = socketio.AsyncServer(async_mode='asgi')
sio = socketio.AsyncServer(async_mode="asgi")
app = FastAPI(title="LoLLMS", description="This is the LoLLMS-Webui documentation")
lollms_app = LollmsApplication(
"lollms_installer",
config=config,
lollms_paths=lollms_paths,
load_binding=False,
load_model=False,
load_voice_service=False,
load_sd_service=False,
socketio=sio,
free_mode=True)
"lollms_installer",
config=config,
lollms_paths=lollms_paths,
load_binding=False,
load_model=False,
load_voice_service=False,
load_sd_service=False,
socketio=sio,
free_mode=True,
)
class InstallProperties(BaseModel):
mode: str
@app.get("/get_personal_path")
def get_personal_path():
return lollms_paths.personal_path
@app.post("/start_installing")
def start_installing(data: InstallProperties):
"""
@ -77,58 +86,64 @@ def start_installing(data: InstallProperties):
- A dictionary with a "message" key indicating the success of the installation.
"""
# Install mode (cpu, cpu-noavx, nvidia-tensorcores, nvidia, amd-noavx, amd, apple-intel, apple-silicon)
if data.mode=="cpu":
config.hardware_mode="cpu"
if data.mode == "cpu":
config.hardware_mode = "cpu"
try:
lollms_app.ShowBlockingMessage("Setting hardware configuration to CPU")
config.save_config()
lollms_app.HideBlockingMessage()
except:
lollms_app.HideBlockingMessage()
if data.mode=="cpu-noavx":
config.hardware_mode="cpu-noavx"
if data.mode == "cpu-noavx":
config.hardware_mode = "cpu-noavx"
try:
lollms_app.ShowBlockingMessage("Setting hardware configuration to CPU with no avx support")
lollms_app.ShowBlockingMessage(
"Setting hardware configuration to CPU with no avx support"
)
config.save_config()
lollms_app.HideBlockingMessage()
except:
lollms_app.HideBlockingMessage()
elif data.mode=="nvidia":
config.hardware_mode="nvidia"
elif data.mode == "nvidia":
config.hardware_mode = "nvidia"
try:
lollms_app.ShowBlockingMessage("Installing pytorch for nVidia GPU (cuda)")
config.save_config()
lollms_app.HideBlockingMessage()
except:
lollms_app.HideBlockingMessage()
elif data.mode=="nvidia-tensorcores":
config.hardware_mode="nvidia-tensorcores"
elif data.mode == "nvidia-tensorcores":
config.hardware_mode = "nvidia-tensorcores"
try:
lollms_app.ShowBlockingMessage("Installing pytorch for nVidia GPU (cuda)")
config.save_config()
lollms_app.HideBlockingMessage()
except:
lollms_app.HideBlockingMessage()
elif data.mode=="amd":
config.hardware_mode="amd"
elif data.mode == "amd":
config.hardware_mode = "amd"
try:
lollms_app.ShowBlockingMessage("Installing pytorch for AMD GPU (rocm)")
config.save_config()
lollms_app.HideBlockingMessage()
except:
lollms_app.HideBlockingMessage()
elif data.mode=="apple-silicon":
config.hardware_mode="apple-silicon"
elif data.mode == "apple-silicon":
config.hardware_mode = "apple-silicon"
try:
lollms_app.ShowBlockingMessage("Installing pytorch for Apple Silicon (Metal)")
lollms_app.ShowBlockingMessage(
"Installing pytorch for Apple Silicon (Metal)"
)
config.save_config()
lollms_app.HideBlockingMessage()
except:
lollms_app.HideBlockingMessage()
elif data.mode=="apple-intel":
config.hardware_mode="apple-intel"
elif data.mode == "apple-intel":
config.hardware_mode = "apple-intel"
try:
lollms_app.ShowBlockingMessage("Installing pytorch for Apple Silicon (Metal)")
lollms_app.ShowBlockingMessage(
"Installing pytorch for Apple Silicon (Metal)"
)
config.save_config()
lollms_app.HideBlockingMessage()
except:
@ -136,9 +151,14 @@ def start_installing(data: InstallProperties):
# Your code here
return {"message": "Item created successfully"}
app.mount("/", StaticFiles(directory=Path(__file__).parent/"frontend"/"dist", html=True), name="static")
app.mount(
"/",
StaticFiles(directory=Path(__file__).parent / "frontend" / "dist", html=True),
name="static",
)
app = ASGIApp(socketio_server=sio, other_asgi_app=app)
if __name__ == "__main__":
webbrowser.open(f"http://localhost:8000")
uvicorn.run(app, host="localhost", port=8000)
uvicorn.run(app, host="localhost", port=8000)

View File

@ -1,17 +1,18 @@
from lollms.paths import LollmsPaths
from pathlib import Path
from ascii_colors import ASCIIColors
import subprocess
from pathlib import Path
global_path = Path(__file__).parent.parent.parent/"global_paths_cfg.yaml"
from ascii_colors import ASCIIColors
from lollms.paths import LollmsPaths
global_path = Path(__file__).parent.parent.parent / "global_paths_cfg.yaml"
ASCIIColors.yellow(f"global_path: {global_path}")
lollms_paths = LollmsPaths(global_path)
shared_folder = lollms_paths.personal_path/"shared"
shared_folder = lollms_paths.personal_path / "shared"
sd_folder = shared_folder / "auto_sd"
output_dir = lollms_paths.personal_path / "outputs/sd"
output_dir.mkdir(parents=True, exist_ok=True)
script_path = sd_folder / "lollms_sd.bat"
output_folder = lollms_paths.personal_outputs_path/"audio_out"
output_folder = lollms_paths.personal_outputs_path / "audio_out"
ASCIIColors.red(" ")
ASCIIColors.red(" __ _____ __ __ _____ _____ _____ ____ ")
@ -24,4 +25,4 @@ ASCIIColors.red(" Forked from Auto1111's Stable diffusion api")
ASCIIColors.red(" Integration in lollms by ParisNeo using mix1009's sdwebuiapi ")
subprocess.Popen(str(script_path) +" --share", cwd=sd_folder)
subprocess.Popen(str(script_path) + " --share", cwd=sd_folder)

View File

@ -1,21 +1,44 @@
from lollms.paths import LollmsPaths
from pathlib import Path
from ascii_colors import ASCIIColors
import subprocess
from pathlib import Path
global_path = Path(__file__).parent.parent.parent/"global_paths_cfg.yaml"
from ascii_colors import ASCIIColors
from lollms.paths import LollmsPaths
global_path = Path(__file__).parent.parent.parent / "global_paths_cfg.yaml"
ASCIIColors.yellow(f"global_path: {global_path}")
lollms_paths = LollmsPaths(global_path)
output_folder = lollms_paths.personal_outputs_path/"audio_out"
output_folder = lollms_paths.personal_outputs_path / "audio_out"
ASCIIColors.red(".____ ________ .____ .____ _____ _________ ____ __________________________________ ")
ASCIIColors.red("| | \_____ \ | | | | / \ / _____/ \ \/ /\__ ___/\__ ___/ _____/ ")
ASCIIColors.red("| | / | \| | | | / \ / \ \_____ \ ______ \ / | | | | \_____ \ ")
ASCIIColors.red("| |___/ | \ |___| |___/ Y \/ \ /_____/ / \ | | | | / \ ")
ASCIIColors.red("|_______ \_______ /_______ \_______ \____|__ /_______ / /___/\ \ |____| |____| /_______ / ")
ASCIIColors.red(" \/ \/ \/ \/ \/ \/ \_/ \/ ")
ASCIIColors.red(
".____ ________ .____ .____ _____ _________ ____ __________________________________ "
)
ASCIIColors.red(
"| | \_____ \ | | | | / \ / _____/ \ \/ /\__ ___/\__ ___/ _____/ "
)
ASCIIColors.red(
"| | / | \| | | | / \ / \ \_____ \ ______ \ / | | | | \_____ \ "
)
ASCIIColors.red(
"| |___/ | \ |___| |___/ Y \/ \ /_____/ / \ | | | | / \ "
)
ASCIIColors.red(
"|_______ \_______ /_______ \_______ \____|__ /_______ / /___/\ \ |____| |____| /_______ / "
)
ASCIIColors.red(
" \/ \/ \/ \/ \/ \/ \_/ \/ "
)
ASCIIColors.red(" Forked from daswer123's XTTS server")
ASCIIColors.red(" Integration in lollms by ParisNeo using daswer123's webapi ")
subprocess.Popen(["python", "-m", "xtts_api_server", "-o", f"{output_folder}", "-sf", f"{lollms_paths.custom_voices_path}"])
subprocess.Popen(
[
"python",
"-m",
"xtts_api_server",
"-o",
f"{output_folder}",
"-sf",
f"{lollms_paths.custom_voices_path}",
]
)