Spaces:
Runtime error
Runtime error
File size: 2,424 Bytes
3516c6f f6a79e3 15d3c7c f6a79e3 3516c6f 5bea1b2 f6a79e3 5bea1b2 f6a79e3 5bea1b2 f6a79e3 15d3c7c 5bea1b2 15d3c7c 5bea1b2 f6a79e3 15d3c7c 5bea1b2 15d3c7c 5bea1b2 f6a79e3 15d3c7c 5bea1b2 15d3c7c 5bea1b2 f6a79e3 15d3c7c 5bea1b2 15d3c7c 5bea1b2 f6a79e3 5bea1b2 f6a79e3 15d3c7c 5bea1b2 15d3c7c 3516c6f 5bea1b2 f6a79e3 3516c6f f6a79e3 15d3c7c 5bea1b2 15d3c7c 5bea1b2 15d3c7c f6a79e3 15d3c7c f6a79e3 15d3c7c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | from smolagents import (
CodeAgent,
DuckDuckGoSearchTool,
TransformersModel
)
# ======================================================
# MODELO COMPARTIDO
# ======================================================
shared_model = TransformersModel(
model_id="Qwen/Qwen2.5-1.5B-Instruct",
max_new_tokens=256,
dtype="auto"
)
COMMON_IMPORTS = [
"json",
"math",
"statistics"
]
# ======================================================
# AGENTES
# ======================================================
research_agent = CodeAgent(
name="research_agent",
description="Especialista en investigaci贸n web.",
tools=[DuckDuckGoSearchTool()],
model=shared_model,
verbosity_level=0,
additional_authorized_imports=COMMON_IMPORTS
)
hypothesis_agent = CodeAgent(
name="hypothesis_agent",
description="Genera hip贸tesis y oportunidades.",
tools=[],
model=shared_model,
verbosity_level=0,
additional_authorized_imports=COMMON_IMPORTS
)
critic_agent = CodeAgent(
name="critic_agent",
description="Eval煤a riesgos y debilidades.",
tools=[],
model=shared_model,
verbosity_level=0,
additional_authorized_imports=COMMON_IMPORTS
)
strategy_agent = CodeAgent(
name="strategy_agent",
description="Dise帽a estrategias accionables.",
tools=[],
model=shared_model,
verbosity_level=0,
additional_authorized_imports=COMMON_IMPORTS
)
# ======================================================
# MANAGER
# ======================================================
manager_agent = CodeAgent(
name="manager_agent",
description="Coordina todos los agentes.",
tools=[],
model=shared_model,
managed_agents=[
research_agent,
hypothesis_agent,
critic_agent,
strategy_agent
],
verbosity_level=1,
max_steps=6,
additional_authorized_imports=COMMON_IMPORTS
)
# ======================================================
# MAIN
# ======================================================
def run_multiagent_system(task):
final_task = f"""
OBJETIVO:
{task}
FLUJO:
1. Investigar evidencia y tendencias
2. Generar hip贸tesis estrat茅gicas
3. Evaluar riesgos y debilidades
4. Construir estrategia operativa
ENTREGA:
- Clara
- Ejecutiva
- Accionable
"""
result = manager_agent.run(final_task)
return str(result) |