""" Email Rule Agent - HuggingFace Spaces App Main entry point for the Gradio interface """ import os import sys import argparse from dotenv import load_dotenv # Load environment variables load_dotenv() # Add components to path sys.path.append(os.path.dirname(__file__)) from components.ui import create_app, launch_app def main(): # Simple setup - prioritize HF Spaces deployment modal_url = os.getenv('MODAL_BACKEND_URL', 'local://mock') if not os.getenv('OPENROUTER_API_KEY'): print("⚠️ Warning: OPENROUTER_API_KEY not set") print("The AI agent features will not work properly.") # Create and launch the app demo = create_app(modal_url) # Check if running on HF Spaces is_hf_spaces = os.getenv('SPACE_ID') is not None # Launch with appropriate settings demo.launch( server_name="0.0.0.0" if is_hf_spaces else None, server_port=7860 if is_hf_spaces else None ) if __name__ == "__main__": main()