-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
67 lines (48 loc) · 1.77 KB
/
run.py
File metadata and controls
67 lines (48 loc) · 1.77 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
# ============================================================
# Offline AI Chat (UI-only orchestrator)
# - No imports from module code.
# - Each module is fully self-contained under ./apps/<module>/.
# ============================================================
def project_root() -> Path:
return Path(__file__).resolve().parent
def _run_module(entrypoint: Path) -> int:
if not entrypoint.exists():
print(f"ERROR: module entrypoint not found: {entrypoint}")
return 2
cmd = [sys.executable, str(entrypoint)]
p = subprocess.run(cmd, cwd=str(project_root()), env=os.environ.copy())
return int(p.returncode)
def ui_main() -> int:
root = project_root()
modules = {
"1": ("Offline AI Chat", root / "apps" / "offline_llm_chat" / "cli.py"),
"2": ("System Analyzer", root / "apps" / "offline_llm_chat" / "system_analyzer_cli.py"),
}
while True:
print("\n=== Offline AI Chat ===")
print("")
print("1) Offline AI Chat")
print("2) System Analyzer")
print("3) Exit")
choice = input("Select (1..3): ").strip()
if choice in ("1", "2"):
title, entry = modules[choice]
if not entry.exists():
print(f"\n[skip] Module is not available on disk: {title}")
print(f"Missing: {entry}")
continue
rc = _run_module(entry)
if rc != 0:
print(f"\n[error] Module exited with rc={rc}: {title}")
continue
if choice == "3":
return 0
print("Invalid selection. Try again.")
if __name__ == "__main__":
raise SystemExit(ui_main())