"""Initialize and download models in Hugging Face Spaces environment.""" import os import asyncio import logging from huggingface_hub import HfApi from reasoning.model_manager import ModelManager # Configure logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) async def initialize_space_models(): """Download and initialize models in Spaces environment.""" try: # Initialize model manager manager = ModelManager() # Download all models logger.info("Starting model downloads in Spaces environment...") await manager.initialize_all_models() logger.info("All models downloaded and initialized successfully!") return True except Exception as e: logger.error(f"Error initializing models in Spaces: {e}") return False if __name__ == "__main__": # Initialize models in Spaces asyncio.run(initialize_space_models())