testign promtps

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-17 00:09:07 +00:00
parent 84fd4bc11a
commit 8f97666522
11 changed files with 1149 additions and 3 deletions

117
test_long_content.py Normal file
View File

@@ -0,0 +1,117 @@
#!/usr/bin/env python
"""
Test if AI can generate 2000+ word content (requires ~2700+ tokens)
"""
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 VERY LONG content requirement")
print("=" * 70)
# This prompt REQUIRES a very long response with many detailed sections
prompt = """Generate a complete JSON article about "Complete Guide to Organic Cotton Bedding" following this EXACT structure. Each section MUST be fully detailed with examples, data, and comprehensive explanations.
JSON Format:
{
"title": "Complete Guide to Organic Cotton Bedding: Benefits, Buying Tips, and Care",
"content": "<full HTML content here>",
"word_count": 2000
}
Content Requirements (MINIMUM 2000 words total):
<h2>Introduction</h2>
Write 200 words introducing organic cotton bedding, market trends, and why consumers are switching.
<h2>What is Organic Cotton?</h2>
Write 250 words explaining organic cotton certification, farming methods, GOTS standards, and differences from conventional cotton. Include specific examples of organic farming practices.
<h2>Health and Skin Benefits</h2>
Write 300 words covering hypoallergenic properties, chemical-free benefits, impact on sensitive skin, dermatologist recommendations, and real-world testimonials.
<h2>Environmental Impact and Sustainability</h2>
Write 300 words with detailed statistics on water conservation, pesticide elimination, carbon footprint, soil health, biodiversity benefits, and certification bodies.
<h2>Quality, Durability, and Thread Count</h2>
Write 250 words explaining thread count myths, weave types (percale vs sateen), durability testing, washing cycle performance, and longevity comparisons.
<h2>Cost Analysis and Value</h2>
Write 250 words with price comparisons, cost-per-use calculations, 5-year ownership analysis, warranty information, and investment justification.
<h2>Top Organic Cotton Bedding Brands</h2>
Write 250 words reviewing 5-7 major brands with specific product examples, price ranges, unique features, and customer ratings.
<h2>Buying Guide and What to Look For</h2>
Write 200 words on certification verification, red flags, shopping tips, online vs retail, and return policies.
Return ONLY valid JSON. The content field must contain complete HTML with ALL sections fully written."""
tests = [
("4096 tokens", 4096),
("8192 tokens", 8192),
("16384 tokens", 16384),
]
print()
for name, max_tokens in tests:
print(f"📝 Testing with max_tokens = {max_tokens}")
print("-" * 70)
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,
},
timeout=120
)
if response.status_code == 200:
data = response.json()
usage = data.get('usage', {})
finish_reason = data['choices'][0].get('finish_reason')
completion = usage.get('completion_tokens', 0)
# Rough word count estimate (1 token ≈ 0.75 words)
estimated_words = int(completion * 0.75)
print(f" Completion Tokens: {completion}")
print(f" Estimated Words: ~{estimated_words}")
print(f" Finish Reason: {finish_reason}")
if finish_reason == 'length':
print(f" ⚠️ TRUNCATED at {max_tokens} tokens!")
print(f" 🚨 Content was CUT OFF - NOT COMPLETE")
else:
print(f" ✅ Response completed naturally")
print()
else:
error = response.json().get('error', {})
print(f" ✗ Error: {error.get('message', 'Unknown')}\n")
except Exception as e:
print(f" ✗ Exception: {e}\n")
print("=" * 70)
print("🎯 CONCLUSION:")
print("=" * 70)
print("If any test shows 'TRUNCATED', we need higher max_tokens for content generation.")
print("A 2000-word article needs ~2700 completion tokens minimum.")
print()