Skip to content

Commit

Permalink
add comment to explain await vs run (microsoft#3907)
Browse files Browse the repository at this point in the history
* add comment to explain await vs run

* update output and import

---------

Co-authored-by: Eric Zhu <[email protected]>
  • Loading branch information
jackgerrits and ekzhu authored Oct 23, 2024
1 parent 8cbfb61 commit 8f4d5ee
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@
"text": [
"\n",
"--------------------------------------------------------------------------- \n",
"\u001b[91m[2024-10-20T09:01:32.381165]:\u001b[0m\n",
"\u001b[91m[2024-10-23T12:15:51.582079]:\u001b[0m\n",
"\n",
"What is the weather in New York?\n",
"--------------------------------------------------------------------------- \n",
"\u001b[91m[2024-10-20T09:01:33.698359], writing_agent:\u001b[0m\n",
"\u001b[91m[2024-10-23T12:15:52.745820], writing_agent:\u001b[0m\n",
"\n",
"The weather in New York is currently 73 degrees and sunny. TERMINATE\n",
"--------------------------------------------------------------------------- \n",
"\u001b[91m[2024-10-20T09:01:33.698749], Termination:\u001b[0m\n",
"\u001b[91m[2024-10-23T12:15:52.746210], Termination:\u001b[0m\n",
"\n",
"Maximal number of messages 1 reached, current message count: 1\n",
" TeamRunResult(messages=[TextMessage(source='user', content='What is the weather in New York?'), StopMessage(source='writing_agent', content='The weather in New York is currently 73 degrees and sunny. TERMINATE')])\n"
" TaskResult(messages=[TextMessage(source='user', content='What is the weather in New York?'), StopMessage(source='writing_agent', content='The weather in New York is currently 73 degrees and sunny. TERMINATE')])\n"
]
}
],
"source": [
"import logging\n",
"\n",
"from autogen_agentchat import EVENT_LOGGER_NAME\n",
"from autogen_agentchat.agents import CodingAssistantAgent, ToolUseAssistantAgent\n",
"from autogen_agentchat.agents import ToolUseAssistantAgent\n",
"from autogen_agentchat.logging import ConsoleLogHandler\n",
"from autogen_agentchat.teams import MaxMessageTermination, RoundRobinGroupChat\n",
"from autogen_core.components.models import OpenAIChatCompletionClient\n",
"from autogen_core.components.tools import FunctionTool\n",
"from autogen_ext.models import OpenAIChatCompletionClient\n",
"\n",
"logger = logging.getLogger(EVENT_LOGGER_NAME)\n",
"logger.addHandler(ConsoleLogHandler())\n",
Expand All @@ -84,6 +84,7 @@
"\n",
"# add the agent to a team\n",
"agent_team = RoundRobinGroupChat([weather_agent])\n",
"# Note: if running in a Python file directly you'll need to use asyncio.run(agent_team.run(...)) instead of await agent_team.run(...)\n",
"result = await agent_team.run(\n",
" task=\"What is the weather in New York?\",\n",
" termination_condition=MaxMessageTermination(max_messages=1),\n",
Expand Down Expand Up @@ -111,7 +112,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "agnext",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -125,7 +126,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8f4d5ee

Please sign in to comment.