Change base agent to use on message impl (#4485)

* Change base agent to use on message impl

* update doc

* Update

* Merge branch 'main' into on_msg_impl
This commit is contained in:
Jack Gerrits
2024-12-03 13:04:12 -05:00
committed by GitHub
parent 934ae03851
commit 954ba84fe7
8 changed files with 21 additions and 17 deletions

View File

@@ -19,7 +19,7 @@
"An agent in AutoGen is an entity defined by the base class {py:class}`autogen_core.base.BaseAgent`.\n",
"It has a unique identifier of the type {py:class}`autogen_core.base.AgentId`,\n",
"a metadata dictionary of the type {py:class}`autogen_core.base.AgentMetadata`,\n",
"and method for handling messages {py:meth}`autogen_core.base.BaseAgent.on_message`.\n",
"and method for handling messages {py:meth}`autogen_core.base.BaseAgent.on_message_impl`.\n",
"\n",
"An agent runtime is the execution environment for agents in AutoGen.\n",
"Similar to the runtime environment of a programming language,\n",
@@ -42,14 +42,14 @@
"## Implementing an Agent\n",
"\n",
"To implement an agent, the developer must subclass the {py:class}`~autogen_core.base.BaseAgent` class\n",
"and implement the {py:meth}`~autogen_core.base.BaseAgent.on_message` method.\n",
"and implement the {py:meth}`~autogen_core.base.BaseAgent.on_message_impl` method.\n",
"This method is invoked when the agent receives a message. For example,\n",
"the following agent handles a simple message type and prints the message it receives:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -67,7 +67,7 @@
" def __init__(self) -> None:\n",
" super().__init__(\"MyAgent\")\n",
"\n",
" async def on_message(self, message: MyMessageType, ctx: MessageContext) -> None:\n",
" async def on_message_impl(self, message: MyMessageType, ctx: MessageContext) -> None:\n",
" print(f\"Received message: {message.content}\") # type: ignore"
]
},
@@ -254,7 +254,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "autogen_core",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
@@ -268,7 +268,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.6"
}
},
"nbformat": 4,