mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
reset --> on_reset :D (#4121)
This commit is contained in:
@@ -298,6 +298,6 @@ class AssistantAgent(BaseChatAgent):
|
||||
except Exception as e:
|
||||
return FunctionExecutionResult(content=f"Error: {e}", call_id=tool_call.id)
|
||||
|
||||
async def reset(self, cancellation_token: CancellationToken) -> None:
|
||||
async def on_reset(self, cancellation_token: CancellationToken) -> None:
|
||||
"""Reset the assistant agent to its initialization state."""
|
||||
self._model_context.clear()
|
||||
|
||||
@@ -106,6 +106,6 @@ class BaseChatAgent(ChatAgent, ABC):
|
||||
yield message
|
||||
|
||||
@abstractmethod
|
||||
async def reset(self, cancellation_token: CancellationToken) -> None:
|
||||
async def on_reset(self, cancellation_token: CancellationToken) -> None:
|
||||
"""Resets the agent to its initialization state."""
|
||||
...
|
||||
|
||||
@@ -39,6 +39,6 @@ class CodeExecutorAgent(BaseChatAgent):
|
||||
else:
|
||||
return Response(chat_message=TextMessage(content="No code blocks found in the thread.", source=self.name))
|
||||
|
||||
async def reset(self, cancellation_token: CancellationToken) -> None:
|
||||
async def on_reset(self, cancellation_token: CancellationToken) -> None:
|
||||
"""It it's a no-op as the code executor agent has no mutable state."""
|
||||
pass
|
||||
|
||||
@@ -141,7 +141,7 @@ class SocietyOfMindAgent(BaseChatAgent):
|
||||
# Reset the team.
|
||||
await self._team.reset()
|
||||
|
||||
async def reset(self, cancellation_token: CancellationToken) -> None:
|
||||
async def on_reset(self, cancellation_token: CancellationToken) -> None:
|
||||
await self._team.reset()
|
||||
|
||||
def _create_transcript(self, messages: Sequence[AgentMessage]) -> str:
|
||||
|
||||
@@ -51,6 +51,6 @@ class ChatAgent(TaskRunner, Protocol):
|
||||
and the final item is the response."""
|
||||
...
|
||||
|
||||
async def reset(self, cancellation_token: CancellationToken) -> None:
|
||||
async def on_reset(self, cancellation_token: CancellationToken) -> None:
|
||||
"""Resets the agent to its initialization state."""
|
||||
...
|
||||
|
||||
@@ -42,7 +42,7 @@ class ChatAgentContainer(SequentialRoutedAgent):
|
||||
async def handle_reset(self, message: GroupChatReset, ctx: MessageContext) -> None:
|
||||
"""Handle a reset event by resetting the agent."""
|
||||
self._message_buffer.clear()
|
||||
await self._agent.reset(ctx.cancellation_token)
|
||||
await self._agent.on_reset(ctx.cancellation_token)
|
||||
|
||||
@event
|
||||
async def handle_request(self, message: GroupChatRequestPublish, ctx: MessageContext) -> None:
|
||||
|
||||
@@ -83,7 +83,7 @@ class _EchoAgent(BaseChatAgent):
|
||||
assert self._last_message is not None
|
||||
return Response(chat_message=TextMessage(content=self._last_message, source=self.name))
|
||||
|
||||
async def reset(self, cancellation_token: CancellationToken) -> None:
|
||||
async def on_reset(self, cancellation_token: CancellationToken) -> None:
|
||||
self._last_message = None
|
||||
|
||||
|
||||
@@ -633,7 +633,7 @@ class _HandOffAgent(BaseChatAgent):
|
||||
)
|
||||
)
|
||||
|
||||
async def reset(self, cancellation_token: CancellationToken) -> None:
|
||||
async def on_reset(self, cancellation_token: CancellationToken) -> None:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"- {py:attr}`~autogen_agentchat.agents.BaseChatAgent.description`: The description of the agent in text.\n",
|
||||
"- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages`: Send the agent a sequence of {py:class}`~autogen_agentchat.messages.ChatMessage` get a {py:class}`~autogen_agentchat.base.Response`.\n",
|
||||
"- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages_stream`: Same as {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages` but returns an iterator of {py:class}`~autogen_agentchat.messages.AgentMessage` followed by a {py:class}`~autogen_agentchat.base.Response` as the last item.\n",
|
||||
"- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.reset`: Reset the agent to its initial state.\n",
|
||||
"- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_reset`: Reset the agent to its initial state.\n",
|
||||
"\n",
|
||||
"See {py:mod}`autogen_agentchat.messages` for more information on AgentChat message types.\n",
|
||||
"\n",
|
||||
@@ -272,7 +272,7 @@
|
||||
"class and implement the following abstract methods and attributes:\n",
|
||||
"\n",
|
||||
"- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages`: The abstract method that defines the behavior of the agent in response to messages. This method is called when the agent is asked to provide a response in {py:meth}`~autogen_agentchat.agents.BaseChatAgent.run`. It returns a {py:class}`~autogen_agentchat.base.Response` object.\n",
|
||||
"- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.reset`: The abstract method that resets the agent to its initial state. This method is called when the agent is asked to reset itself.\n",
|
||||
"- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_reset`: The abstract method that resets the agent to its initial state. This method is called when the agent is asked to reset itself.\n",
|
||||
"- {py:attr}`~autogen_agentchat.agents.BaseChatAgent.produced_message_types`: The list of possible {py:class}`~autogen_agentchat.messages.ChatMessage` message types the agent can produce in its response.\n",
|
||||
"\n",
|
||||
"Optionally, you can implement the the {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages_stream` method to stream messages as they are generated by the agent. If this method is not implemented, the agent\n",
|
||||
@@ -345,7 +345,7 @@
|
||||
" # It contains the final message and all the inner messages.\n",
|
||||
" yield Response(chat_message=TextMessage(content=\"Done!\", source=self.name), inner_messages=inner_messages)\n",
|
||||
"\n",
|
||||
" async def reset(self, cancellation_token: CancellationToken) -> None:\n",
|
||||
" async def on_reset(self, cancellation_token: CancellationToken) -> None:\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@@ -406,7 +406,7 @@
|
||||
" user_input = await asyncio.get_event_loop().run_in_executor(None, input, \"Enter your response: \")\n",
|
||||
" return Response(chat_message=TextMessage(content=user_input, source=self.name))\n",
|
||||
"\n",
|
||||
" async def reset(self, cancellation_token: CancellationToken) -> None:\n",
|
||||
" async def on_reset(self, cancellation_token: CancellationToken) -> None:\n",
|
||||
" pass\n",
|
||||
"\n",
|
||||
"\n",
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
" return Response(chat_message=StopMessage(content=\"User has terminated the conversation.\", source=self.name))\n",
|
||||
" return Response(chat_message=TextMessage(content=user_input, source=self.name))\n",
|
||||
"\n",
|
||||
" async def reset(self, cancellation_token: CancellationToken) -> None:\n",
|
||||
" async def on_reset(self, cancellation_token: CancellationToken) -> None:\n",
|
||||
" pass"
|
||||
]
|
||||
},
|
||||
@@ -281,7 +281,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.6"
|
||||
"version": "3.11.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user