"""
FastAPI Dependencies

This module contains dependency injection functions to avoid circular imports.
"""

from .models.predictor import ModelPredictor

# Global model predictor instance (set by main.py during startup)
model_predictor: ModelPredictor = None


def get_predictor() -> ModelPredictor:
    """
    Dependency to get the global model predictor instance
    
    Returns:
        ModelPredictor: The global predictor instance
        
    Raises:
        RuntimeError: If model is not loaded
    """
    if model_predictor is None:
        raise RuntimeError("Model not loaded")
    return model_predictor


def set_predictor(predictor: ModelPredictor) -> None:
    """
    Set the global model predictor instance
    
    Args:
        predictor: ModelPredictor instance to set globally
    """
    global model_predictor
    model_predictor = predictor

