#!/usr/bin/env python3 """Entry point for Heavy 2.0.""" import os import sys # Detect if running on Hugging Face Spaces IS_SPACE = os.getenv("SPACE_ID") is not None if not IS_SPACE: # Local configuration only os.environ["GRADIO_ANALYTICS_ENABLED"] = "False" os.environ["GRADIO_SERVER_NAME"] = "127.0.0.1" # Remove proxy settings that might interfere for proxy_var in ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy', 'ALL_PROXY', 'all_proxy']: if proxy_var in os.environ: del os.environ[proxy_var] # Set no proxy to bypass any remaining proxy configs os.environ["NO_PROXY"] = "*" os.environ["no_proxy"] = "*" # Monkey-patch Gradio to avoid schema generation crashes on Spaces import gradio gradio.version_check = lambda: None # Disable version check try: # Make schema-to-python conversion tolerant of booleans or other unexpected shapes import gradio_client.utils as grc_utils _orig_json_schema_to_python_type = grc_utils.json_schema_to_python_type def _safe_json_schema_to_python_type(schema, defs=None): if isinstance(schema, bool): return "any" try: return _orig_json_schema_to_python_type(schema, defs) except Exception: return "any" grc_utils.json_schema_to_python_type = _safe_json_schema_to_python_type except Exception: pass # Import the demo from multi_web_combined (with chat support!) from src.multi_web_combined import demo if __name__ == "__main__": print("šŸ¤– Heavy 2.0 - Starting...") # Enable queue for better performance demo.queue() if IS_SPACE: # Hugging Face Spaces configuration print("🌐 Running on Hugging Face Spaces") demo.launch( show_error=True, show_api=False, share=True, # Required when localhost not accessible in Spaces server_name="0.0.0.0", server_port=7860, ) else: # Local development configuration print("🌐 Server will be available at: http://127.0.0.1:7860") print() try: demo.launch( server_name="127.0.0.1", # Local only to avoid network issues server_port=7860, share=False, show_error=True, favicon_path=None, inbrowser=True, # Auto-open browser show_api=False, # Disable API documentation prevent_thread_lock=False ) except Exception as e: print(f"āŒ Error launching: {e}") print("\nšŸ’” Try opening http://127.0.0.1:7860 in your browser manually") # Keep server running even if browser launch fails import time try: while True: time.sleep(1) except KeyboardInterrupt: print("\nšŸ‘‹ Shutting down...")