"""
System utilities - default prompts and helper functions
"""
from typing import Optional


def get_default_prompt(prompt_type: str) -> str:
    """
    Get default prompt value from GlobalAIPrompt ONLY - single source of truth.
    No hardcoded fallbacks. Admin must configure prompts in GlobalAIPrompt table.
    """
    from .global_settings_models import GlobalAIPrompt
    
    try:
        global_prompt = GlobalAIPrompt.objects.get(prompt_type=prompt_type, is_active=True)
        return global_prompt.prompt_value
    except GlobalAIPrompt.DoesNotExist:
        error_msg = (
            f"ERROR: Global prompt '{prompt_type}' not configured. "
            f"Please configure it in Django admin at: /admin/system/globalaiprompt/"
        )
        return error_msg
    except Exception as e:
        error_msg = f"ERROR: Failed to load global prompt '{prompt_type}': {str(e)}"
        return error_msg

