[Add] browser-use and main.py
This commit is contained in:
parent
08e64bdf45
commit
96914d44ac
221 changed files with 30952 additions and 1 deletions
34
browser-use/examples/features/save_trace.py
Normal file
34
browser-use/examples/features/save_trace.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import asyncio
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
from browser_use.agent.service import Agent
|
||||
from browser_use.browser.browser import Browser
|
||||
from browser_use.browser.context import BrowserContextConfig
|
||||
|
||||
llm = ChatOpenAI(model='gpt-4o', temperature=0.0)
|
||||
|
||||
|
||||
async def main():
|
||||
browser = Browser()
|
||||
|
||||
async with await browser.new_context(config=BrowserContextConfig(trace_path='./tmp/traces/')) as context:
|
||||
agent = Agent(
|
||||
task='Go to hackernews, then go to apple.com and return all titles of open tabs',
|
||||
llm=llm,
|
||||
browser_context=context,
|
||||
)
|
||||
await agent.run()
|
||||
|
||||
await browser.close()
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue