ai fixes
This commit is contained in:
@@ -65,7 +65,7 @@ class GenerateContentFunction(BaseAIFunction):
|
||||
# STAGE 3: Preload relationships - taxonomy_term instead of taxonomy
|
||||
tasks = list(queryset.select_related(
|
||||
'account', 'site', 'sector', 'cluster', 'taxonomy_term'
|
||||
).prefetch_related('keywords'))
|
||||
))
|
||||
|
||||
if not tasks:
|
||||
raise ValueError("No tasks found")
|
||||
@@ -106,11 +106,10 @@ class GenerateContentFunction(BaseAIFunction):
|
||||
if task.taxonomy_term.taxonomy_type:
|
||||
taxonomy_data += f"Type: {task.taxonomy_term.get_taxonomy_type_display()}\n"
|
||||
|
||||
# STAGE 3: Build keywords context (from keywords M2M)
|
||||
# STAGE 3: Build keywords context (from keywords TextField)
|
||||
keywords_data = ''
|
||||
if task.keywords.exists():
|
||||
keyword_list = [kw.keyword for kw in task.keywords.all()]
|
||||
keywords_data = "Keywords: " + ", ".join(keyword_list) + "\n"
|
||||
if task.keywords:
|
||||
keywords_data = f"Keywords: {task.keywords}\n"
|
||||
|
||||
# Get prompt from registry with context
|
||||
prompt = PromptRegistry.get_prompt(
|
||||
@@ -192,6 +191,7 @@ class GenerateContentFunction(BaseAIFunction):
|
||||
# Core fields
|
||||
title=title,
|
||||
content_html=content_html or '',
|
||||
word_count=word_count,
|
||||
cluster=task.cluster,
|
||||
content_type=task.content_type,
|
||||
content_structure=task.content_structure,
|
||||
|
||||
@@ -63,7 +63,7 @@ class GenerateImagePromptsFunction(BaseAIFunction):
|
||||
if account:
|
||||
queryset = queryset.filter(account=account)
|
||||
|
||||
contents = list(queryset.select_related('task', 'account', 'site', 'sector'))
|
||||
contents = list(queryset.select_related('account', 'site', 'sector', 'cluster'))
|
||||
|
||||
if not contents:
|
||||
raise ValueError("No content records found")
|
||||
@@ -203,7 +203,7 @@ class GenerateImagePromptsFunction(BaseAIFunction):
|
||||
"""Extract title, intro paragraphs, and H2 headings from content HTML"""
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
html_content = content.html_content or ''
|
||||
html_content = content.content_html or ''
|
||||
soup = BeautifulSoup(html_content, 'html.parser')
|
||||
|
||||
# Extract title
|
||||
|
||||
Reference in New Issue
Block a user