2025-01-22 15:51:34 -08:00
|
|
|
from abc import ABC, abstractmethod
|
2025-01-23 23:08:22 -08:00
|
|
|
from typing import Any, Mapping
|
|
|
|
|
|
|
|
from autogen_core import ComponentBase
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
2024-11-01 04:12:43 -07:00
|
|
|
from ._task import TaskRunner
|
2024-10-24 05:36:33 -07:00
|
|
|
|
|
|
|
|
2025-01-23 23:08:22 -08:00
|
|
|
class Team(ABC, TaskRunner, ComponentBase[BaseModel]):
|
|
|
|
component_type = "team"
|
|
|
|
|
2025-01-22 15:51:34 -08:00
|
|
|
@abstractmethod
|
2024-11-07 16:00:35 -08:00
|
|
|
async def reset(self) -> None:
|
|
|
|
"""Reset the team and all its participants to its initial state."""
|
|
|
|
...
|
2024-12-04 16:14:41 -08:00
|
|
|
|
2025-03-11 17:12:34 -07:00
|
|
|
@abstractmethod
|
|
|
|
async def pause(self) -> None:
|
|
|
|
"""Pause the team and all its participants. This is useful for
|
|
|
|
pausing the :meth:`autogen_agentchat.base.TaskRunner.run` or
|
|
|
|
:meth:`autogen_agentchat.base.TaskRunner.run_stream` methods from
|
|
|
|
concurrently, while keeping them alive."""
|
|
|
|
...
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
async def resume(self) -> None:
|
|
|
|
"""Resume the team and all its participants from a pause after
|
|
|
|
:meth:`pause` was called."""
|
|
|
|
...
|
|
|
|
|
2025-01-22 15:51:34 -08:00
|
|
|
@abstractmethod
|
2024-12-04 16:14:41 -08:00
|
|
|
async def save_state(self) -> Mapping[str, Any]:
|
|
|
|
"""Save the current state of the team."""
|
|
|
|
...
|
|
|
|
|
2025-01-22 15:51:34 -08:00
|
|
|
@abstractmethod
|
2024-12-04 16:14:41 -08:00
|
|
|
async def load_state(self, state: Mapping[str, Any]) -> None:
|
|
|
|
"""Load the state of the team."""
|
|
|
|
...
|