[BUG-FIX] Test Update for build_agent -> build_llm_agent

pull/1224/head
Aksh Parekh 5 days ago
parent e5c2960912
commit 93b17bd646

@ -41,21 +41,27 @@ def test_initialization():
def test_agent_building(): def test_agent_building():
"""Test building individual agents""" """Test building individual agents from specs"""
print_separator() print_separator()
print("Testing Agent Building") print("Testing Agent Building")
try: try:
swarm = AutoSwarmBuilder() swarm = AutoSwarmBuilder()
agent = swarm.build_agent( specs = {
agent_name="TestAgent", "agents": [
agent_description="A test agent", {
agent_system_prompt="You are a test agent", "agent_name": "TestAgent",
max_loops=1, "description": "A test agent",
) "system_prompt": "You are a test agent",
"max_loops": 1,
}
]
}
agents = swarm.create_agents_from_specs(specs)
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
@ -69,18 +75,25 @@ def test_agent_creation():
print_separator() print_separator()
print("Testing Agent Creation from Task") print("Testing Agent Creation from Task")
try: try:
import json
swarm = AutoSwarmBuilder( swarm = AutoSwarmBuilder(
name="ResearchSwarm", name="ResearchSwarm",
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) # create_agents returns a JSON string
agent_specs_json = swarm.create_agents(task)
# Parse JSON string to dict
agent_specs = json.loads(agent_specs_json)
# Convert specs to actual Agent objects
agents = swarm.create_agents_from_specs(agent_specs)
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:
@ -155,7 +168,7 @@ def test_error_handling():
# Test with invalid agent configuration # Test with invalid agent configuration
print("Testing invalid agent configuration...") print("Testing invalid agent configuration...")
try: try:
swarm.build_agent("", "", "") swarm.create_agents_from_specs({"agents": [{"agent_name": ""}]})
print( print(
"✗ Should have raised an error for empty agent configuration" "✗ Should have raised an error for empty agent configuration"
) )

Loading…
Cancel
Save