- Introduced GlobalModuleSettings model for platform-wide module enable/disable settings. - Added 'caption' field to Images model to store image captions. - Updated GenerateImagePromptsFunction to handle new caption structure in prompts. - Enhanced AIPromptViewSet to return global prompt types and validate active prompts. - Modified serializers and views to accommodate new caption field and global settings. - Updated frontend components to display captions and filter prompts based on active types. - Created migrations for GlobalModuleSettings and added caption field to Images.
27 lines
913 B
Python
27 lines
913 B
Python
"""
|
|
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
|
|
|