Spaces:
Runtime error
Runtime error
#!/usr/bin/env python3 | |
""" | |
DigiPal - HuggingFace Spaces Entry Point | |
Simplified launcher for HuggingFace Spaces deployment. | |
""" | |
import sys | |
import os | |
import logging | |
from pathlib import Path | |
# Add the project root to Python path | |
project_root = Path(__file__).parent | |
sys.path.insert(0, str(project_root)) | |
from digipal.core.digipal_core import DigiPalCore | |
from digipal.storage.storage_manager import StorageManager | |
from digipal.ai.communication import AICommunication | |
from digipal.auth.auth_manager import AuthManager | |
from digipal.storage.database import DatabaseConnection | |
from digipal.ui.gradio_interface import GradioInterface | |
from config import get_config | |
# Configure logging for HF Spaces | |
logging.basicConfig( | |
level=logging.INFO, | |
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
) | |
logger = logging.getLogger(__name__) | |
def main(): | |
"""Main function for HuggingFace Spaces deployment.""" | |
logger.info("๐ฅ Starting DigiPal on HuggingFace Spaces...") | |
try: | |
# Get configuration | |
config = get_config() | |
# Override for HF Spaces | |
config.gradio.server_name = "0.0.0.0" | |
config.gradio.server_port = 7860 | |
config.gradio.share = False | |
config.env = "production" | |
# Initialize storage manager | |
db_path = "assets/digipal.db" | |
os.makedirs(os.path.dirname(db_path), exist_ok=True) | |
storage_manager = StorageManager(db_path) | |
logger.info(f"๐พ Storage initialized: {db_path}") | |
# Initialize AI communication | |
ai_communication = AICommunication() | |
logger.info("๐ค AI system initialized") | |
# Initialize DigiPal core | |
digipal_core = DigiPalCore(storage_manager, ai_communication) | |
logger.info("๐ฎ DigiPal core ready") | |
# Initialize auth manager | |
db_connection = DatabaseConnection(db_path) | |
auth_manager = AuthManager(db_connection) | |
logger.info("๐ Authentication ready") | |
# Initialize Gradio interface | |
gradio_interface = GradioInterface(digipal_core, auth_manager) | |
logger.info("๐ Interface ready") | |
logger.info("โ DigiPal ready on HuggingFace Spaces!") | |
# Launch the interface | |
gradio_interface.launch_interface( | |
share=False, | |
server_name="0.0.0.0", | |
server_port=7860, | |
debug=False | |
) | |
except Exception as e: | |
logger.error(f"โ Failed to start DigiPal: {e}") | |
raise e | |
if __name__ == "__main__": | |
main() |