Add SEO fields to Tasks model, improve content generation response handling, and enhance progress bar animation
- Added primary_keyword, secondary_keywords, tags, and categories fields to Tasks model - Updated generate_content function to handle full JSON response with all SEO fields - Improved progress bar animation: smooth 1% increments every 300ms - Enhanced step detection for content generation vs clustering vs ideas - Fixed progress modal to show correct messages for each function type - Added comprehensive logging to Keywords and Tasks pages for AI functions - Fixed error handling to show meaningful error messages instead of generic failures
This commit is contained in:
92
backend/igny8_core/ai/settings.py
Normal file
92
backend/igny8_core/ai/settings.py
Normal file
@@ -0,0 +1,92 @@
|
||||
"""
|
||||
AI Settings - Centralized model configurations and limits
|
||||
"""
|
||||
from typing import Dict, Any
|
||||
|
||||
# Model configurations for each AI function
|
||||
MODEL_CONFIG = {
|
||||
"auto_cluster": {
|
||||
"model": "gpt-4o-mini",
|
||||
"max_tokens": 3000,
|
||||
"temperature": 0.7,
|
||||
"response_format": {"type": "json_object"}, # Auto-enabled for JSON mode models
|
||||
},
|
||||
"generate_ideas": {
|
||||
"model": "gpt-4.1",
|
||||
"max_tokens": 4000,
|
||||
"temperature": 0.7,
|
||||
"response_format": {"type": "json_object"},
|
||||
},
|
||||
"generate_content": {
|
||||
"model": "gpt-4.1",
|
||||
"max_tokens": 8000,
|
||||
"temperature": 0.7,
|
||||
"response_format": None, # Text output
|
||||
},
|
||||
"generate_images": {
|
||||
"model": "dall-e-3",
|
||||
"size": "1024x1024",
|
||||
"provider": "openai",
|
||||
},
|
||||
"extract_image_prompts": {
|
||||
"model": "gpt-4o-mini",
|
||||
"max_tokens": 1000,
|
||||
"temperature": 0.7,
|
||||
"response_format": {"type": "json_object"},
|
||||
},
|
||||
}
|
||||
|
||||
# Function name aliases (for backward compatibility)
|
||||
FUNCTION_ALIASES = {
|
||||
"cluster_keywords": "auto_cluster",
|
||||
"auto_cluster_keywords": "auto_cluster",
|
||||
"auto_generate_ideas": "generate_ideas",
|
||||
"auto_generate_content": "generate_content",
|
||||
"auto_generate_images": "generate_images",
|
||||
}
|
||||
|
||||
|
||||
def get_model_config(function_name: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Get model configuration for an AI function.
|
||||
|
||||
Args:
|
||||
function_name: AI function name (e.g., 'auto_cluster', 'generate_ideas')
|
||||
|
||||
Returns:
|
||||
Dict with model, max_tokens, temperature, etc.
|
||||
"""
|
||||
# Check aliases first
|
||||
actual_name = FUNCTION_ALIASES.get(function_name, function_name)
|
||||
|
||||
# Get config or return defaults
|
||||
config = MODEL_CONFIG.get(actual_name, {})
|
||||
|
||||
# Merge with defaults
|
||||
default_config = {
|
||||
"model": "gpt-4.1",
|
||||
"max_tokens": 4000,
|
||||
"temperature": 0.7,
|
||||
"response_format": None,
|
||||
}
|
||||
|
||||
return {**default_config, **config}
|
||||
|
||||
|
||||
def get_model(function_name: str) -> str:
|
||||
"""Get model name for function"""
|
||||
config = get_model_config(function_name)
|
||||
return config.get("model", "gpt-4.1")
|
||||
|
||||
|
||||
def get_max_tokens(function_name: str) -> int:
|
||||
"""Get max tokens for function"""
|
||||
config = get_model_config(function_name)
|
||||
return config.get("max_tokens", 4000)
|
||||
|
||||
|
||||
def get_temperature(function_name: str) -> float:
|
||||
"""Get temperature for function"""
|
||||
config = get_model_config(function_name)
|
||||
return config.get("temperature", 0.7)
|
||||
|
||||
Reference in New Issue
Block a user