forked from microsoft/autogen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor agentchat +implement base chat agent run method (microsoft#3913
- Loading branch information
Showing
30 changed files
with
176 additions
and
85 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
python/packages/autogen-agentchat/src/autogen_agentchat/base/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
python/packages/autogen-agentchat/src/autogen_agentchat/base/_base_team.py
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from typing import List, Protocol, Sequence, runtime_checkable | ||
|
||
from autogen_core.base import CancellationToken | ||
from autogen_core.components.tools import Tool | ||
|
||
from ..messages import ChatMessage | ||
from ._task import TaskResult, TaskRunner | ||
from ._termination import TerminationCondition | ||
|
||
|
||
@runtime_checkable | ||
class ChatAgent(TaskRunner, Protocol): | ||
"""Protocol for a chat agent.""" | ||
|
||
@property | ||
def name(self) -> str: | ||
"""The name of the agent. This is used by team to uniquely identify | ||
the agent. It should be unique within the team.""" | ||
... | ||
|
||
@property | ||
def description(self) -> str: | ||
"""The description of the agent. This is used by team to | ||
make decisions about which agents to use. The description should | ||
describe the agent's capabilities and how to interact with it.""" | ||
... | ||
|
||
async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken) -> ChatMessage: | ||
"""Handle incoming messages and return a response message.""" | ||
... | ||
|
||
async def run( | ||
self, | ||
task: str, | ||
*, | ||
cancellation_token: CancellationToken | None = None, | ||
termination_condition: TerminationCondition | None = None, | ||
) -> TaskResult: | ||
"""Run the agent with the given task and return the result.""" | ||
... | ||
|
||
|
||
@runtime_checkable | ||
class ToolUseChatAgent(ChatAgent, Protocol): | ||
"""Protocol for a chat agent that can use tools.""" | ||
|
||
@property | ||
def registered_tools(self) -> List[Tool]: | ||
"""The list of tools that the agent can use.""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
python/packages/autogen-agentchat/src/autogen_agentchat/base/_team.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Protocol | ||
|
||
from autogen_core.base import CancellationToken | ||
|
||
from ._task import TaskResult, TaskRunner | ||
from ._termination import TerminationCondition | ||
|
||
|
||
class Team(TaskRunner, Protocol): | ||
async def run( | ||
self, | ||
task: str, | ||
*, | ||
cancellation_token: CancellationToken | None = None, | ||
termination_condition: TerminationCondition | None = None, | ||
) -> TaskResult: | ||
"""Run the team on a given task until the termination condition is met.""" | ||
... |
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from ._terminations import MaxMessageTermination, StopMessageTermination, TextMentionTermination | ||
|
||
__all__ = [ | ||
"MaxMessageTermination", | ||
"TextMentionTermination", | ||
"StopMessageTermination", | ||
] |
File renamed without changes.
4 changes: 0 additions & 4 deletions
4
python/packages/autogen-agentchat/src/autogen_agentchat/teams/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
from ._group_chat._round_robin_group_chat import RoundRobinGroupChat | ||
from ._group_chat._selector_group_chat import SelectorGroupChat | ||
from ._terminations import MaxMessageTermination, StopMessageTermination, TextMentionTermination | ||
|
||
__all__ = [ | ||
"MaxMessageTermination", | ||
"TextMentionTermination", | ||
"StopMessageTermination", | ||
"RoundRobinGroupChat", | ||
"SelectorGroupChat", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
python/packages/autogen-agentchat/tests/test_termination_condition.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.