Skip to content

A programming framework for agentic AI

Update README to clarify Web Browsing Agent Team usage, and use animated Chromium browser (#5861)

Eric Zhu704dab1018de
diff --git a/README.md b/README.md
index e4cdb3c16..ab855e7a8 100644
--- a/README.md
+++ b/README.md
@@ -47,22 +47,24 @@ from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
async def main() -> None:
- agent = AssistantAgent("assistant", OpenAIChatCompletionClient(model="gpt-4o"))
+ model_client = OpenAIChatCompletionClient(model="gpt-4o")
+ agent = AssistantAgent("assistant", model_client=model_client)
print(await agent.run(task="Say 'Hello World!'"))
+ await model_client.close()
asyncio.run(main())
```
-### Team
+### Web Browsing Agent Team
-Create a group chat team with an assistant agent, a web surfer agent, and a user proxy agent
+Create a group chat team with a web surfer agent and a user proxy agent
for web browsing tasks. You need to install [playwright](https://playwright.dev/python/docs/library).
```python
# pip install -U autogen-agentchat autogen-ext[openai,web-surfer]
# playwright install
import asyncio
-from autogen_agentchat.agents import AssistantAgent, UserProxyAgent
+from autogen_agentchat.agents import UserProxyAgent
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.ui import Console
@@ -71,12 +73,21 @@ from autogen_ext.agents.web_surfer import MultimodalWebSurfer
async def main() -> None:
model_client = OpenAIChatCompletionClient(model="gpt-4o")
- assistant = AssistantAgent("assistant", model_client)
- web_surfer = MultimodalWebSurfer("web_surfer", model_client)
+ # The web surfer will open a Chromium browser window to perform web browsing tasks.
+ web_surfer = MultimodalWebSurfer("web_surfer", model_client, headless=False, animate_actions=True)
+ # The user proxy agent is used to get user input after each step of the web surfer.
+ # NOTE: you can skip input by pressing Enter.
user_proxy = UserProxyAgent("user_proxy")
- termination = TextMentionTermination("exit") # Type 'exit' to end the conversation.
- team = RoundRobinGroupChat([web_surfer, assistant, user_proxy], termination_condition=termination)
- await Console(team.run_stream(task="Find information about AutoGen and write a short summary."))
+ # The termination condition is set to end the conversation when the user types 'exit'.
+ termination = TextMentionTermination("exit", sources=["user_proxy"])
+ # Web surfer and user proxy takes turns in a round-robin fashion.
+ team = RoundRobinGroupChat([web_surfer, user_proxy], termination_condition=termination)
+ try:
+ # Start the team and wait for it to terminate.
+ await Console(team.run_stream(task="Find information about AutoGen and write a short summary."))
+ finally:
+ await web_surfer.close()
+ await model_client.close()
asyncio.run(main())
```