from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    """LLM Redact client settings"""
    
    # LLM Host settings
    llm_host_url: str = "http://localhost:8000"
    default_model: str = "gemma3:1b"
    
    # Database settings
    database_url: str = "sqlite:///llm_redact.db"
    
    # Redaction settings
    enable_caching: bool = True
    cache_ttl_hours: int = 24
    
    class Config:
        env_prefix = "LLM_REDACT_"
        env_file = ".env"


# Global settings instance
_settings = None


def get_settings() -> Settings:
    """Get the current settings instance"""
    global _settings
    if _settings is None:
        _settings = Settings()
    return _settings


def configure(**kwargs) -> Settings:
    """Configure settings with custom values"""
    global _settings
    # Update existing settings or create new ones
    if _settings is None:
        _settings = Settings(**kwargs)
    else:
        for key, value in kwargs.items():
            if hasattr(_settings, key):
                setattr(_settings, key, value)
    return _settings 