Spaces:
Running
Running
Update agents/specialized/writer.py
Browse files- agents/specialized/writer.py +16 -3
agents/specialized/writer.py
CHANGED
|
@@ -7,16 +7,29 @@ Eres redactor experto. Escribe SOLO contenido real y extenso (500+ palabras).
|
|
| 7 |
Sin placeholders. Usa ## para secciones y ### para subsecciones.
|
| 8 |
Secciones: ## Resumen Ejecutivo, ### Introducción, ### Desarrollo,
|
| 9 |
### Hallazgos, ### Conclusiones, ### Recomendaciones
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
"""
|
| 11 |
|
| 12 |
|
| 13 |
async def run(task: str, context: dict = None) -> dict:
|
| 14 |
result = build_result("writer")
|
| 15 |
try:
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
result["response"] = response
|
| 18 |
|
| 19 |
-
# Si la respuesta es suficientemente larga, generar un .docx
|
| 20 |
if len(response.strip()) > 300:
|
| 21 |
title = task[:60].strip('"') or "Informe generado"
|
| 22 |
try:
|
|
@@ -31,4 +44,4 @@ async def run(task: str, context: dict = None) -> dict:
|
|
| 31 |
result["success"] = False
|
| 32 |
result["error"] = str(e)
|
| 33 |
|
| 34 |
-
return result
|
|
|
|
| 7 |
Sin placeholders. Usa ## para secciones y ### para subsecciones.
|
| 8 |
Secciones: ## Resumen Ejecutivo, ### Introducción, ### Desarrollo,
|
| 9 |
### Hallazgos, ### Conclusiones, ### Recomendaciones
|
| 10 |
+
|
| 11 |
+
IMPORTANTE: Si recibes contexto del Analyst, INTÉGRALO en tu redacción.
|
| 12 |
+
Usa sus hallazgos, datos y conclusiones como base de tu documento.
|
| 13 |
+
No ignores el contexto — es la investigación previa que debes expandir y redactar.
|
| 14 |
"""
|
| 15 |
|
| 16 |
|
| 17 |
async def run(task: str, context: dict = None) -> dict:
|
| 18 |
result = build_result("writer")
|
| 19 |
try:
|
| 20 |
+
# Construir prompt enriquecido si hay análisis previo
|
| 21 |
+
enriched_task = task
|
| 22 |
+
if context and "analyst" in context:
|
| 23 |
+
enriched_task = (
|
| 24 |
+
f"{task}\n\n"
|
| 25 |
+
f"--- ANÁLISIS PREVIO DEL ANALYST (úsalo como base) ---\n"
|
| 26 |
+
f"{context['analyst'][:3000]}\n"
|
| 27 |
+
f"--- FIN DEL ANÁLISIS ---"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
response = await call_llm("writer", ROLE, enriched_task, context)
|
| 31 |
result["response"] = response
|
| 32 |
|
|
|
|
| 33 |
if len(response.strip()) > 300:
|
| 34 |
title = task[:60].strip('"') or "Informe generado"
|
| 35 |
try:
|
|
|
|
| 44 |
result["success"] = False
|
| 45 |
result["error"] = str(e)
|
| 46 |
|
| 47 |
+
return result
|