File size: 523 Bytes
db4810d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import os
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI
from pydantic import SecretStr
from browser_use import Agent
load_dotenv()
api_key = os.getenv('GEMINI_API_KEY', '')
if not api_key:
raise ValueError('GEMINI_API_KEY is not set')
async def run_agent(task: str, max_steps: int = 38):
llm = ChatGoogleGenerativeAI(model='gemini-2.0-flash-exp', api_key=SecretStr(api_key))
agent = Agent(task=task, llm=llm)
result = await agent.run(max_steps=max_steps)
return result
|