max iamges
This commit is contained in:
@@ -188,16 +188,36 @@ class GenerateImagePromptsFunction(BaseAIFunction):
|
|||||||
|
|
||||||
# Helper methods
|
# Helper methods
|
||||||
def _get_max_in_article_images(self, account) -> int:
|
def _get_max_in_article_images(self, account) -> int:
|
||||||
"""Get max_in_article_images from IntegrationSettings"""
|
"""Get max_in_article_images from IntegrationSettings with fallback to system account"""
|
||||||
try:
|
try:
|
||||||
from igny8_core.modules.system.models import IntegrationSettings
|
from igny8_core.modules.system.models import IntegrationSettings
|
||||||
settings = IntegrationSettings.objects.get(
|
from igny8_core.auth.models import Account
|
||||||
account=account,
|
|
||||||
integration_type='image_generation'
|
# Try account-specific settings first
|
||||||
)
|
try:
|
||||||
return settings.config.get('max_in_article_images', 2)
|
settings = IntegrationSettings.objects.get(
|
||||||
except IntegrationSettings.DoesNotExist:
|
account=account,
|
||||||
return 2 # Default
|
integration_type='image_generation',
|
||||||
|
is_active=True
|
||||||
|
)
|
||||||
|
max_images = settings.config.get('max_in_article_images', 2)
|
||||||
|
logger.info(f"Using max_in_article_images={max_images} from account {account.id} settings")
|
||||||
|
return max_images
|
||||||
|
except IntegrationSettings.DoesNotExist:
|
||||||
|
# Fallback to system account (aws-admin)
|
||||||
|
logger.info(f"No image_generation settings for account {account.id}, falling back to system account")
|
||||||
|
system_account = Account.objects.get(slug='aws-admin')
|
||||||
|
settings = IntegrationSettings.objects.get(
|
||||||
|
account=system_account,
|
||||||
|
integration_type='image_generation',
|
||||||
|
is_active=True
|
||||||
|
)
|
||||||
|
max_images = settings.config.get('max_in_article_images', 2)
|
||||||
|
logger.info(f"Using max_in_article_images={max_images} from system account (aws-admin)")
|
||||||
|
return max_images
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Failed to get max_in_article_images from IntegrationSettings: {e}, using default=2")
|
||||||
|
return 2 # Default fallback
|
||||||
|
|
||||||
def _extract_content_elements(self, content: Content, max_images: int) -> Dict:
|
def _extract_content_elements(self, content: Content, max_images: int) -> Dict:
|
||||||
"""Extract title, intro paragraphs, and H2 headings from content HTML"""
|
"""Extract title, intro paragraphs, and H2 headings from content HTML"""
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ Return a JSON object with this structure:
|
|||||||
|
|
||||||
Make sure each prompt is detailed enough for image generation, describing the visual elements, style, mood, and composition.""",
|
Make sure each prompt is detailed enough for image generation, describing the visual elements, style, mood, and composition.""",
|
||||||
|
|
||||||
'image_prompt_template': 'Create a high-quality {image_type} image to use as a featured photo for a blog post titled "{post_title}". The image should visually represent the theme, mood, and subject implied by the image prompt: {image_prompt}. Focus on a realistic, well-composed scene that naturally communicates the topic without text or logos. Use balanced lighting, pleasing composition, and photographic detail suitable for lifestyle or editorial web content. Avoid adding any visible or readable text, brand names, or illustrative effects. **And make sure image is not blurry.**',
|
'image_prompt_template': '{image_type} image for blog post titled "{post_title}": {image_prompt}',
|
||||||
|
|
||||||
'negative_prompt': 'text, watermark, logo, overlay, title, caption, writing on walls, writing on objects, UI, infographic elements, post title',
|
'negative_prompt': 'text, watermark, logo, overlay, title, caption, writing on walls, writing on objects, UI, infographic elements, post title',
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ def process_image_generation_queue(self, image_ids: list, account_id: int = None
|
|||||||
image_prompt_template = PromptRegistry.get_image_prompt_template(account)
|
image_prompt_template = PromptRegistry.get_image_prompt_template(account)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to get image prompt template: {e}, using fallback")
|
logger.warning(f"Failed to get image prompt template: {e}, using fallback")
|
||||||
image_prompt_template = 'Create a high-quality {image_type} image for a blog post titled "{post_title}". Image prompt: {image_prompt}'
|
image_prompt_template = '{image_type} image for blog post titled "{post_title}": {image_prompt}'
|
||||||
|
|
||||||
# Get negative prompt for Runware (only needed for Runware provider)
|
# Get negative prompt for Runware (only needed for Runware provider)
|
||||||
negative_prompt = None
|
negative_prompt = None
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ Return a JSON object with this structure:
|
|||||||
|
|
||||||
Make sure each prompt is detailed enough for image generation, describing the visual elements, style, mood, and composition.""",
|
Make sure each prompt is detailed enough for image generation, describing the visual elements, style, mood, and composition.""",
|
||||||
|
|
||||||
'image_prompt_template': 'Create a high-quality {image_type} image to use as a featured photo for a blog post titled "{post_title}". The image should visually represent the theme, mood, and subject implied by the image prompt: {image_prompt}. Focus on a realistic, well-composed scene that naturally communicates the topic without text or logos. Use balanced lighting, pleasing composition, and photographic detail suitable for lifestyle or editorial web content. Avoid adding any visible or readable text, brand names, or illustrative effects. **And make sure image is not blurry.**',
|
'image_prompt_template': '{image_type} image for blog post titled "{post_title}": {image_prompt}',
|
||||||
|
|
||||||
'negative_prompt': 'text, watermark, logo, overlay, title, caption, writing on walls, writing on objects, UI, infographic elements, post title',
|
'negative_prompt': 'text, watermark, logo, overlay, title, caption, writing on walls, writing on objects, UI, infographic elements, post title',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user