mirror of
https://github.com/browser-use/browser-use
synced 2026-05-06 17:52:15 +02:00
Simple example
This commit is contained in:
@@ -10,39 +10,21 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
try:
|
||||
from lmnr import Instruments, Laminar
|
||||
|
||||
Laminar.initialize(project_api_key=os.getenv('LMNR_PROJECT_API_KEY'), disabled_instruments={Instruments.BROWSER_USE})
|
||||
except Exception:
|
||||
print('Error initializing Laminar')
|
||||
pass
|
||||
|
||||
from browser_use import Agent
|
||||
|
||||
# Initialize the model
|
||||
llm = ChatOpenAI(
|
||||
model='o4-mini',
|
||||
temperature=0.2,
|
||||
model='gpt-4.1-mini',
|
||||
)
|
||||
|
||||
# Optimized task with more specific instructions
|
||||
task = """
|
||||
Navigate to the Qatar Airways homepage and search for flights from Doha to Paris departing in the upcoming week; then list the available fare classes and prices.
|
||||
Only use https://www.qatarairways.com/ to achieve the task. Don't go to any other site. The task is achievable with just navigation from this site."""
|
||||
|
||||
task = ' call done directly and repeat the word "New" 100 times'
|
||||
# Performance optimizations
|
||||
agent = Agent(
|
||||
task=task,
|
||||
llm=llm,
|
||||
)
|
||||
task = 'Find the founders of browser-use'
|
||||
agent = Agent(task=task, llm=llm)
|
||||
|
||||
|
||||
async def main():
|
||||
history = await agent.run(max_steps=10)
|
||||
# token usage
|
||||
print(history.usage)
|
||||
await agent.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user