diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py index 5fc5b8c54cd0..e5f38ea5b8a9 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py @@ -11,7 +11,6 @@ List, Mapping, Sequence, - Tuple, ) from autogen_core import CancellationToken, FunctionCall @@ -312,7 +311,7 @@ def __init__( self._is_running = False @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: """The types of messages that the assistant agent produces.""" message_types: List[type[ChatMessage]] = [TextMessage] if self._handoffs: diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py index c78c9adb90ee..abcb64eff260 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import Any, AsyncGenerator, List, Mapping, Sequence, Tuple +from typing import Any, AsyncGenerator, List, Mapping, Sequence from autogen_core import CancellationToken @@ -56,7 +56,7 @@ def description(self) -> str: @property @abstractmethod - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: """The types of messages that the agent produces in the :attr:`Response.chat_message` field. They must be :class:`ChatMessage` types.""" ... diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py index 22cbe1cca799..6374328b97a1 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_code_executor_agent.py @@ -1,5 +1,5 @@ import re -from typing import List, Sequence, Tuple +from typing import List, Sequence from autogen_core import CancellationToken from autogen_core.code_executor import CodeBlock, CodeExecutor @@ -80,7 +80,7 @@ def __init__( self._code_executor = code_executor @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: """The types of messages that the code executor agent produces.""" return (TextMessage,) diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py index 980859d15298..713b518bd7df 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py @@ -1,4 +1,4 @@ -from typing import Any, AsyncGenerator, List, Mapping, Sequence, Tuple +from typing import Any, AsyncGenerator, List, Mapping, Sequence from autogen_core import CancellationToken from autogen_core.models import ChatCompletionClient, LLMMessage, SystemMessage, UserMessage @@ -103,7 +103,7 @@ def __init__( self._response_prompt = response_prompt @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: return (TextMessage,) async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken) -> Response: diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py index 1695be4267c0..b3e15da851ee 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py @@ -1,6 +1,6 @@ import asyncio from inspect import iscoroutinefunction -from typing import Awaitable, Callable, Optional, Sequence, Tuple, Union, cast +from typing import Awaitable, Callable, Optional, Sequence, Union, cast from aioconsole import ainput # type: ignore from autogen_core import CancellationToken @@ -122,7 +122,7 @@ def __init__( self._is_async = iscoroutinefunction(self.input_func) @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: """Message types this agent can produce.""" return (TextMessage, HandoffMessage) diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py index 7610eba2052b..c4ea0218916c 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_chat_agent.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from typing import Any, AsyncGenerator, Mapping, Protocol, Sequence, Tuple, runtime_checkable +from typing import Any, AsyncGenerator, Mapping, Protocol, Sequence, runtime_checkable from autogen_core import CancellationToken @@ -37,7 +37,7 @@ def description(self) -> str: ... @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: """The types of messages that the agent produces in the :attr:`Response.chat_message` field. They must be :class:`ChatMessage` types.""" ... diff --git a/python/packages/autogen-agentchat/tests/test_group_chat.py b/python/packages/autogen-agentchat/tests/test_group_chat.py index e8893cf2a302..25194d6049af 100644 --- a/python/packages/autogen-agentchat/tests/test_group_chat.py +++ b/python/packages/autogen-agentchat/tests/test_group_chat.py @@ -2,7 +2,7 @@ import json import logging import tempfile -from typing import Any, AsyncGenerator, List, Sequence, Tuple +from typing import Any, AsyncGenerator, List, Sequence import pytest from autogen_agentchat import EVENT_LOGGER_NAME @@ -75,7 +75,7 @@ def __init__(self, name: str, description: str) -> None: self._total_messages = 0 @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: return (TextMessage,) @property @@ -104,7 +104,7 @@ def __init__(self, name: str, description: str, *, stop_at: int = 1) -> None: self._stop_at = stop_at @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: return (TextMessage, StopMessage) async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken) -> Response: @@ -797,7 +797,7 @@ def __init__(self, name: str, description: str, next_agent: str) -> None: self._next_agent = next_agent @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: return (HandoffMessage,) async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken) -> Response: diff --git a/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py b/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py index 78191045f255..4a2f831aeba6 100644 --- a/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py +++ b/python/packages/autogen-agentchat/tests/test_magentic_one_group_chat.py @@ -1,7 +1,7 @@ import asyncio import json import logging -from typing import Sequence, Tuple +from typing import Sequence import pytest from autogen_agentchat import EVENT_LOGGER_NAME @@ -33,7 +33,7 @@ def __init__(self, name: str, description: str) -> None: self._total_messages = 0 @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: return (TextMessage,) @property diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb index f541671e62f6..6e2dfa90b494 100644 --- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb +++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/custom-agents.ipynb @@ -63,7 +63,7 @@ " self._count = count\n", "\n", " @property\n", - " def produced_message_types(self) -> Tuple[type[ChatMessage], ...]:\n", + " def produced_message_types(self) -> Sequence[type[ChatMessage]]:\n", " return (TextMessage,)\n", "\n", " async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken) -> Response:\n", @@ -130,7 +130,7 @@ "metadata": {}, "outputs": [], "source": [ - "from typing import Callable, Sequence, Tuple\n", + "from typing import Callable, Sequence\n", "\n", "from autogen_agentchat.agents import BaseChatAgent\n", "from autogen_agentchat.base import Response\n", @@ -149,7 +149,7 @@ " self._message_history: List[ChatMessage] = []\n", "\n", " @property\n", - " def produced_message_types(self) -> Tuple[type[ChatMessage], ...]:\n", + " def produced_message_types(self) -> Sequence[type[ChatMessage]]:\n", " return (TextMessage,)\n", "\n", " async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken) -> Response:\n", @@ -310,4 +310,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py b/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py index 291acf418ca8..7f73016971ca 100644 --- a/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py +++ b/python/packages/autogen-ext/src/autogen_ext/agents/file_surfer/_file_surfer.py @@ -63,7 +63,7 @@ def __init__( self._browser = MarkdownFileBrowser(viewport_size=1024 * 5) @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: return (TextMessage,) async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token: CancellationToken) -> Response: diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py b/python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py index 97c1b166ff48..6c11fcd76e58 100644 --- a/python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py +++ b/python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py @@ -15,7 +15,6 @@ Optional, Sequence, Set, - Tuple, Union, cast, ) @@ -299,7 +298,7 @@ async def _retrieve_initial_state(self) -> None: self._initial_message_ids = initial_message_ids @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: """The types of messages that the assistant agent produces.""" return (TextMessage,) diff --git a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py index 6173a857b74f..8f59964731dd 100644 --- a/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py +++ b/python/packages/autogen-ext/src/autogen_ext/agents/web_surfer/_multimodal_web_surfer.py @@ -15,7 +15,6 @@ List, Optional, Sequence, - Tuple, cast, ) from urllib.parse import quote_plus @@ -322,7 +321,7 @@ async def _set_debug_dir(self, debug_dir: str | None) -> None: ) @property - def produced_message_types(self) -> Tuple[type[ChatMessage], ...]: + def produced_message_types(self) -> Sequence[type[ChatMessage]]: return (MultiModalMessage,) async def on_reset(self, cancellation_token: CancellationToken) -> None: