mirror of
https://github.com/microsoft/autogen.git
synced 2026-02-10 17:34:55 -05:00
Add user proxy docs. Make user proxy's default impl cancellable (#4459)
* Add user proxy docs. Make user proxy's default impl cancellable * remove unnecessary import * revert accidental change * address PR comments * uv sync * Fix bugs * poe format * fixing mypy issues * poe format * ignore pyright errors for ainput * fix example code * remove unused import * fix accidental reversion, example code * formatting * fix typing * Update python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/agents.ipynb Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/agents.ipynb --------- Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -101,6 +101,39 @@
|
||||
"as well as a list of inner messages in the {py:attr}`~autogen_agentchat.base.Response.inner_messages` attribute,\n",
|
||||
"which stores the agent's \"thought process\" that led to the final response.\n",
|
||||
"\n",
|
||||
"## User Proxy Agent\n",
|
||||
"\n",
|
||||
"{py:class}`~autogen_agentchat.agents.UserProxyAgent` is a built-in agent that\n",
|
||||
"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."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from autogen_agentchat.agents import UserProxyAgent\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"async def user_proxy_run() -> None:\n",
|
||||
" user_proxy_agent = UserProxyAgent(\"user_proxy\")\n",
|
||||
" response = await user_proxy_agent.on_messages(\n",
|
||||
" [TextMessage(content=\"What is your name? \", source=\"user\")], cancellation_token=CancellationToken()\n",
|
||||
" )\n",
|
||||
" print(f\"Your name is {response.chat_message.content}\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Use asyncio.run(user_proxy_run()) when running in a script.\n",
|
||||
"await user_proxy_run()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"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 the session using a termination condition and start another one from run or run_stream with another message.\n",
|
||||
"\n",
|
||||
"### Stream Messages\n",
|
||||
"\n",
|
||||
"We can also stream each message as it is generated by the agent by using the\n",
|
||||
|
||||
@@ -17,6 +17,7 @@ classifiers = [
|
||||
dependencies = [
|
||||
"openai>=1.3",
|
||||
"pillow",
|
||||
"aioconsole",
|
||||
"aiohttp",
|
||||
"typing-extensions",
|
||||
"pydantic<3.0.0,>=2.0.0",
|
||||
|
||||
Reference in New Issue
Block a user