image max count
This commit is contained in:
@@ -93,7 +93,7 @@ class GenerateImagePromptsFunction(BaseAIFunction):
|
||||
data = data[0]
|
||||
|
||||
extracted = data['extracted']
|
||||
max_images = data.get('max_images', 2)
|
||||
max_images = data.get('max_images')
|
||||
|
||||
# Format content for prompt
|
||||
content_text = self._format_content_for_prompt(extracted)
|
||||
@@ -146,7 +146,7 @@ class GenerateImagePromptsFunction(BaseAIFunction):
|
||||
|
||||
content = original_data['content']
|
||||
extracted = original_data['extracted']
|
||||
max_images = original_data.get('max_images', 2)
|
||||
max_images = original_data.get('max_images')
|
||||
|
||||
prompts_created = 0
|
||||
|
||||
@@ -200,6 +200,14 @@ class GenerateImagePromptsFunction(BaseAIFunction):
|
||||
is_active=True
|
||||
)
|
||||
max_images = settings.config.get('max_in_article_images')
|
||||
|
||||
if max_images is None:
|
||||
raise ValueError(
|
||||
"max_in_article_images not configured in aws-admin image_generation settings. "
|
||||
"Please set this value in the Integration Settings page."
|
||||
)
|
||||
|
||||
max_images = int(max_images)
|
||||
logger.info(f"Using max_in_article_images={max_images} from aws-admin account")
|
||||
return max_images
|
||||
|
||||
|
||||
@@ -67,19 +67,17 @@ class GenerateImagesFunction(BaseAIFunction):
|
||||
if not tasks:
|
||||
raise ValueError("No tasks found")
|
||||
|
||||
# Get image generation settings
|
||||
image_settings = {}
|
||||
if account:
|
||||
try:
|
||||
from igny8_core.modules.system.models import IntegrationSettings
|
||||
integration = IntegrationSettings.objects.get(
|
||||
account=account,
|
||||
integration_type='image_generation',
|
||||
is_active=True
|
||||
)
|
||||
image_settings = integration.config or {}
|
||||
except Exception:
|
||||
pass
|
||||
# Get image generation settings from aws-admin account only (global settings)
|
||||
from igny8_core.modules.system.models import IntegrationSettings
|
||||
from igny8_core.auth.models import Account
|
||||
|
||||
system_account = Account.objects.get(slug='aws-admin')
|
||||
integration = IntegrationSettings.objects.get(
|
||||
account=system_account,
|
||||
integration_type='image_generation',
|
||||
is_active=True
|
||||
)
|
||||
image_settings = integration.config or {}
|
||||
|
||||
# Extract settings with defaults
|
||||
provider = image_settings.get('provider') or image_settings.get('service', 'openai')
|
||||
@@ -94,7 +92,7 @@ class GenerateImagesFunction(BaseAIFunction):
|
||||
'provider': provider,
|
||||
'model': model,
|
||||
'image_type': image_settings.get('image_type', 'realistic'),
|
||||
'max_in_article_images': int(image_settings.get('max_in_article_images', 2)),
|
||||
'max_in_article_images': int(image_settings.get('max_in_article_images')),
|
||||
'desktop_enabled': image_settings.get('desktop_enabled', True),
|
||||
'mobile_enabled': image_settings.get('mobile_enabled', True),
|
||||
}
|
||||
@@ -102,7 +100,7 @@ class GenerateImagesFunction(BaseAIFunction):
|
||||
def build_prompt(self, data: Dict, account=None) -> Dict:
|
||||
"""Extract image prompts from task content"""
|
||||
task = data.get('task')
|
||||
max_images = data.get('max_in_article_images', 2)
|
||||
max_images = data.get('max_in_article_images')
|
||||
|
||||
if not task or not task.content:
|
||||
raise ValueError("Task has no content")
|
||||
|
||||
Reference in New Issue
Block a user