[Add] browser-use and main.py
This commit is contained in:
parent
08e64bdf45
commit
96914d44ac
221 changed files with 30952 additions and 1 deletions
21
browser-use/eval/gemini-2.5-preview.py
Normal file
21
browser-use/eval/gemini-2.5-preview.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from langchain_google_genai import ChatGoogleGenerativeAI
|
||||
from pydantic import SecretStr
|
||||
|
||||
from browser_use import Agent, Browser
|
||||
|
||||
load_dotenv()
|
||||
|
||||
api_key = os.getenv('GOOGLE_API_KEY', '')
|
||||
if not api_key:
|
||||
raise ValueError('GOOGLE_API_KEY is not set')
|
||||
|
||||
|
||||
async def run_agent(task: str, browser: Browser | None = None, max_steps: int = 38):
|
||||
browser = browser or Browser()
|
||||
llm = ChatGoogleGenerativeAI(model='gemini-2.5-pro-preview-03-25', api_key=SecretStr(api_key))
|
||||
agent = Agent(task=task, llm=llm, browser=browser)
|
||||
result = await agent.run(max_steps=max_steps)
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue