Spaces:
Sleeping
Sleeping
| # agents/specialized/writer.py | |
| from agents.specialized.base import build_result, call_llm | |
| from core.file_builder import build_docx | |
| ROLE = """ | |
| Eres redactor experto. Escribe SOLO contenido real y extenso (500+ palabras). | |
| Sin placeholders. Usa ## para secciones y ### para subsecciones. | |
| Secciones: ## Resumen Ejecutivo, ### Introducción, ### Desarrollo, | |
| ### Hallazgos, ### Conclusiones, ### Recomendaciones | |
| """ | |
| async def run(task: str, context: dict = None) -> dict: | |
| result = build_result("writer") | |
| try: | |
| response = await call_llm("writer", ROLE, task, context) | |
| result["response"] = response | |
| # Si la respuesta es suficientemente larga, generar un .docx | |
| if len(response.strip()) > 300: | |
| title = task[:60].strip('"') or "Informe generado" | |
| try: | |
| file_path = build_docx(title, response, images=None) | |
| if file_path: | |
| result["file_path"] = file_path.name | |
| result["file_type"] = "docx" | |
| except Exception as e: | |
| result["file_error"] = str(e) | |
| except Exception as e: | |
| result["success"] = False | |
| result["error"] = str(e) | |
| return result | |