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,85 @@
name: tip_tech
description: Tips de tecnología cortos y accionables
personality: default
purpose: |
Generar tips prácticos que el lector pueda aplicar inmediatamente.
El valor está en la accionabilidad, no en la teoría.
requirements:
- Accionable en menos de 5 minutos
- Un solo concepto por tip
- Incluye el "por qué" importa
- Específico, no genérico
structure:
hook: attention_grabbing_first_line
body: the_tip_with_context
why: why_it_matters
close: hashtags_only
variables:
- name: category
type: string
required: true
examples: ["productividad", "ia", "seguridad", "python", "automatización"]
- name: difficulty_level
type: string
required: false
default: "principiante"
options: ["principiante", "intermedio", "avanzado"]
- name: target_audience
type: string
required: false
default: "profesionales tech"
parameters:
temperature: 0.8
max_tokens: 300
template: |
Genera un tip de tecnología sobre: {category}
NIVEL DE DIFICULTAD: {difficulty_level}
AUDIENCIA: {target_audience}
ESTRUCTURA REQUERIDA:
1. HOOK: Primera línea que capture atención (pregunta, dato sorprendente, o afirmación bold)
2. TIP: El consejo concreto y específico
3. POR QUÉ: Una línea explicando el beneficio
4. HASHTAGS: 2-3 hashtags relevantes
CRITERIOS DE CALIDAD:
- El lector debe poder aplicarlo HOY
- Debe ser específico (no "usa IA para ser más productivo", sino "usa ChatGPT para resumir emails largos")
- El hook debe generar curiosidad o resonar con un dolor común
EVITAR:
- Tips genéricos que todos conocen
- Consejos que requieran comprar algo
- Jerga técnica sin explicación
Responde SOLO con el texto del post, sin explicaciones ni meta-comentarios.
examples:
good:
- |
¿Pasas horas en reuniones improductivas?
La regla 2-2-2: máximo 2 temas, 2 decisiones, 2 acciones.
Mis reuniones ahora duran la mitad.
#Productividad #Tips
- |
El 90% ignora esto en Python:
Usa enumerate() en lugar de range(len()).
Código más limpio y 0 errores de índice.
#Python #Programming
bad:
- "Usa IA para ser más productivo" # Muy genérico
- "Compra una segunda pantalla para trabajar mejor" # Requiere compra
- "El machine learning es útil" # No es accionable