Spaces:
Build error
Build error
File size: 763 Bytes
01523b5 |
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 |
from __future__ import annotations
from typing import TYPE_CHECKING, List
from . import order_registry as OrderRegistry
from .base import BaseOrder
if TYPE_CHECKING:
from agentverse.environments import BaseEnvironment
@OrderRegistry.register("sequential")
class SequentialOrder(BaseOrder):
"""
Order for sequential conversation
The agents speak in a round-robin fashion
"""
next_agent_idx: int = 0
def get_next_agent_idx(self, environment: BaseEnvironment) -> List[int]:
"""Return the index of the next agent to speak"""
ret = self.next_agent_idx
self.next_agent_idx = (self.next_agent_idx + 1) % len(environment.agents)
return [ret]
def reset(self) -> None:
self.next_agent_idx = 0
|