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,82 @@
name: product_post
description: Posts promocionales para productos
personality: promotional
purpose: |
Presentar productos de forma atractiva enfocándose en cómo
resuelven problemas reales del cliente.
requirements:
- Liderar con el problema que resuelve
- Destacar 2-3 beneficios clave
- Incluir precio como inversión
- CTA claro pero no agresivo
- NO inventar especificaciones
structure:
hook: problem_or_benefit_hook
benefits: 2_3_key_benefits
specs: relevant_specs_only
price: price_as_investment
cta: soft_call_to_action
hashtags: 2_3_relevant
variables:
- name: product_name
type: string
required: true
- name: product_description
type: string
required: true
- name: price
type: number
required: true
- name: category
type: string
required: true
- name: specs
type: object
required: false
- name: highlights
type: array
required: false
parameters:
temperature: 0.7
max_tokens: 400
template: |
Genera un post promocional para este producto:
PRODUCTO: {product_name}
DESCRIPCIÓN: {product_description}
PRECIO: ${price:,.2f} MXN
CATEGORÍA: {category}
ESPECIFICACIONES: {specs}
PUNTOS DESTACADOS: {highlights}
ESTRUCTURA:
1. HOOK: Problema que resuelve O beneficio principal
2. BENEFICIOS: 2-3 beneficios clave (no características)
3. PRECIO: Presentado como inversión
4. CTA: Invitación a saber más (no presión)
5. HASHTAGS: 2-3 relevantes
REGLAS:
- Beneficios > Características (no "8GB RAM", sino "edita video sin lag")
- El precio es una inversión, no un gasto
- CTA suave: "Más info en DM", "Conoce más", etc.
- NO inventes especificaciones que no están en los datos
- Usa emojis con propósito (máximo 3-4)
Responde SOLO con el texto del post.
tone_guidelines:
do:
- "Edita videos 4K sin esperar renderizados eternos"
- "Inversión que se paga sola en productividad"
- "¿Te interesa? Escríbenos para más detalles"
dont:
- "¡¡¡OFERTA INCREÍBLE!!!"
- "ÚLTIMAS UNIDADES" (a menos que sea verdad)
- "Compra ahora antes de que se acabe"