forked from t41372/Open-LLM-VTuber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_cli.py
41 lines (31 loc) · 1.18 KB
/
start_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
This module contains the main function to start the CLI.
"""
import os
import platform
import subprocess
from pathlib import Path
from utils.install_utils import InstallationManager
# Set HF_HOME to models folder in project directory
os.environ["HF_HOME"] = str(Path(__file__).parent / "models")
os.environ["MODELSCOPE_CACHE"] = str(Path(__file__).parent / "models")
def main():
# Initialize installation manager
install_mgr = InstallationManager()
# Ensure environment is set up
if not install_mgr.conda_dir.exists():
print("Conda installation not found. Running setup...")
install_mgr.setup()
# Activate environment and run main.py
install_mgr.check_environment()
if platform.system().lower() == "windows":
activate_cmd = f"call {install_mgr.activate_script} {install_mgr.env_name}"
else:
activate_cmd = f"source {install_mgr.activate_script} {install_mgr.env_name}"
run_cmd = f"{activate_cmd} && python main.py"
if platform.system().lower() == "windows":
subprocess.run(run_cmd, shell=True, check=True)
else:
subprocess.run(["bash", "-c", run_cmd], check=True)
if __name__ == "__main__":
main()