Skip to content

Commit 5f96156

Browse files
moonbox3glorious-beard
authored andcommitted
Python: Add deprecaton warning to add_chat_message for server agents (microsoft#11331)
### Motivation and Context Now that we have a common agent invocation API, that uses threads, we will be deprecating the `add_chat_message` for the `AzureAIAgent` and `OpenAIAssistantAgent`. Add the deprecation decorator and message. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Add the deprecation decorator and message. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄
1 parent 7d41157 commit 5f96156

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

python/semantic_kernel/agents/azure_ai/azure_ai_agent.py

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from collections.abc import AsyncIterable, Callable, Iterable
66
from typing import TYPE_CHECKING, Any, ClassVar, Literal, TypeVar
77

8+
from typing_extensions import deprecated
9+
810
if sys.version_info >= (3, 12):
911
from typing import override # pragma: no cover
1012
else:
@@ -598,6 +600,9 @@ async def create_channel(self, thread_id: str | None = None) -> AgentChannel:
598600

599601
return AzureAIChannel(client=self.client, thread_id=thread.id)
600602

603+
@deprecated(
604+
"Pass messages directly to get_response(...)/invoke(...) instead. This method will be removed after May 1st 2025." # noqa: E501
605+
)
601606
async def add_chat_message(self, thread_id: str, message: str | ChatMessageContent) -> "ThreadMessage | None":
602607
"""Add a chat message to the thread.
603608

python/semantic_kernel/agents/open_ai/open_ai_assistant_agent.py

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from copy import copy
77
from typing import TYPE_CHECKING, Any, ClassVar, Literal
88

9+
from typing_extensions import deprecated
10+
911
if sys.version_info >= (3, 12):
1012
from typing import override # pragma: no cover
1113
else:
@@ -440,6 +442,9 @@ async def create_channel(self, thread_id: str | None = None) -> AgentChannel:
440442

441443
# region Message Handling
442444

445+
@deprecated(
446+
"Pass messages directly to get_response(...)/invoke(...) instead. This method will be removed after May 1st 2025." # noqa: E501
447+
)
443448
async def add_chat_message(
444449
self, thread_id: str, message: "str | ChatMessageContent", **kwargs: Any
445450
) -> "Message | None":

0 commit comments

Comments
 (0)