-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
60 lines (48 loc) · 2.63 KB
/
examples.py
File metadata and controls
60 lines (48 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# examples.py
# A collection of example tasks you can copy-paste into main.py
# Run any of these by replacing the TASK in main.py
import asyncio
from agent import run_task
# ── Example 1: Simple login ────────────────────────────────────────────────
example_login = """
Go to https://the-internet.herokuapp.com/login
Log in with username 'tomsmith' and password 'SuperSecretPassword!'
Tell me if the login was successful.
"""
# ── Example 2: Google search ───────────────────────────────────────────────
example_search = """
Go to https://www.google.com
Search for 'Python beginner tutorial'
Tell me the titles of the first 3 results.
"""
# ── Example 3: Read page content ──────────────────────────────────────────
example_scrape = """
Go to https://news.ycombinator.com
Tell me the titles of the top 5 posts on the front page.
"""
# ── Example 4: Fill a form (required field detection) ─────────────────────
# The AI will automatically detect which fields are required
example_form = """
Go to https://the-internet.herokuapp.com/contact
Fill in the contact form with:
- First name: John
- Last name: Doe
- Email: john@example.com
- Message: Hello, this is a test message.
Submit the form and tell me if it worked.
"""
# ── Example 5: Multi-step task ─────────────────────────────────────────────
example_multistep = """
Go to https://books.toscrape.com
Find the cheapest book on the front page.
Tell me the book title and its price.
"""
# ──────────────────────────────────────────────────────────────────────────────
# To run an example, just call asyncio.run(run_task(...)) like below.
# Uncomment whichever example you want to try.
# ──────────────────────────────────────────────────────────────────────────────
if __name__ == "__main__":
# Change this to any of the examples above
task_to_run = example_login
result = asyncio.run(run_task(task=task_to_run, headless=False))
print(f"\n Result:\n{result}")