File size: 5,907 Bytes
7dfe46c |
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
import sys
import subprocess
import os
from pathlib import Path
def print_banner():
"""Print welcome banner."""
print("=" * 70)
print("π°π· Korean Q&A Evaluation System - Demo Launcher")
print("=" * 70)
print()
def print_options():
"""Print available demo options."""
print("π± Available Demo Interfaces:")
print()
print("1. π― Gradio Demo (Recommended)")
print(" - Interactive web interface")
print(" - Real-time evaluation")
print(" - Shareable public links")
print(" - Best for: Quick testing and sharing")
print()
print("2. π Streamlit Dashboard")
print(" - Professional analytics interface")
print(" - Advanced visualizations")
print(" - Detailed metrics analysis")
print(" - Best for: In-depth analysis")
print()
print("3. π₯οΈ Command Line Interface")
print(" - Traditional CLI evaluation")
print(" - Batch processing")
print(" - Automated workflows")
print(" - Best for: Production use")
print()
print("4. π§ͺ Test Setup")
print(" - Verify system configuration")
print(" - Check dependencies")
print(" - Validate API keys")
print()
print("0. β Exit")
print()
def launch_gradio():
"""Launch Gradio demo."""
print("π Launching Gradio Demo...")
print("π± Will be available at: http://localhost:7860")
print("π Public link will be generated for sharing")
print()
try:
subprocess.run([sys.executable, "gradio_demo.py"], check=True)
except KeyboardInterrupt:
print("\nπ Gradio demo stopped")
except Exception as e:
print(f"β Error launching Gradio: {e}")
def launch_streamlit():
"""Launch Streamlit demo."""
print("π Launching Streamlit Dashboard...")
print("π± Will be available at: http://localhost:8501")
print()
try:
subprocess.run([
sys.executable, "-m", "streamlit", "run", "streamlit_demo.py",
"--server.port", "8501",
"--server.address", "0.0.0.0",
"--browser.gatherUsageStats", "false"
], check=True)
except KeyboardInterrupt:
print("\nπ Streamlit demo stopped")
except Exception as e:
print(f"β Error launching Streamlit: {e}")
def launch_cli():
"""Launch CLI interface."""
print("π₯οΈ Command Line Interface Options:")
print()
print("1. Quick evaluation with default settings")
print("2. Custom evaluation with parameters")
print("3. Back to main menu")
print()
choice = input("Select option (1-3): ").strip()
if choice == "1":
print("π Running quick evaluation...")
try:
subprocess.run([sys.executable, "run_evaluation.py"], check=True)
except Exception as e:
print(f"β Error: {e}")
elif choice == "2":
print("π Custom Evaluation Parameters:")
dataset = input("Dataset path (default: assets/bench_korean.csv): ").strip()
if not dataset:
dataset = "assets/bench_korean.csv"
threshold = input("Threshold (default: 0.8): ").strip()
if not threshold:
threshold = "0.8"
log_level = input("Log level (DEBUG/INFO/WARNING/ERROR, default: INFO): ").strip()
if not log_level:
log_level = "INFO"
verbose = input("Verbose mode? (y/n, default: y): ").strip().lower()
verbose_flag = "--verbose" if verbose != "n" else ""
cmd = [
sys.executable, "main.py",
"--dataset", dataset,
"--threshold", threshold,
"--log-level", log_level
]
if verbose_flag:
cmd.append(verbose_flag)
print(f"π Running: {' '.join(cmd)}")
try:
subprocess.run(cmd, check=True)
except Exception as e:
print(f"β Error: {e}")
elif choice == "3":
return
else:
print("β Invalid option")
def test_setup():
"""Run setup test."""
print("π§ͺ Testing system setup...")
try:
subprocess.run([sys.executable, "test_setup.py"], check=True)
except Exception as e:
print(f"β Setup test failed: {e}")
def check_dependencies():
"""Check if required packages are installed."""
required_packages = [
"gradio", "streamlit", "plotly", "deepeval",
"pandas"
]
missing_packages = []
for package in required_packages:
try:
__import__(package)
except ImportError:
missing_packages.append(package)
if missing_packages:
print("β οΈ Missing required packages:")
for package in missing_packages:
print(f" - {package}")
print()
print("π¦ Install missing packages with:")
print(" pip install -r requirements.txt")
print()
return False
return True
def main():
"""Main demo launcher."""
print_banner()
# Check dependencies
if not check_dependencies():
sys.exit(1)
while True:
print_options()
choice = input("Select an option (0-4): ").strip()
if choice == "1":
launch_gradio()
elif choice == "2":
launch_streamlit()
elif choice == "3":
launch_cli()
elif choice == "4":
test_setup()
elif choice == "0":
print("π Goodbye!")
break
else:
print("β Invalid option. Please try again.")
print("\n" + "=" * 50 + "\n")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\nπ Demo launcher stopped")
except Exception as e:
print(f"β Unexpected error: {e}")
sys.exit(1) |