diff --git a/src/generator/generator.py b/src/generator/generator.py index d759b0a..5c3236a 100644 --- a/src/generator/generator.py +++ b/src/generator/generator.py @@ -670,6 +670,15 @@ async def generate_comparison( if not settings.anthropic_api_key: raise ValueError("Claude API key required for comparison") + def _truncate(text: str, max_words: int = 3000) -> str: + words = text.split() + if len(words) > max_words: + return " ".join(words[:max_words]) + "\n\n[... contenido adicional truncado ...]" + return text + + context_a = _truncate(context_a) + context_b = _truncate(context_b) + prompt = ( f'Eres un analista experto. Compara en profundidad estos dos temas:\n' f'TEMA A: "{topic_a}"\n'