Spaces:
Runtime error
Runtime error
| """ | |
| LLMGuardian Dashboard Demo Script | |
| ================================== | |
| This script launches the LLMGuardian security dashboard in demo mode | |
| with pre-populated data for testing and demonstration purposes. | |
| Usage: | |
| python demo_dashboard.py | |
| Requirements: | |
| - streamlit | |
| - plotly | |
| - pandas | |
| - numpy | |
| The dashboard will be available at http://localhost:8501 | |
| """ | |
| import subprocess | |
| import sys | |
| import os | |
| from pathlib import Path | |
| def check_dependencies(): | |
| """Check if required dependencies are installed""" | |
| required = ['streamlit', 'plotly', 'pandas', 'numpy'] | |
| missing = [] | |
| for package in required: | |
| try: | |
| __import__(package) | |
| except ImportError: | |
| missing.append(package) | |
| return missing | |
| def install_dependencies(packages): | |
| """Install missing dependencies""" | |
| print(f"Installing missing dependencies: {', '.join(packages)}") | |
| subprocess.check_call([sys.executable, '-m', 'pip', 'install'] + packages) | |
| def main(): | |
| print("=" * 60) | |
| print("LLMGuardian Dashboard Demo") | |
| print("=" * 60) | |
| print() | |
| # Check dependencies | |
| missing = check_dependencies() | |
| if missing: | |
| print(f"β οΈ Missing dependencies detected: {', '.join(missing)}") | |
| response = input("Would you like to install them now? (y/n): ") | |
| if response.lower() == 'y': | |
| install_dependencies(missing) | |
| print("β Dependencies installed successfully!") | |
| else: | |
| print("β Cannot run dashboard without required dependencies.") | |
| return | |
| print("β All dependencies are installed") | |
| print() | |
| # Get the dashboard script path | |
| script_dir = Path(__file__).parent | |
| dashboard_path = script_dir / "src" / "llmguardian" / "dashboard" / "app.py" | |
| if not dashboard_path.exists(): | |
| print(f"β Dashboard script not found at: {dashboard_path}") | |
| return | |
| print("π Starting LLMGuardian Dashboard in demo mode...") | |
| print() | |
| print("π Dashboard Features:") | |
| print(" β’ Real-time security monitoring") | |
| print(" β’ Threat detection and analysis") | |
| print(" β’ Privacy violation tracking") | |
| print(" β’ Usage analytics and metrics") | |
| print(" β’ Interactive security scanner") | |
| print() | |
| print("π Dashboard will open at: http://localhost:8501") | |
| print("βΉοΈ Press Ctrl+C to stop the dashboard") | |
| print() | |
| print("=" * 60) | |
| print() | |
| # Run streamlit with the dashboard | |
| try: | |
| subprocess.run([ | |
| sys.executable, '-m', 'streamlit', 'run', | |
| str(dashboard_path), | |
| '--server.port=8501', | |
| '--server.address=localhost', | |
| '--', | |
| '--demo' | |
| ]) | |
| except KeyboardInterrupt: | |
| print("\n\nπ Dashboard stopped. Thank you for using LLMGuardian!") | |
| except Exception as e: | |
| print(f"\nβ Error running dashboard: {e}") | |
| if __name__ == "__main__": | |
| main() | |