This commit is contained in:
Saifeddine ALOUI 2024-09-15 01:37:41 +02:00
parent e4820efe9a
commit 840bcfe6cb
14 changed files with 372 additions and 212 deletions

9
app.py
View File

@ -243,7 +243,11 @@ if __name__ == "__main__":
from lollms.server.endpoints.lollms_user import router as lollms_user_router
from lollms.server.endpoints.lollms_tts import router as lollms_xtts_add_router
from lollms.server.endpoints.lollms_tts import router as lollms_tts_add_router
from lollms.server.endpoints.lollms_xtts import router as lollms_xtts_add_router
from lollms.server.endpoints.lollms_whisper import router as lollms_whisper
from lollms.server.endpoints.lollms_sd import router as lollms_sd_router
from lollms.server.endpoints.lollms_diffusers import router as lollms_diffusers_router
@ -308,7 +312,10 @@ if __name__ == "__main__":
app.include_router(chat_bar_router)
app.include_router(help_router)
app.include_router(lollms_tts_add_router)
app.include_router(lollms_xtts_add_router)
app.include_router(lollms_whisper)
app.include_router(lollms_sd_router)
app.include_router(lollms_diffusers_router)

View File

@ -327,6 +327,13 @@ async def upload_app(client_id: str, file: UploadFile = File(...)):
import shutil
from pathlib import Path
import json
# Function to get the current conda environment
def get_current_conda_env():
result = subprocess.run(['conda', 'info', '--json'], capture_output=True, text=True)
conda_info = json.loads(result.stdout)
return conda_info['active_prefix_name']
@router.post("/install/{app_name}")
async def install_app(app_name: str, auth: AuthRequest):
@ -353,6 +360,51 @@ async def install_app(app_name: str, auth: AuthRequest):
else:
shutil.copy2(item, app_path)
try:
description_path = app_path/"description.yaml"
requirements = app_path/"requirements.txt"
if description_path.exists() and requirements.exists():
with open(description_path, 'r') as file:
description_data = yaml.safe_load(file)
if description_data.get("has_server", False):
current_env = get_current_conda_env()
env_name = app_path.stem
import conda.cli
ASCIIColors.info("Creating a new environment")
conda.cli.main('create', '-n', env_name, 'python=3.11', '-y')
# Activate the new conda environment
activate_command = f"conda activate {env_name}"
if os.name == 'nt': # Windows
activate_command = f"call activate {env_name}"
# Install requirements
install_command = f"{activate_command} && pip install -r {requirements}"
try:
ASCIIColors.info(f"Creating a new environment: {env_name}")
subprocess.run(activate_command, shell=True, check=True)
ASCIIColors.info("Installing requirements")
subprocess.run(install_command, shell=True, check=True)
ASCIIColors.success(f"Environment '{env_name}' created and requirements installed successfully.")
except subprocess.CalledProcessError as e:
ASCIIColors.error(f"An error occurred: {str(e)}")
finally:
# Switch back to the original environment
if current_env:
switch_back_command = f"conda activate {current_env}"
if os.name == 'nt': # Windows
switch_back_command = f"call activate {current_env}"
ASCIIColors.info(f"Switching back to the original environment: {current_env}")
subprocess.run(switch_back_command, shell=True, check=True)
else:
ASCIIColors.warning("Could not determine the original environment. You may need to switch back manually.")
except Exception as ex:
trace_exception(ex)
return {"message": f"App {app_name} installed successfully."}
@router.post("/uninstall/{app_name}")

43
environment.yaml Normal file
View File

@ -0,0 +1,43 @@
name: lollms_env
channels:
- defaults
- conda-forge # Adds a wider selection of packages, especially for less common ones
dependencies:
- python=3.11
- numpy=1.26.*
- pandas
- pillow>=9.5.0
- pyyaml
- requests
- rich
- scipy
- tqdm
- setuptools
- wheel
- psutil
- pytest
- gitpython
- beautifulsoup4
- packaging
- fastapi
- uvicorn
- pydantic
- selenium
- aiofiles
- ffmpeg
- pip # Conda will manage pip installation
- pip:
- colorama
- ascii-colors>=0.4.2
- python-multipart
- python-socketio
- python-socketio[client]
- python-socketio[asyncio_client]
- tiktoken
- pipmaster>=0.1.7
- lollmsvectordb>=1.1.0
- freedom-search>=0.1.9
- scrapemaster>=0.2.0
- lollms_client>=0.7.5
- zipfile36
- freedom_search

@ -1 +1 @@
Subproject commit fe562543b4e6811f98bc42e58aa06c46dd441c46
Subproject commit 04500070eba0729a40c45b17e42a6c6089b29549

View File

@ -1,5 +1,5 @@
colorama
numpy==1.26.3
numpy==1.26.*
pandas
Pillow>=9.5.0
pyyaml
@ -29,11 +29,11 @@ tiktoken
pipmaster>=0.1.7
lollmsvectordb>=1.0.5
lollmsvectordb>=1.1.0
freedom-search>=0.1.9
scrapemaster
lollms_client
scrapemaster>=0.2.0
freedom_search
lollms_client>=0.7.5
aiofiles
python-multipart

View File

@ -92,6 +92,20 @@ source activate "$INSTALL_ENV_DIR" || ( echo && echo "Conda environment activati
# install conda
conda install conda -y
echo "Installing pytorch (Required for RAG)"
# Check if CUDA-enabled device is available
if command -v nvidia-smi &> /dev/null && nvidia-smi > /dev/null 2>&1; then
echo "CUDA-enabled device detected."
echo "Installing PyTorch with CUDA support..."
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
else
echo "No CUDA-enabled device detected."
echo "Installing PyTorch for CPU only..."
pip install torch torchvision torchaudio
fi
echo "PyTorch installation complete."
# Set default cuda toolkit to the one in the environment
export CUDA_PATH="$INSTALL_ENV_DIR"

View File

@ -147,6 +147,10 @@ source activate "$ENV_NAME" || ( echo && echo "Conda environment activation fail
# install conda
conda install conda -y
#Install pytorch (required for RAG)
echo "Installing pytorch (required for RAG)"
pip install torch torchvision torchaudio
echo "$ENV_NAME Activated"
# Set default CUDA toolkit to the one in the environment
export CUDA_PATH="$INSTALL_ENV_DIR"

View File

@ -3,18 +3,8 @@
@rem This script will install miniconda and git with all dependencies for this project
@rem This enables a user to install this project without manually installing conda and git.
echo " ___ ___ ___ ___ ___ ___ "
echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ "
echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ "
echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ "
echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ "
echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ "
echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ "
echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ "
echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / "
echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / "
echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ "
echo V12
echo "L🍓LLMS: Lord of Large Language and Multimodal Systems"
echo V12 Strawberry
echo -----------------
echo By ParisNeo
echo -----------------
@ -83,6 +73,19 @@ call conda activate "%INSTALL_ENV_DIR%" || ( echo. && echo Conda environment act
@rem install conda library
call conda install conda -y
echo Installing pytorch (required for RAG)
:: Check if CUDA-enabled device is available
nvidia-smi >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
echo CUDA-enabled device detected.
echo Installing PyTorch with CUDA support...
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia -y
) ELSE (
echo No CUDA-enabled device detected.
echo Installing PyTorch for CPU only...
cconda install pytorch torchvision torchaudio cpuonly -c pytorch -y
)
@rem clone the repository
if exist lollms-webui\ (
@ -103,7 +106,7 @@ if exist lollms-webui\ (
cd
pip install -r requirements.txt
conda env update --file environment.yml
@rem create launcher
if exist ..\win_run.bat (

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 @@
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LoLLMS WebUI</title>
<script type="module" crossorigin src="/assets/index-1a16f704.js"></script>
<link rel="stylesheet" href="/assets/index-a6119f57.css">
<script type="module" crossorigin src="/assets/index-51c00f60.js"></script>
<link rel="stylesheet" href="/assets/index-64721b5a.css">
</head>
<body>
<div id="app"></div>

View File

@ -2413,22 +2413,31 @@
</Card>
<Card title="Whisper audio transcription" :is_subcard="true" class="pb-2 m-2">
<table class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
<tr>
<td style="min-width: 200px;">
<label for="whisper_activate" class="text-sm font-bold" style="margin-right: 1rem;">Activate Whisper at startup:</label>
</td>
<td>
<div class="flex flex-row">
<input
type="checkbox"
id="whisper_activate"
required
v-model="configFile.whisper_activate"
@change="settingsChanged=true"
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
>
</div>
</td>
</tr>
<tr>
<td style="min-width: 200px;">
<label for="whisper_activate" class="text-sm font-bold" style="margin-right: 1rem;">Activate Whisper at startup:</label>
<label for="xtts_current_language" class="text-sm font-bold" style="margin-right: 1rem;"></label>
</td>
<td>
<div class="flex flex-row">
<input
type="checkbox"
id="whisper_activate"
required
v-model="configFile.whisper_activate"
@change="settingsChanged=true"
class="mt-1 px-2 py-1 border border-gray-300 rounded dark:bg-gray-600"
>
</div>
</td> </tr>
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallWhisperService">install whisper</button>
</td>
</tr>
<tr>
<td style="min-width: 200px;">
<label for="whisper_model" class="text-sm font-bold" style="margin-right: 1rem;">Whisper model:</label>
@ -2556,6 +2565,14 @@
</Card>
<Card title="XTTS service" :is_subcard="true" class="pb-2 m-2">
<table class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
<tr>
<td style="min-width: 200px;">
<label for="xtts_current_language" class="text-sm font-bold" style="margin-right: 1rem;">Current language:</label>
</td>
<td>
<button class="hover:text-primary bg-green-200 rounded-lg p-4 m-4 w-full text-center items-center" @click="reinstallXTTSService">install xtts service</button>
</td>
</tr>
<tr>
<td style="min-width: 200px;">
<label for="xtts_current_language" class="text-sm font-bold" style="margin-right: 1rem;">Current language:</label>
@ -4621,7 +4638,27 @@ export default {
},
upgradeDiffusersService(){
axios.post('upgrade_sd', {client_id:this.$store.state.client_id}, this.posts_headers)
axios.post('install_diffusers', {client_id:this.$store.state.client_id}, this.posts_headers)
.then(response => {
})
.catch(error => {
console.error(error);
});
},
reinstallXTTSService(){
axios.post('install_xtts', {client_id:this.$store.state.client_id}, this.posts_headers)
.then(response => {
})
.catch(error => {
console.error(error);
});
},
reinstallWhisperService(){
axios.post('install_whisper', {client_id:this.$store.state.client_id}, this.posts_headers)
.then(response => {
})

@ -1 +1 @@
Subproject commit 358a64a034c7651a8b551cf20bd9bb2059f8835a
Subproject commit b3ede8b00a216c0ea9fbd885c44085a12999bbc7

@ -1 +1 @@
Subproject commit 299134098a0b43b920e2194d43fb70f936c2dd62
Subproject commit 94623140d0d5473716998713a8cf63feed27c919