prompt issues fixes
This commit is contained in:
@@ -206,14 +206,21 @@ def process_image_generation_queue(self, image_ids: list, account_id: int = None
|
||||
except IntegrationSettings.DoesNotExist:
|
||||
return {'success': False, 'error': f'{provider} integration not found'}
|
||||
|
||||
# Get prompt templates
|
||||
# Get image prompt template (has placeholders: {image_type}, {post_title}, {image_prompt})
|
||||
try:
|
||||
image_prompt_template = PromptRegistry.get_image_prompt_template(account)
|
||||
negative_prompt = PromptRegistry.get_negative_prompt(account) if provider == 'runware' else None
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to get prompt templates: {e}, using fallback")
|
||||
image_prompt_template = "{image_prompt}"
|
||||
negative_prompt = None
|
||||
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}'
|
||||
|
||||
# Get negative prompt for Runware (only needed for Runware provider)
|
||||
negative_prompt = None
|
||||
if provider == 'runware':
|
||||
try:
|
||||
negative_prompt = PromptRegistry.get_negative_prompt(account)
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to get negative prompt: {e}")
|
||||
negative_prompt = None
|
||||
|
||||
# Initialize AICore
|
||||
ai_core = AICore(account=account)
|
||||
@@ -259,7 +266,7 @@ def process_image_generation_queue(self, image_ids: list, account_id: int = None
|
||||
failed += 1
|
||||
continue
|
||||
|
||||
# Get content for prompt formatting
|
||||
# Get content for template formatting
|
||||
content = image.content
|
||||
if not content:
|
||||
logger.warning(f"Image {image_id} has no content")
|
||||
@@ -271,17 +278,18 @@ def process_image_generation_queue(self, image_ids: list, account_id: int = None
|
||||
failed += 1
|
||||
continue
|
||||
|
||||
# Format prompt using template
|
||||
# Format template with image prompt from database
|
||||
# Template has placeholders: {image_type}, {post_title}, {image_prompt}
|
||||
try:
|
||||
formatted_prompt = image_prompt_template.format(
|
||||
image_type=image_type,
|
||||
post_title=content.title or content.meta_title or f"Content #{content.id}",
|
||||
image_prompt=image.prompt,
|
||||
image_type=image_type
|
||||
image_prompt=image.prompt # Read directly from database field
|
||||
)
|
||||
except Exception as e:
|
||||
# Fallback to simple prompt
|
||||
logger.warning(f"Prompt template formatting failed: {e}, using fallback")
|
||||
formatted_prompt = f"{image.prompt}, {image_type} style"
|
||||
# Fallback if template formatting fails
|
||||
logger.warning(f"Prompt template formatting failed: {e}, using image prompt directly")
|
||||
formatted_prompt = image.prompt
|
||||
|
||||
# Generate image
|
||||
logger.info(f"Generating image {index}/{total_images} (ID: {image_id})")
|
||||
@@ -346,4 +354,4 @@ def process_image_generation_queue(self, image_ids: list, account_id: int = None
|
||||
'completed': completed,
|
||||
'failed': failed,
|
||||
'results': results
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user