From 973c8b63302df5b13ddbb83628d7cabd09a960fa Mon Sep 17 00:00:00 2001 From: Jack Gerrits Date: Wed, 8 Jan 2025 08:56:08 -0500 Subject: [PATCH] Remove deprecated items for release (#4927) --- .../src/autogen_agentchat/agents/__init__.py | 7 +- .../agents/_assistant_agent.py | 13 --- .../agents/_coding_assistant_agent.py | 40 --------- .../agents/_tool_use_assistant_agent.py | 46 ---------- .../src/autogen_agentchat/messages.py | 38 +------- .../src/autogen_agentchat/task/__init__.py | 88 ------------------- .../src/autogen_core/base/__init__.py | 0 .../src/autogen_core/base/intervention.py | 22 ----- 8 files changed, 2 insertions(+), 252 deletions(-) delete mode 100644 python/packages/autogen-agentchat/src/autogen_agentchat/agents/_coding_assistant_agent.py delete mode 100644 python/packages/autogen-agentchat/src/autogen_agentchat/agents/_tool_use_assistant_agent.py delete mode 100644 python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py delete mode 100644 python/packages/autogen-core/src/autogen_core/base/__init__.py delete mode 100644 python/packages/autogen-core/src/autogen_core/base/intervention.py diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py index 855e66ae8..a6732d12e 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/__init__.py @@ -3,21 +3,16 @@ This module initializes various pre-defined agents provided by the package. BaseChatAgent is the base class for all agents in AgentChat. """ -from ._assistant_agent import AssistantAgent, Handoff # type: ignore +from ._assistant_agent import AssistantAgent from ._base_chat_agent import BaseChatAgent from ._code_executor_agent import CodeExecutorAgent -from ._coding_assistant_agent import CodingAssistantAgent from ._society_of_mind_agent import SocietyOfMindAgent -from ._tool_use_assistant_agent import ToolUseAssistantAgent from ._user_proxy_agent import UserProxyAgent __all__ = [ "BaseChatAgent", "AssistantAgent", - "Handoff", "CodeExecutorAgent", - "CodingAssistantAgent", - "ToolUseAssistantAgent", "SocietyOfMindAgent", "UserProxyAgent", ] 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 95f8e8dd8..f60a44dbb 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 @@ -27,7 +27,6 @@ from autogen_core.models import ( UserMessage, ) from autogen_core.tools import FunctionTool, Tool -from typing_extensions import deprecated from .. import EVENT_LOGGER_NAME from ..base import Handoff as HandoffBase @@ -48,18 +47,6 @@ from ._base_chat_agent import BaseChatAgent event_logger = logging.getLogger(EVENT_LOGGER_NAME) -@deprecated("Moved to autogen_agentchat.base.Handoff. Will remove in 0.4.0.", stacklevel=2) -class Handoff(HandoffBase): - """[DEPRECATED] Handoff configuration. Moved to :class:`autogen_agentchat.base.Handoff`. Will remove in 0.4.0.""" - - def model_post_init(self, __context: Any) -> None: - warnings.warn( - "Handoff was moved to autogen_agentchat.base.Handoff. Importing from this will be removed in 0.4.0.", - DeprecationWarning, - stacklevel=2, - ) - - class AssistantAgent(BaseChatAgent): """An agent that provides assistance with tool use. diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_coding_assistant_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_coding_assistant_agent.py deleted file mode 100644 index 751b0d440..000000000 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_coding_assistant_agent.py +++ /dev/null @@ -1,40 +0,0 @@ -import warnings - -from autogen_core.models import ( - ChatCompletionClient, -) - -from ._assistant_agent import AssistantAgent - - -class CodingAssistantAgent(AssistantAgent): - """[DEPRECATED] An agent that provides coding assistance using an LLM model client. - - It responds with a StopMessage when 'terminate' is detected in the response. - """ - - def __init__( - self, - name: str, - model_client: ChatCompletionClient, - *, - description: str = "A helpful and general-purpose AI assistant that has strong language skills, Python skills, and Linux command line skills.", - system_message: str = """You are a helpful AI assistant. -Solve tasks using your coding and language skills. -In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute. - 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself. - 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly. -Solve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill. -When using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user. -If you want the user to save the code in a file before executing it, put # filename: inside the code block as the first line. Don't include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use 'print' function for the output when relevant. Check the execution result returned by the user. -If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try. -When you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible. -Reply "TERMINATE" in the end when code has been executed and task is complete.""", - ): - # Deprecation warning. - warnings.warn( - "CodingAssistantAgent is deprecated. Use AssistantAgent instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(name, model_client, description=description, system_message=system_message) diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_tool_use_assistant_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_tool_use_assistant_agent.py deleted file mode 100644 index 1ebe1f226..000000000 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_tool_use_assistant_agent.py +++ /dev/null @@ -1,46 +0,0 @@ -import logging -import warnings -from typing import Any, Awaitable, Callable, List - -from autogen_core.models import ( - ChatCompletionClient, -) -from autogen_core.tools import Tool - -from .. import EVENT_LOGGER_NAME -from ._assistant_agent import AssistantAgent - -event_logger = logging.getLogger(EVENT_LOGGER_NAME) - - -class ToolUseAssistantAgent(AssistantAgent): - """[DEPRECATED] An agent that provides assistance with tool use. - - It responds with a StopMessage when 'terminate' is detected in the response. - - Args: - name (str): The name of the agent. - model_client (ChatCompletionClient): The model client to use for inference. - registered_tools (List[Tool | Callable[..., Any] | Callable[..., Awaitable[Any]]): The tools to register with the agent. - description (str, optional): The description of the agent. - system_message (str, optional): The system message for the model. - """ - - def __init__( - self, - name: str, - model_client: ChatCompletionClient, - registered_tools: List[Tool | Callable[..., Any] | Callable[..., Awaitable[Any]]], - *, - description: str = "An agent that provides assistance with ability to use tools.", - system_message: str = "You are a helpful AI assistant. Solve tasks using your tools. Reply with 'TERMINATE' when the task has been completed.", - ): - # Deprecation warning. - warnings.warn( - "ToolUseAssistantAgent is deprecated. Use AssistantAgent instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__( - name, model_client, tools=registered_tools, description=description, system_message=system_message - ) diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py b/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py index 923b56960..07fc3123e 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/messages.py @@ -10,7 +10,7 @@ from typing import List, Literal from autogen_core import FunctionCall, Image from autogen_core.models import FunctionExecutionResult, RequestUsage from pydantic import BaseModel, ConfigDict, Field -from typing_extensions import Annotated, deprecated +from typing_extensions import Annotated class BaseMessage(BaseModel, ABC): @@ -76,26 +76,6 @@ class HandoffMessage(BaseChatMessage): type: Literal["HandoffMessage"] = "HandoffMessage" -@deprecated("Will be removed in 0.4.0, use ToolCallRequestEvent instead.") -class ToolCallMessage(BaseMessage): - """A message signaling the use of tools.""" - - content: List[FunctionCall] - """The tool calls.""" - - type: Literal["ToolCallMessage"] = "ToolCallMessage" - - -@deprecated("Will be removed in 0.4.0, use ToolCallExecutionEvent instead.") -class ToolCallResultMessage(BaseMessage): - """A message signaling the results of tool calls.""" - - content: List[FunctionExecutionResult] - """The tool call results.""" - - type: Literal["ToolCallResultMessage"] = "ToolCallResultMessage" - - class ToolCallRequestEvent(BaseAgentEvent): """An event signaling a request to use tools.""" @@ -133,19 +113,6 @@ AgentEvent = Annotated[ToolCallRequestEvent | ToolCallExecutionEvent, Field(disc """Events emitted by agents and teams when they work, not used for agent-to-agent communication.""" -AgentMessage = Annotated[ - TextMessage - | MultiModalMessage - | StopMessage - | HandoffMessage - | ToolCallRequestEvent - | ToolCallExecutionEvent - | ToolCallSummaryMessage, - Field(discriminator="type"), -] -"""(Deprecated, will be removed in 0.4.0) All message and event types.""" - - __all__ = [ "BaseMessage", "TextMessage", @@ -154,10 +121,7 @@ __all__ = [ "HandoffMessage", "ToolCallRequestEvent", "ToolCallExecutionEvent", - "ToolCallMessage", - "ToolCallResultMessage", "ToolCallSummaryMessage", "ChatMessage", "AgentEvent", - "AgentMessage", ] diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py b/python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py deleted file mode 100644 index a45983d83..000000000 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/task/__init__.py +++ /dev/null @@ -1,88 +0,0 @@ -from typing import AsyncGenerator, TypeVar - -from typing_extensions import deprecated - -from ..base import Response, TaskResult -from ..conditions import ( - ExternalTermination as ExternalTerminationAlias, -) -from ..conditions import ( - HandoffTermination as HandoffTerminationAlias, -) -from ..conditions import ( - MaxMessageTermination as MaxMessageTerminationAlias, -) -from ..conditions import ( - SourceMatchTermination as SourceMatchTerminationAlias, -) -from ..conditions import ( - StopMessageTermination as StopMessageTerminationAlias, -) -from ..conditions import ( - TextMentionTermination as TextMentionTerminationAlias, -) -from ..conditions import ( - TimeoutTermination as TimeoutTerminationAlias, -) -from ..conditions import ( - TokenUsageTermination as TokenUsageTerminationAlias, -) -from ..messages import AgentEvent, ChatMessage -from ..ui import Console as ConsoleAlias - - -@deprecated("Moved to autogen_agentchat.conditions.ExternalTermination. Will remove this in 0.4.0.", stacklevel=2) -class ExternalTermination(ExternalTerminationAlias): ... - - -@deprecated("Moved to autogen_agentchat.conditions.HandoffTermination. Will remove this in 0.4.0.", stacklevel=2) -class HandoffTermination(HandoffTerminationAlias): ... - - -@deprecated("Moved to autogen_agentchat.conditions.MaxMessageTermination. Will remove this in 0.4.0.", stacklevel=2) -class MaxMessageTermination(MaxMessageTerminationAlias): ... - - -@deprecated("Moved to autogen_agentchat.conditions.SourceMatchTermination. Will remove this in 0.4.0.", stacklevel=2) -class SourceMatchTermination(SourceMatchTerminationAlias): ... - - -@deprecated("Moved to autogen_agentchat.conditions.StopMessageTermination. Will remove this in 0.4.0.", stacklevel=2) -class StopMessageTermination(StopMessageTerminationAlias): ... - - -@deprecated("Moved to autogen_agentchat.conditions.TextMentionTermination. Will remove this in 0.4.0.", stacklevel=2) -class TextMentionTermination(TextMentionTerminationAlias): ... - - -@deprecated("Moved to autogen_agentchat.conditions.TimeoutTermination. Will remove this in 0.4.0.", stacklevel=2) -class TimeoutTermination(TimeoutTerminationAlias): ... - - -@deprecated("Moved to autogen_agentchat.conditions.TokenUsageTermination. Will remove this in 0.4.0.", stacklevel=2) -class TokenUsageTermination(TokenUsageTerminationAlias): ... - - -T = TypeVar("T", bound=TaskResult | Response) - - -@deprecated("Moved to autogen_agentchat.ui.Console. Will remove this in 0.4.0.", stacklevel=2) -async def Console( - stream: AsyncGenerator[AgentEvent | ChatMessage | T, None], - *, - no_inline_images: bool = False, -) -> T: - return await ConsoleAlias(stream, no_inline_images=no_inline_images) - - -__all__ = [ - "MaxMessageTermination", - "TextMentionTermination", - "StopMessageTermination", - "TokenUsageTermination", - "HandoffTermination", - "TimeoutTermination", - "ExternalTermination", - "SourceMatchTermination", - "Console", -] diff --git a/python/packages/autogen-core/src/autogen_core/base/__init__.py b/python/packages/autogen-core/src/autogen_core/base/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/python/packages/autogen-core/src/autogen_core/base/intervention.py b/python/packages/autogen-core/src/autogen_core/base/intervention.py deleted file mode 100644 index aa4a388a3..000000000 --- a/python/packages/autogen-core/src/autogen_core/base/intervention.py +++ /dev/null @@ -1,22 +0,0 @@ -from typing_extensions import deprecated - -from .._intervention import DefaultInterventionHandler as DefaultInterventionHandlerAlias -from .._intervention import DropMessage as DropMessageAlias -from .._intervention import InterventionHandler as InterventionHandlerAliass - -__all__ = [ - "DropMessage", - "InterventionHandler", - "DefaultInterventionHandler", -] - -# Final so can't inherit and deprecate -DropMessage = DropMessageAlias - - -@deprecated("Moved to autogen_core.InterventionHandler. Will remove this in 0.4.0.", stacklevel=2) -class InterventionHandler(InterventionHandlerAliass): ... - - -@deprecated("Moved to autogen_core.DefaultInterventionHandler. Will remove this in 0.4.0.", stacklevel=2) -class DefaultInterventionHandler(DefaultInterventionHandlerAlias): ...