From 0f0d0b8d206dc49cb5fbd85e6404064a669d9fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20=C5=BDuni=C4=8D?= <36313686+gregpr07@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:42:38 +0100 Subject: [PATCH] bumped up version, web voyager agent example --- examples/web_voyager_agent.py | 61 +++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 examples/web_voyager_agent.py diff --git a/examples/web_voyager_agent.py b/examples/web_voyager_agent.py new file mode 100644 index 000000000..e6dce67da --- /dev/null +++ b/examples/web_voyager_agent.py @@ -0,0 +1,61 @@ +import os +import sys + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +import asyncio +import os + +from langchain_openai import AzureChatOpenAI +from pydantic import SecretStr + +from browser_use.agent.service import Agent +from browser_use.browser.browser import Browser, BrowserConfig, BrowserContextConfig + +browser = Browser( + config=BrowserConfig( + headless=False, # This is True in production + disable_security=True, + new_context_config=BrowserContextConfig( + disable_security=True, + minimum_wait_page_load_time=4, + maximum_wait_page_load_time=20, + # no_viewport=True, + browser_window_size={ + 'width': 1280, + 'height': 1100, + }, + # trace_path='./tmp/web_voyager_agent', + ), + ) +) +llm = AzureChatOpenAI( + model='gpt-4o', + api_version='2024-10-21', + azure_endpoint=os.getenv('AZURE_OPENAI_ENDPOINT', ''), + api_key=SecretStr(os.getenv('AZURE_OPENAI_KEY', '')), +) + +# TASK = """ +# Find the lowest-priced one-way flight from Cairo to Montreal on February 21, 2025, including the total travel time and number of stops. on https://www.google.com/travel/flights/ +# """ +# TASK = """ +# Browse Coursera, which universities offer Master of Advanced Study in Engineering degrees? Tell me what is the latest application deadline for this degree? on https://www.coursera.org/""" +TASK = """ +Find the names of people in ArXiv's Leadership Team. on https://arxiv.org/ +""" + + +async def main(): + agent = Agent( + task=TASK, + llm=llm, + browser=browser, + validate_output=True, + ) + history = await agent.run(max_steps=50) + history.save_to_file('./tmp/history.json') + + +if __name__ == '__main__': + asyncio.run(main()) diff --git a/pyproject.toml b/pyproject.toml index c2540950d..93e330f16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ description = "Make websites accessible for AI agents" authors = [ { name = "Gregor Zunic" } ] -version = "0.1.16" +version = "0.1.17" readme = "README.md" requires-python = ">=3.11" classifiers = [