mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2025-02-25 10:42:18 +00:00
Added a tool to install all personalities
This commit is contained in:
parent
d77b83323f
commit
0508e559b8
16
installations/download_all_personalities.bat
Normal file
16
installations/download_all_personalities.bat
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
rem Set the environment name
|
||||||
|
set environment_name=env
|
||||||
|
|
||||||
|
rem Activate the virtual environment
|
||||||
|
call %environment_name%\Scripts\activate.bat
|
||||||
|
|
||||||
|
rem Change to the installations subfolder
|
||||||
|
|
||||||
|
rem Run the Python script
|
||||||
|
python installations/download_all_personalities.py
|
||||||
|
|
||||||
|
rem Deactivate the virtual environment
|
||||||
|
echo deactivating
|
||||||
|
call %environment_name%\Scripts\deactivate.bat
|
55
installations/download_all_personalities.py
Normal file
55
installations/download_all_personalities.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
def copy_files(source_path, destination_path):
|
||||||
|
for item in os.listdir(source_path):
|
||||||
|
source_item = source_path / item
|
||||||
|
destination_item = destination_path / item
|
||||||
|
|
||||||
|
if source_item.is_file():
|
||||||
|
# Remove destination file if it already exists
|
||||||
|
if destination_item.exists():
|
||||||
|
destination_item.unlink()
|
||||||
|
|
||||||
|
# Copy file from source to destination
|
||||||
|
shutil.copy2(str(source_item), str(destination_item))
|
||||||
|
|
||||||
|
elif source_item.is_dir():
|
||||||
|
# Create destination directory if it does not exist
|
||||||
|
destination_item.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# Recursively copy files in subdirectories
|
||||||
|
copy_files(source_item, destination_item)
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
def clone_and_copy_repository(repo_url):
|
||||||
|
tmp_folder = Path("tmp/git_clone")
|
||||||
|
personalities_folder = Path("personalities")
|
||||||
|
subfolder_name = "personalities_zoo"
|
||||||
|
|
||||||
|
# Clone the repository to a temporary folder
|
||||||
|
subprocess.run(["git", "clone", repo_url, str(tmp_folder)])
|
||||||
|
|
||||||
|
# Check if the repository was cloned successfully
|
||||||
|
if not tmp_folder.exists():
|
||||||
|
print("Failed to clone the repository.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Construct the source and destination paths for copying the subfolder
|
||||||
|
subfolder_path = tmp_folder / subfolder_name
|
||||||
|
destination_path = Path.cwd() / personalities_folder
|
||||||
|
|
||||||
|
# Copy files and folders recursively
|
||||||
|
print(f"copying")
|
||||||
|
copy_files(subfolder_path, destination_path)
|
||||||
|
|
||||||
|
# Remove the temporary folder
|
||||||
|
shutil.rmtree(str(tmp_folder))
|
||||||
|
|
||||||
|
print("Repository clone and copy completed successfully.")
|
||||||
|
|
||||||
|
# Example usage
|
||||||
|
repo_url = "https://github.com/ParisNeo/PyAIPersonality.git"
|
||||||
|
clone_and_copy_repository(repo_url)
|
16
installations/download_all_personalities.sh
Normal file
16
installations/download_all_personalities.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set the environment name
|
||||||
|
environment_name="env"
|
||||||
|
|
||||||
|
# Activate the virtual environment
|
||||||
|
source "$environment_name/Scripts/activate"
|
||||||
|
|
||||||
|
# Change to the installations subfolder
|
||||||
|
|
||||||
|
# Run the Python script
|
||||||
|
python installations/download_all_personalities.py
|
||||||
|
|
||||||
|
# Deactivate the virtual environment
|
||||||
|
echo "deactivating"
|
||||||
|
deactivate
|
Loading…
x
Reference in New Issue
Block a user