|
14 | 14 | "- {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`. **It is important to note that agents are expected to be stateful and this method is expected to be called with new messages, not the complete history**.\n", |
15 | 15 | "- {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.AgentEvent` or {py:class}`~autogen_agentchat.messages.ChatMessage` followed by a {py:class}`~autogen_agentchat.base.Response` as the last item.\n", |
16 | 16 | "- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_reset`: Reset the agent to its initial state.\n", |
| 17 | + "- {py:meth}`~autogen_agentchat.agents.BaseChatAgent.run` and {py:meth}`~autogen_agentchat.agents.BaseChatAgent.run_stream`: convenience methods that call {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages` and {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages_stream` respectively but offer the same interface as [Teams](./teams.ipynb).\n", |
17 | 18 | "\n", |
18 | 19 | "See {py:mod}`autogen_agentchat.messages` for more information on AgentChat message types.\n", |
19 | 20 | "\n", |
|
115 | 116 | "Unlike in v0.2 AgentChat, the tools are executed by the same agent directly within\n", |
116 | 117 | "the same call to {py:meth}`~autogen_agentchat.agents.AssistantAgent.on_messages`.\n", |
117 | 118 | "By default, the agent will return the result of the tool call as the final response.\n", |
118 | | - "```" |
| 119 | + "```\n", |
| 120 | + "\n", |
| 121 | + "You can also call the {py:meth}`~autogen_agentchat.agents.BaseChatAgent.run` method, which is a convenience method that calls {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages`. \n", |
| 122 | + "It follows the same interface as [Teams](./teams.ipynb) and returns a {py:class}`~autogen_agentchat.base.TaskResult` object." |
119 | 123 | ] |
120 | 124 | }, |
121 | 125 | { |
|
186 | 190 | "with the final item being the response message in the {py:attr}`~autogen_agentchat.base.Response.chat_message` attribute.\n", |
187 | 191 | "\n", |
188 | 192 | "From the messages, you can observe that the assistant agent utilized the `web_search` tool to\n", |
189 | | - "gather information and responded based on the search results." |
| 193 | + "gather information and responded based on the search results.\n", |
| 194 | + "\n", |
| 195 | + "You can also use {py:meth}`~autogen_agentchat.agents.BaseChatAgent.run_stream` to get the same streaming behavior as {py:meth}`~autogen_agentchat.agents.BaseChatAgent.on_messages_stream`. It follows the same interface as [Teams](./teams.ipynb)." |
190 | 196 | ] |
191 | 197 | }, |
192 | 198 | { |
|
310 | 316 | ")" |
311 | 317 | ] |
312 | 318 | }, |
313 | | - { |
314 | | - "cell_type": "markdown", |
315 | | - "metadata": {}, |
316 | | - "source": [ |
317 | | - "## User Proxy Agent\n", |
318 | | - "\n", |
319 | | - "{py:class}`~autogen_agentchat.agents.UserProxyAgent` is a built-in agent that\n", |
320 | | - "provides one way for a user to intervene in the process. This agent will put the team in a temporary blocking state, and thus any exceptions or runtime failures while in the blocked state will result in a deadlock. It is strongly advised that this agent be coupled with a timeout mechanic and that all errors and exceptions emanating from it are handled." |
321 | | - ] |
322 | | - }, |
323 | | - { |
324 | | - "cell_type": "code", |
325 | | - "execution_count": null, |
326 | | - "metadata": {}, |
327 | | - "outputs": [], |
328 | | - "source": [ |
329 | | - "from autogen_agentchat.agents import UserProxyAgent\n", |
330 | | - "\n", |
331 | | - "\n", |
332 | | - "async def user_proxy_run() -> None:\n", |
333 | | - " user_proxy_agent = UserProxyAgent(\"user_proxy\")\n", |
334 | | - " response = await user_proxy_agent.on_messages(\n", |
335 | | - " [TextMessage(content=\"What is your name? \", source=\"user\")], cancellation_token=CancellationToken()\n", |
336 | | - " )\n", |
337 | | - " print(f\"Your name is {response.chat_message.content}\")\n", |
338 | | - "\n", |
339 | | - "\n", |
340 | | - "# Use asyncio.run(user_proxy_run()) when running in a script.\n", |
341 | | - "await user_proxy_run()" |
342 | | - ] |
343 | | - }, |
344 | | - { |
345 | | - "cell_type": "markdown", |
346 | | - "metadata": {}, |
347 | | - "source": [ |
348 | | - "The User Proxy agent is ideally used for on-demand human-in-the-loop interactions for scenarios such as Just In Time approvals, human feedback, alerts, etc. For slower user interactions, consider terminating a team using a termination condition and start another one from\n", |
349 | | - "{py:meth}`~autogen_agentchat.base.TaskRunner.run` or {py:meth}`~autogen_agentchat.base.TaskRunner.run_stream` with another message." |
350 | | - ] |
351 | | - }, |
352 | 319 | { |
353 | 320 | "cell_type": "markdown", |
354 | 321 | "metadata": {}, |
|
357 | 324 | "\n", |
358 | 325 | "The following preset agents are available:\n", |
359 | 326 | "\n", |
| 327 | + "- {py:class}`~autogen_agentchat.agents.UserProxyAgent`: An agent that takes user input returns it as responses.\n", |
360 | 328 | "- {py:class}`~autogen_agentchat.agents.CodeExecutorAgent`: An agent that can execute code.\n", |
361 | 329 | "- {py:class}`~autogen_ext.agents.openai.OpenAIAssistantAgent`: An agent that is backed by an OpenAI Assistant, with ability to use custom tools.\n", |
362 | 330 | "- {py:class}`~autogen_ext.agents.web_surfer.MultimodalWebSurfer`: A multi-modal agent that can search the web and visit web pages for information.\n", |
|
0 commit comments