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:
2026-01-28 20:55:28 +00:00
parent f458f809ca
commit 11b0ba46fa
36 changed files with 6266 additions and 55 deletions

View File

@@ -0,0 +1,79 @@
platform: x
display_name: "X (Twitter)"
description: "Plataforma de microblogging. Contenido conciso y directo."
limits:
max_characters: 280
max_hashtags: 2
max_mentions: 3
max_links: 1
media_optional: true
tone:
style: direct_punchy
emoji_usage: minimal # 1-2 máximo
formality: medium
energy: high
formatting:
line_breaks: true
use_bullets: true
bullet_style: "→"
numbered_lists: false
whitespace: strategic # Usa espacios para legibilidad
hooks:
preferred:
- dato_impactante # "El 90% de..."
- pregunta_retórica # "¿Sabías que...?"
- afirmación_bold # "La productividad no es..."
- tip_directo # "Tip: usa..."
avoid:
- historia_larga # No hay espacio
- introducción_suave # Pierde caracteres
- múltiples_ideas # Un concepto solo
cta:
frequency: 0.3 # 30% de posts
types:
- follow: "Síguenos para más tips"
- save: "Guarda este tip"
- share: "RT si te fue útil"
- engage: "¿Qué opinas?"
placement: end_before_hashtags
hashtags:
count: 1-2
placement: end
style: no_spaces # #IA no # IA
avoid:
- hashtags_largos_incomprensibles
- más_de_2_palabras
recommended:
- "#Tech"
- "#IA"
- "#Productividad"
- "#Tips"
- "#Python"
best_practices:
- Primera línea es crucial (aparece en preview)
- Usa saltos de línea para escaneo rápido
- Un solo mensaje/idea por post
- Threads para contenido largo (no comprimir)
- Los posts con datos específicos performan mejor
avoid:
- Comprimir contenido largo en 280 chars
- Más de 2 hashtags
- Emojis excesivos
- Links en el medio del texto
- "Hilo:" sin contenido de hilo real
adaptation_rules: |
Cuando adaptes contenido para X:
1. Extrae la idea principal únicamente
2. Usa formato de lista con → si hay múltiples puntos
3. Hook en primera línea obligatorio
4. Si no cabe, sugiere crear hilo en su lugar
5. Hashtags al final, máximo 2