feat: Add Content Generation Engine v2 with quality scoring
Major improvements to AI content generation: ## New Components (app/services/ai/) - PromptLibrary: YAML-based prompt templates with inheritance - ContextEngine: Anti-repetition and best performers tracking - ContentGeneratorV2: Enhanced generation with dynamic parameters - PlatformAdapter: Platform-specific content adaptation - ContentValidator: AI-powered quality scoring (0-100) ## Prompt Library (app/prompts/) - 3 personalities: default, educational, promotional - 5 templates: tip_tech, product_post, service_post, thread, response - 4 platform configs: x, threads, instagram, facebook - Few-shot examples by category: ia, productividad, seguridad ## Database Changes - New table: content_memory (tracks generated content) - New columns in posts: quality_score, score_breakdown, generation_attempts ## New API Endpoints (/api/v2/generate/) - POST /generate - Generation with quality check - POST /generate/batch - Batch generation - POST /quality/evaluate - Evaluate content quality - GET /templates, /personalities, /platforms - List configs ## Celery Tasks - update_engagement_scores (every 6h) - cleanup_old_memory (monthly) - refresh_best_posts_yaml (weekly) ## Tests - Comprehensive tests for all AI engine components Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
124
app/config/quality.yaml
Normal file
124
app/config/quality.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
# Configuración de calidad para el Content Generation Engine
|
||||
# Este archivo controla los umbrales de validación y scoring
|
||||
|
||||
version: "1.0"
|
||||
|
||||
# Umbrales de calidad
|
||||
thresholds:
|
||||
minimum_score: 60 # Score mínimo para aceptar contenido
|
||||
regenerate_below: 60 # Regenerar si score está debajo de esto
|
||||
excellent_score: 85 # Marcar como "top quality" si supera esto
|
||||
|
||||
# Control de regeneración
|
||||
regeneration:
|
||||
max_attempts: 2 # Máximo intentos de regeneración
|
||||
temperature_increment: 0.1 # Aumentar temperature en cada intento
|
||||
|
||||
# Acciones según score
|
||||
actions:
|
||||
below_40:
|
||||
action: reject
|
||||
log: true
|
||||
reason: "Calidad muy baja, posible error en generación"
|
||||
range_40_60:
|
||||
action: regenerate
|
||||
log: true
|
||||
reason: "Calidad insuficiente"
|
||||
range_60_85:
|
||||
action: accept
|
||||
log: false
|
||||
above_85:
|
||||
action: accept_and_flag
|
||||
flag_as: top_performer
|
||||
log: true
|
||||
reason: "Excelente calidad, usar como ejemplo"
|
||||
|
||||
# Pesos para scoring con IA
|
||||
scoring_weights:
|
||||
hook_strength: 25 # ¿El inicio captura atención?
|
||||
clarity: 20 # ¿Se entiende fácil?
|
||||
actionability: 20 # ¿El lector puede hacer algo?
|
||||
originality: 15 # ¿Diferente a posts anteriores?
|
||||
brand_voice: 10 # ¿Suena como la marca?
|
||||
cta_effectiveness: 10 # ¿El CTA es claro? (si aplica)
|
||||
|
||||
# Prompt para scoring con IA
|
||||
scoring_prompt: |
|
||||
Evalúa este post para {platform} en escala 0-100.
|
||||
|
||||
POST:
|
||||
{content}
|
||||
|
||||
CRITERIOS (suma = 100):
|
||||
- Hook (0-25): ¿La primera línea captura atención inmediata?
|
||||
- Claridad (0-20): ¿Se entiende sin esfuerzo? ¿Oraciones claras?
|
||||
- Accionabilidad (0-20): ¿Qué puede hacer el lector después de leer?
|
||||
- Originalidad (0-15): ¿Evita clichés? ¿Tiene perspectiva única?
|
||||
- Voz de marca (0-10): ¿Profesional pero cercano? ¿Consistente?
|
||||
- CTA (0-10): Si tiene CTA, ¿es claro y natural? Si no aplica, dar 5.
|
||||
|
||||
RESPONDE EXACTAMENTE EN ESTE FORMATO JSON:
|
||||
{
|
||||
"total": <número 0-100>,
|
||||
"breakdown": {
|
||||
"hook_strength": <número 0-25>,
|
||||
"clarity": <número 0-20>,
|
||||
"actionability": <número 0-20>,
|
||||
"originality": <número 0-15>,
|
||||
"brand_voice": <número 0-10>,
|
||||
"cta_effectiveness": <número 0-10>
|
||||
},
|
||||
"feedback": "<1 oración con sugerencia de mejora principal>"
|
||||
}
|
||||
|
||||
# Validaciones obligatorias (pass/fail)
|
||||
validations:
|
||||
length:
|
||||
enabled: true
|
||||
description: "Contenido dentro del límite de la plataforma"
|
||||
action_on_fail: reject
|
||||
|
||||
prohibited_content:
|
||||
enabled: true
|
||||
description: "Sin palabras o temas prohibidos"
|
||||
action_on_fail: reject
|
||||
prohibited_words:
|
||||
- "mierda"
|
||||
- "estafa"
|
||||
- "garantizado 100%"
|
||||
- "hazte rico"
|
||||
prohibited_patterns:
|
||||
- "compra ahora.*últimas unidades" # Urgencia falsa
|
||||
|
||||
format:
|
||||
enabled: true
|
||||
description: "Formato válido y completo"
|
||||
action_on_fail: reject
|
||||
checks:
|
||||
- not_truncated
|
||||
- has_content
|
||||
- proper_encoding
|
||||
|
||||
language:
|
||||
enabled: true
|
||||
description: "En el idioma configurado"
|
||||
expected_language: "es"
|
||||
action_on_fail: reject
|
||||
|
||||
repetition:
|
||||
enabled: true
|
||||
description: "No idéntico a posts recientes"
|
||||
action_on_fail: reject
|
||||
similarity_threshold: 0.85 # Rechazar si >85% similar a post reciente
|
||||
lookback_days: 30
|
||||
|
||||
# Context Engine settings
|
||||
context:
|
||||
memory_window: 50 # Recordar últimos N posts
|
||||
anti_repetition:
|
||||
topic_cooldown_days: 7 # No repetir mismo tema en N días
|
||||
phrase_cooldown_days: 14 # No repetir frases distintivas
|
||||
best_performers:
|
||||
top_percentile: 20 # Usar top 20% como examples
|
||||
min_examples: 3 # Mínimo ejemplos a incluir
|
||||
max_examples: 5 # Máximo ejemplos a incluir
|
||||
Reference in New Issue
Block a user