fixed auto swarm builder issues

pull/1218/head
Steve-Dusty 7 days ago
parent 8c7670121c
commit 17e4de4887

@ -407,6 +407,8 @@ class AutoSwarmBuilder:
agents_dictionary = model.run(task) agents_dictionary = model.run(task)
agents_dictionary = json.loads(agents_dictionary)
return agents_dictionary return agents_dictionary
except Exception as e: except Exception as e:
@ -437,6 +439,8 @@ class AutoSwarmBuilder:
f"Create the swarm spec for the following task: {task}" f"Create the swarm spec for the following task: {task}"
) )
swarm_spec = json.loads(swarm_spec)
print(swarm_spec) print(swarm_spec)
print(type(swarm_spec)) print(type(swarm_spec))

@ -46,16 +46,22 @@ def test_agent_building():
print("Testing Agent Building") print("Testing Agent Building")
try: try:
swarm = AutoSwarmBuilder() swarm = AutoSwarmBuilder()
agent = swarm.build_agent(
# Create agent spec
agent_spec = AgentSpec(
agent_name="TestAgent", agent_name="TestAgent",
agent_description="A test agent", description="A test agent",
agent_system_prompt="You are a test agent", system_prompt="You are a test agent",
max_loops=1, max_loops=1,
) )
# Create agent from spec
agents = swarm.create_agents_from_specs({"agents": [agent_spec]})
agent = agents[0]
print("✓ Built agent with configuration:") print("✓ Built agent with configuration:")
print(f" - Name: {agent.agent_name}") print(f" - Name: {agent.agent_name}")
print(f" - Description: {agent.description}") print(f" - Description: {agent.agent_description}")
print(f" - Max loops: {agent.max_loops}") print(f" - Max loops: {agent.max_loops}")
print("✓ Agent building test passed") print("✓ Agent building test passed")
return agent return agent
@ -74,13 +80,14 @@ def test_agent_creation():
description="A swarm for research tasks", description="A swarm for research tasks",
) )
task = "Research the latest developments in quantum computing" task = "Research the latest developments in quantum computing"
agents = swarm._create_agents(task) agents_dict = swarm.create_agents(task)
agents = swarm.create_agents_from_specs(agents_dict)
print("✓ Created agents for research task:") print("✓ Created agents for research task:")
for i, agent in enumerate(agents, 1): for i, agent in enumerate(agents, 1):
print(f" Agent {i}:") print(f" Agent {i}:")
print(f" - Name: {agent.agent_name}") print(f" - Name: {agent.agent_name}")
print(f" - Description: {agent.description}") print(f" - Description: {agent.agent_description}")
print(f"✓ Created {len(agents)} agents successfully") print(f"✓ Created {len(agents)} agents successfully")
return agents return agents
except Exception as e: except Exception as e:
@ -103,7 +110,7 @@ def test_swarm_routing():
task = "Analyze the impact of AI on healthcare" task = "Analyze the impact of AI on healthcare"
print("Starting task routing...") print("Starting task routing...")
result = swarm.swarm_router(agents, task) result = swarm.initialize_swarm_router(agents, task)
print("✓ Task routed successfully") print("✓ Task routed successfully")
print( print(

Loading…
Cancel
Save