Remove deprecated items for release (#4927)

This commit is contained in:
Jack Gerrits 2025-01-08 08:56:08 -05:00 committed by GitHub
parent 00b06ab2e1
commit 973c8b6330
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 2 additions and 252 deletions

View File

@ -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",
]

View File

@ -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.

View File

@ -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: <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)

View File

@ -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
)

View File

@ -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",
]

View File

@ -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",
]

View File

@ -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): ...