mirror of
https://github.com/browser-use/browser-use.git
synced 2025-02-18 01:18:20 +03:00
Update gpt-4o.py
This commit is contained in:
@@ -1,36 +1,29 @@
|
||||
import asyncio
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from langchain_openai import ChatOpenAI
|
||||
|
||||
from browser_use import Agent, Controller
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
async def run_agent(task: str):
|
||||
llm = ChatOpenAI(
|
||||
model='gpt-4o',
|
||||
temperature=0.0,
|
||||
)
|
||||
agent = Agent(
|
||||
task=task,
|
||||
llm=llm,
|
||||
include_attributes=[
|
||||
'title',
|
||||
'type',
|
||||
'name',
|
||||
'role',
|
||||
'tabindex',
|
||||
'aria-label',
|
||||
'placeholder',
|
||||
'value',
|
||||
'alt',
|
||||
'aria-expanded',
|
||||
'href',
|
||||
],
|
||||
)
|
||||
|
||||
history = await agent.run()
|
||||
final_response = history.final_result()
|
||||
return final_response, history.history
|
||||
async def run_agent(task: str, max_steps: int = 38):
|
||||
llm = ChatOpenAI(
|
||||
model='gpt-4o',
|
||||
temperature=0.0,
|
||||
)
|
||||
agent = Agent(
|
||||
task=task,
|
||||
llm=llm,
|
||||
include_attributes=[
|
||||
'title',
|
||||
'type',
|
||||
'name',
|
||||
'role',
|
||||
'tabindex',
|
||||
'aria-label',
|
||||
'placeholder',
|
||||
'value',
|
||||
'alt',
|
||||
'aria-expanded',
|
||||
'href',
|
||||
],
|
||||
)
|
||||
result = await agent.run(max_steps=max_steps)
|
||||
return result, result.history
|
||||
|
||||
Reference in New Issue
Block a user