mirror of
https://github.com/microsoft/autogen.git
synced 2025-06-26 22:30:10 +00:00
Update README to clarify Web Browsing Agent Team usage, and use animated Chromium browser (#5861)
Because it is more fun to see it
This commit is contained in:
parent
740afe5b61
commit
704dab1018
29
README.md
29
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())
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user