diff --git a/backend/igny8_core/modules/planner/admin.py b/backend/igny8_core/modules/planner/admin.py index cc389bdf..2ae78276 100644 --- a/backend/igny8_core/modules/planner/admin.py +++ b/backend/igny8_core/modules/planner/admin.py @@ -177,7 +177,7 @@ class ContentIdeasAdmin(SiteSectorAdminMixin, Igny8ModelAdmin): 'fields': ('content_type', 'content_structure', 'estimated_word_count') }), ('Keywords & Clustering', { - 'fields': ('keyword_cluster', 'target_keywords', 'taxonomy') + 'fields': ('keyword_cluster', 'target_keywords') }), ('Timestamps', { 'fields': ('created_at', 'updated_at'), diff --git a/REMEMBER-ME-FEATURE-REFERENCE.md b/docs/logout-issues/REMEMBER-ME-FEATURE-REFERENCE.md similarity index 100% rename from REMEMBER-ME-FEATURE-REFERENCE.md rename to docs/logout-issues/REMEMBER-ME-FEATURE-REFERENCE.md diff --git a/test_frontend_content_generation.py b/test_frontend_content_generation.py deleted file mode 100644 index 79a7c7e9..00000000 --- a/test_frontend_content_generation.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python -""" -Test ACTUAL content generation using existing task (same as frontend) -""" -import os, sys, django -sys.path.insert(0, '/app') -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings') -django.setup() - -from igny8_core.ai.functions.generate_content import execute as generate_content -from igny8_core.auth.models import Account -from igny8_core.business.content.models import Tasks, Content -import re -from html import unescape - -print("=" * 80) -print("TESTING ACTUAL CONTENT GENERATION (same function as frontend)") -print("=" * 80) -print() - -# Get account and task -account = Account.objects.filter(slug='aws-admin').first() -task_id = 229 # "Essential Garden Tools for Every Gardener" - -task = Tasks.objects.get(id=task_id) -print(f"โœ… Using task: {task.title}") -print() - -# Delete any existing content for this task to start fresh -existing = Content.objects.filter(task=task) -if existing.exists(): - count = existing.count() - existing.delete() - print(f"๐Ÿ—‘๏ธ Deleted {count} existing content items") - print() - -print("=" * 80) -print("CALLING generate_content() - THE ACTUAL FUNCTION") -print("=" * 80) -print() - -# Call the ACTUAL function -try: - result = generate_content( - payload={'ids': [task_id]}, - account=account, - user=None - ) - - print() - print("=" * 80) - print("GENERATION RESULT") - print("=" * 80) - print() - - if result.get('success'): - print(f"โœ… Success: {result.get('message')}") - print(f" Items: {result.get('count', 0)}") - print() - - # Get the generated content - content = Content.objects.filter(task=task).order_by('-created_at').first() - - if content: - # Count actual words - html_content = content.content_html or '' - text_only = re.sub(r'<[^>]+>', '', html_content) - text_only = unescape(text_only) - words = len(text_only.split()) - - print(f"๐Ÿ“ Content Details:") - print(f" Title: {content.title}") - print(f" Word Count (actual): {words}") - print(f" Word Count (reported): {content.word_count}") - print() - - if words < 1200: - print(f"๐Ÿšจ CRITICAL ISSUE: Only {words} words!") - print(f" Target: 1200+ words") - print(f" Shortfall: {1200 - words} words") - else: - print(f"โœ… EXCELLENT: {words} words (exceeds 1200)") - - print() - print("=" * 80) - print("FIRST 800 CHARACTERS OF CONTENT:") - print("=" * 80) - print(text_only[:800]) - print() - print(f"[...{len(text_only) - 800} more characters...]" if len(text_only) > 800 else "") - - else: - print(f"โŒ Failed: {result.get('error')}") - -except Exception as e: - print(f"โŒ Exception: {e}") - import traceback - traceback.print_exc() - -print() -print("=" * 80) -print("This is the EXACT same generate_content() function called by frontend") -print("=" * 80) diff --git a/test_idea_generation.py b/test_idea_generation.py deleted file mode 100644 index 6e5c7154..00000000 --- a/test_idea_generation.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python -""" -Test idea generation with 16384 max_tokens to ensure it works correctly -""" -import os, sys, django -sys.path.insert(0, '/app') -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings') -django.setup() - -import requests, json -from igny8_core.modules.system.models import IntegrationSettings -from igny8_core.auth.models import Account - -account = Account.objects.filter(slug='aws-admin').first() -settings = IntegrationSettings.objects.filter(integration_type='openai', account=account, is_active=True).first() -config = settings.config or {} -api_key = config.get('apiKey') -model = config.get('model', 'gpt-4o') -max_tokens = config.get('max_tokens', 16384) - -# Read the actual idea generation prompt -with open('/data/idea-generation-prompt.md', 'r') as f: - prompt_template = f.read() - -# Simulate idea generation input -cluster_data = """ -Cluster ID: 1 | Name: Organic Cotton Bedding | Description: Keywords related to organic and eco-friendly bedding products -""" - -cluster_keywords = """ -Cluster ID: 1 | Name: Organic Cotton Bedding | Keywords: organic cotton sheets, eco-friendly bedding, sustainable duvet covers, GOTS certified bedding, organic mattress protector, chemical-free bedding, organic pillowcases, hypoallergenic sheets -""" - -prompt = prompt_template.replace('[IGNY8_CLUSTERS]', cluster_data) -prompt = prompt.replace('[IGNY8_CLUSTER_KEYWORDS]', cluster_keywords) - -print(f"๐Ÿงช Testing Idea Generation with max_tokens={max_tokens:,}") -print("=" * 70) -print(f"Prompt length: {len(prompt):,} characters (~{len(prompt)//4:,} tokens)") -print() - -try: - response = requests.post( - 'https://api.openai.com/v1/chat/completions', - headers={'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'}, - json={ - 'model': model, - 'messages': [{'role': 'user', 'content': prompt}], - 'max_tokens': max_tokens, - 'temperature': 0.7, - 'response_format': {"type": "json_object"} - }, - timeout=60 - ) - - if response.status_code == 200: - data = response.json() - usage = data.get('usage', {}) - finish_reason = data['choices'][0].get('finish_reason') - - prompt_tokens = usage.get('prompt_tokens', 0) - completion_tokens = usage.get('completion_tokens', 0) - total_tokens = usage.get('total_tokens', 0) - - print(f"โœ“ Response received") - print(f" Input Tokens: {prompt_tokens:>6,}") - print(f" Output Tokens: {completion_tokens:>6,}") - print(f" Total Tokens: {total_tokens:>6,}") - print(f" Finish Reason: {finish_reason}") - print() - - # Try to parse the response - try: - response_text = data['choices'][0]['message']['content'] - ideas_data = json.loads(response_text) - ideas_count = len(ideas_data.get('ideas', [])) - - print(f"โœ… Generated {ideas_count} ideas successfully") - - # Show summary of first idea - if ideas_count > 0: - first_idea = ideas_data['ideas'][0] - print() - print("Sample Idea:") - print(f" Title: {first_idea.get('title', 'N/A')}") - - desc = first_idea.get('description', {}) - if isinstance(desc, dict) and 'H2' in desc: - h2_count = len(desc['H2']) - print(f" H2 Sections: {h2_count}") - - print(f" Keywords: {first_idea.get('covered_keywords', 'N/A')[:60]}...") - except json.JSONDecodeError: - print("โš ๏ธ Could not parse JSON response") - - print() - if finish_reason == 'length': - print("๐Ÿšจ WARNING: Response was TRUNCATED!") - print(" Consider increasing max_tokens further") - else: - print("โœ… Response completed successfully") - print(f" Used {completion_tokens} of {max_tokens:,} available tokens") - print(f" Headroom: {((max_tokens - completion_tokens) / max_tokens * 100):.1f}%") - - else: - print(f"โœ— API Error: {response.status_code}") - print(response.json().get('error', {}).get('message', '')[:200]) - -except Exception as e: - print(f"โœ— Exception: {str(e)}") - -print() -print("=" * 70) -print("CONCLUSION:") -print("=" * 70) -print("Idea generation typically uses 1500-2500 tokens for 3 ideas with outlines.") -print(f"Current max_tokens={max_tokens:,} provides plenty of headroom.") -print("โœ… Configuration is optimal for idea generation.") diff --git a/test_large_context.py b/test_large_context.py deleted file mode 100644 index 71a359b0..00000000 --- a/test_large_context.py +++ /dev/null @@ -1,298 +0,0 @@ -#!/usr/bin/env python -""" -Test AI with LARGE INPUT (5000+ tokens) and LARGE OUTPUT (5000+ tokens) -This simulates real content generation scenarios -""" -import os, sys, django -sys.path.insert(0, '/app') -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings') -django.setup() - -import requests -from igny8_core.modules.system.models import IntegrationSettings -from igny8_core.auth.models import Account - -account = Account.objects.filter(slug='aws-admin').first() -settings = IntegrationSettings.objects.filter(integration_type='openai', account=account, is_active=True).first() -config = settings.config or {} -api_key = config.get('apiKey') -model = config.get('model', 'gpt-4o') - -print(f"๐Ÿงช Testing {model} with LARGE INPUT + LARGE OUTPUT") -print("=" * 80) -print() - -# Create a VERY LONG prompt to ensure input > 5000 tokens -# Including detailed outline, examples, and extensive instructions -large_prompt = """You are a professional content writer. Generate a complete, comprehensive article following this detailed specification. - -## Article Topic: "Complete Guide to Organic Cotton Bedding: Benefits, Types, and Buying Guide" - -## Target Word Count: 2500+ words (approximately 3500+ tokens in output) - -## JSON Output Format Required: -{ - "title": "article title", - "meta_title": "SEO title under 60 chars", - "meta_description": "SEO description under 160 chars", - "content": "", - "word_count": actual_word_count, - "primary_keyword": "organic cotton bedding", - "secondary_keywords": ["eco-friendly bedding", "sustainable sheets", "organic duvet covers"], - "tags": ["organic bedding", "sustainable home", "eco-friendly textiles", "cotton sheets", "bedroom essentials"], - "categories": ["Home & Living > Bedding", "Sustainable Living > Eco-Friendly Products"] -} - -## DETAILED CONTENT STRUCTURE (Each section must be fully written with examples, data, and depth): - -### Section 1: Introduction (300 words) -Write a compelling introduction that: -- Opens with an engaging hook about the rise of organic bedding -- Explains why consumers are switching from conventional to organic cotton -- Discusses market trends and growth statistics -- Mentions health concerns with conventional bedding -- Previews what readers will learn in this comprehensive guide -- Naturally incorporates the primary keyword "organic cotton bedding" - -### Section 2: Understanding Organic Cotton (400 words) -Write a detailed section covering: -- Definition of organic cotton and GOTS (Global Organic Textile Standard) certification -- Differences between organic and conventional cotton farming practices -- Specific pesticides and chemicals avoided in organic farming -- Water usage statistics (organic vs conventional) -- Soil health and crop rotation practices -- Carbon footprint comparison data -- Other certifications to look for (OEKO-TEX, Fair Trade, etc.) -- Include specific examples of organic cotton farms and their practices -- Mention leading organic cotton producing regions globally - -### Section 3: Health Benefits of Organic Cotton Bedding (400 words) -Comprehensive coverage of: -- Hypoallergenic properties and why they matter -- Impact on sensitive skin and skin conditions (eczema, psoriasis, allergies) -- Chemical residues in conventional bedding and health risks -- Dermatologist recommendations and clinical studies -- Respiratory benefits from chemical-free textiles -- Benefits for babies and children -- Real customer testimonials and experiences -- Comparison of skin irritation rates between organic and conventional bedding -- Long-term health advantages - -### Section 4: Environmental Impact and Sustainability (400 words) -Detailed analysis including: -- Water conservation statistics (gallons saved per pound of cotton) -- Pesticide elimination impact on ecosystems -- Biodiversity benefits for pollinators and wildlife -- Soil degradation prevention through organic farming -- Carbon emissions comparison with conventional cotton -- Impact on farmer health and community welfare -- Waste reduction in textile production -- End-of-life biodegradability -- Circular economy considerations -- Case studies of sustainable bedding brands - -### Section 5: Types of Organic Cotton Bedding (350 words) -Comprehensive overview of: -- Organic cotton sheets (fitted, flat, pillowcases) - - Thread count ranges and what they mean - - Weave types: percale, sateen, jersey, flannel - - Specific characteristics of each weave -- Organic cotton duvet covers and comforters - - Fill power and warmth ratings - - Seasonal considerations -- Organic cotton mattress protectors and pads - - Waterproof vs breathable options -- Organic cotton blankets and throws -- Specialty items (body pillows, Euro shams, bed skirts) -- Price ranges for each category -- Brand examples for each product type - -### Section 6: Quality Factors and What to Look For (350 words) -In-depth buying guidance: -- Thread count myths and realities (why 800+ isn't always better) -- Ply differences (single-ply vs multi-ply) -- Weave construction details -- Fabric weight and GSM (grams per square meter) -- Fiber length and quality grades -- Color fastness and dye methods (low-impact dyes) -- Shrinkage rates and pre-washing -- Durability testing standards -- Pilling resistance -- How to verify authentic organic certification -- Red flags for fake "organic" claims - -### Section 7: Top Organic Cotton Bedding Brands (400 words) -Detailed brand reviews including: -- Coyuchi: Product range, price points, unique features, customer ratings -- Boll & Branch: Signature products, fair trade practices, pricing -- Parachute: Material quality, design aesthetic, value proposition -- Pottery Barn Organic: Accessibility, variety, retail presence -- West Elm Organic: Style options, price range, sustainability initiatives -- SOL Organics: Budget-friendly options, certification details -- Avocado: Premium positioning, additional eco-features -- Include specific product examples from each brand -- Price comparison table format -- Warranty and return policy highlights - -### Section 8: Care and Maintenance (300 words) -Comprehensive care instructions: -- Initial washing recommendations before first use -- Water temperature guidelines for different weaves -- Detergent recommendations (eco-friendly, fragrance-free) -- Drying methods: air-dry vs machine dry -- Ironing tips for different weaves -- Stain removal techniques for organic cotton -- Frequency of washing for longevity -- Storage recommendations for seasonal items -- How to maintain whiteness without bleach -- Expected lifespan with proper care (5-10 years) -- When to replace bedding - -### Section 9: Cost Analysis and Value Proposition (300 words) -Financial breakdown: -- Price range overview: budget ($50-100), mid-range ($100-250), premium ($250-500+) -- Cost per use calculation over 5 years -- Durability comparison with conventional bedding -- Health cost savings (reduced allergies, better sleep) -- Environmental value beyond personal use -- Sale and discount timing (when to buy) -- Starter set recommendations for budget-conscious buyers -- Investment prioritization (which pieces to buy first) -- Comparison with luxury conventional bedding prices - -### Section 10: Where to Buy (200 words) -Shopping guide including: -- Direct-to-consumer brands (online) -- Major retailers (Pottery Barn, West Elm, Crate & Barrel) -- Amazon and online marketplaces (verification tips) -- Local organic stores and boutiques -- Outlet and discount sources -- International shipping considerations -- Return policies and trial periods -- Customer service quality comparisons - -### Section 11: Conclusion (150 words) -Wrap up with: -- Summary of key benefits -- Final recommendations for different buyer types -- Call to action -- Future of organic bedding industry - -## Writing Requirements: -- Use active voice throughout -- Include specific data points, statistics, and examples -- Vary sentence structure for natural flow -- Use HTML tags properly:

,

,

,