Skip to content
Open
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
17 changes: 9 additions & 8 deletions agentverse/environments/tasksolving_env/rules/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union, Optional
from enum import Enum

from agentverse.agents.base import BaseAgent
from agentverse.utils import AGENT_TYPES
Expand Down Expand Up @@ -71,29 +72,29 @@ def build_components(config: Dict, registry):
async def role_assign(
self,
task_description: str,
agents: List[BaseAgent],
agents: Dict[Enum, Union[BaseAgent, List[BaseAgent]]],
cnt_turn: int,
advice: str = "",
) -> List[BaseAgent]:
"""Assign roles to agents"""
if self.role_assign_only_once and cnt_turn > 0:
agents = [agents[AGENT_TYPES.SOLVER]] + agents[AGENT_TYPES.CRITIC]
else:
agents = await self.role_assigner.astep(
critic_agents = await self.role_assigner.astep(
role_assigner=agents[AGENT_TYPES.ROLE_ASSIGNMENT],
group_members=[agents[AGENT_TYPES.SOLVER]] + agents[AGENT_TYPES.CRITIC],
advice=advice,
task_description=task_description,
)
if self.role_assign_only_once and cnt_turn == 0:
agents[AGENT_TYPES.SOLVER] = agents[0]
agents[AGENT_TYPES.CRITIC] = agents[1:]
return agents
agents[AGENT_TYPES.SOLVER] = critic_agents[0]
agents[AGENT_TYPES.CRITIC] = critic_agents[1:]
return critic_agents

async def decision_making(
self,
task_description: str,
agents: List[BaseAgent],
agents: Dict[Enum, Union[BaseAgent, List[BaseAgent]]],
previous_plan: str,
advice: str = "No advice yet.",
) -> List[SolverMessage]:
Expand All @@ -120,7 +121,7 @@ async def decision_making(
async def execute(
self,
task_description: str,
agents: List[BaseAgent],
agents: Dict[Enum, Union[BaseAgent, List[BaseAgent]]],
final_solution: List[SolverMessage],
) -> Any:
"""execution stage.
Expand All @@ -140,7 +141,7 @@ async def execute(
async def evaluate(
self,
task_description: str,
agents: List[BaseAgent],
agents: Dict[Enum, Union[BaseAgent, List[BaseAgent]]],
solution: List[SolverMessage],
result: List[ExecutorMessage],
) -> Tuple[List[int], str]:
Expand Down