From 403432770bdd29ca02574ab1710c57aaf8bbd98a Mon Sep 17 00:00:00 2001 From: "IGNY8 VPS (Salman)" Date: Wed, 26 Nov 2025 12:53:10 +0000 Subject: [PATCH] ai fix --- .../igny8_core/ai/functions/generate_ideas.py | 23 ++++++++++++++++--- backend/igny8_core/ai/prompts.py | 10 ++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/backend/igny8_core/ai/functions/generate_ideas.py b/backend/igny8_core/ai/functions/generate_ideas.py index b37b8084..cf07a449 100644 --- a/backend/igny8_core/ai/functions/generate_ideas.py +++ b/backend/igny8_core/ai/functions/generate_ideas.py @@ -208,12 +208,29 @@ class GenerateIdeasFunction(BaseAIFunction): # Handle target_keywords target_keywords = idea_data.get('covered_keywords', '') or idea_data.get('target_keywords', '') + # Map content_type and content_structure to ContentIdeas fields + # AI returns: content_type (post/page/product/service) → site_entity_type + # AI returns: content_structure (article/guide/review/comparison) → cluster_role (hub/supporting/attribute) + site_entity_type = idea_data.get('content_type', 'post') # post, page, product, service + + # Map content_structure to cluster_role + content_structure = idea_data.get('content_structure', 'article') + structure_to_role = { + 'article': 'hub', + 'guide': 'supporting', + 'review': 'supporting', + 'comparison': 'attribute', + 'listicle': 'supporting', + 'product_page': 'attribute', + } + cluster_role = structure_to_role.get(content_structure, 'hub') + # Create ContentIdeas record ContentIdeas.objects.create( idea_title=idea_data.get('title', 'Untitled Idea'), - description=description, - content_type=idea_data.get('content_type', 'post'), # Updated: blog_post → post - content_structure=idea_data.get('content_structure', 'article'), # Updated: supporting_page → article + description=description, # Stored as JSON string + site_entity_type=site_entity_type, + cluster_role=cluster_role, target_keywords=target_keywords, keyword_cluster=cluster, estimated_word_count=idea_data.get('estimated_word_count', 1500), diff --git a/backend/igny8_core/ai/prompts.py b/backend/igny8_core/ai/prompts.py index 161a3269..5121460e 100644 --- a/backend/igny8_core/ai/prompts.py +++ b/backend/igny8_core/ai/prompts.py @@ -123,17 +123,17 @@ Output JSON Example: "introduction": { "hook": "Transform your sleep with organic cotton that blends comfort and sustainability.", "paragraphs": [ - {"content_type": "paragraph", "details": "Overview of organic cotton's rise in bedding industry."}, - {"content_type": "paragraph", "details": "Why consumers prefer organic bedding over synthetic alternatives."} + {"format": "paragraph", "details": "Overview of organic cotton's rise in bedding industry."}, + {"format": "paragraph", "details": "Why consumers prefer organic bedding over synthetic alternatives."} ] }, "H2": [ { "heading": "Why Choose Organic Cotton for Bedding?", "subsections": [ - {"subheading": "Health and Skin Benefits", "content_type": "paragraph", "details": "Discuss hypoallergenic and chemical-free aspects."}, - {"subheading": "Environmental Sustainability", "content_type": "list", "details": "Eco benefits like low water use, no pesticides."}, - {"subheading": "Long-Term Cost Savings", "content_type": "table", "details": "Compare durability and pricing over time."} + {"subheading": "Health and Skin Benefits", "format": "paragraph", "details": "Discuss hypoallergenic and chemical-free aspects."}, + {"subheading": "Environmental Sustainability", "format": "list", "details": "Eco benefits like low water use, no pesticides."}, + {"subheading": "Long-Term Cost Savings", "format": "table", "details": "Compare durability and pricing over time."} ] } ]