Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions agentverse/tasksolving.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def from_task(cls, task: str, tasks_dir: str):
# Build agents for all pipeline (task)
agents = {}
for i, agent_config in enumerate(task_config["agents"]):
agent_type = AGENT_TYPES(i)
if i == 2 and agent_config.get("agent_type", "") == "critic":
if agent_config.get("agent_type", "") == "critic":
agent = load_agent(agent_config)
agents[agent_type] = [
agents[AGENT_TYPES.CRITIC] = [
copy.deepcopy(agent)
for _ in range(task_config.get("cnt_agents", 1) - 1)
]
else:
agent_type = AGENT_TYPES.from_string(agent_config.get("agent_type", ""))
agents[agent_type] = load_agent(agent_config)

env_config["agents"] = agents
Expand Down
15 changes: 15 additions & 0 deletions agentverse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ class AGENT_TYPES(Enum):
EVALUATION = 4
MANAGER = 5

@staticmethod
def from_string(agent_type: str):
str_to_enum_dict = {
"role_assigner": AGENT_TYPES.ROLE_ASSIGNMENT,
"solver": AGENT_TYPES.SOLVER,
"critic": AGENT_TYPES.CRITIC,
"executor": AGENT_TYPES.EXECUTION,
"evaluator": AGENT_TYPES.EVALUATION,
"manager": AGENT_TYPES.MANAGER,
}
assert (
agent_type in str_to_enum_dict
), f"Unknown agent type: {agent_type}. Check your config file."
return str_to_enum_dict.get(agent_type.lower())


class Singleton(abc.ABCMeta, type):
"""
Expand Down