-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfun_events.py
More file actions
53 lines (45 loc) · 1.43 KB
/
Copy pathfun_events.py
File metadata and controls
53 lines (45 loc) · 1.43 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
from scrapybara.tools import BashTool, ComputerTool, EditTool
from scrapybara.anthropic import Anthropic
from scrapybara.prompts import UBUNTU_SYSTEM_PROMPT
from scrapybara import Scrapybara
from playwright.sync_api import sync_playwright
# Initialize Scrapybara client
client = Scrapybara(api_key="YOUR_SCRAPYBARA_API_KEY")
# Start an Ubuntu instance
instance = client.start_ubuntu(timeout_hours=1)
# Start the browser
cdp_url = instance.browser.start().cdp_url
playwright = sync_playwright().start()
browser = playwright.chromium.connect_over_cdp(cdp_url)
def print_step(step):
print(step.text)
# Event Search Prompt
prompt_text = (
"Go to Eventbrite and search for fun local events happening this weekend. "
"Filter events by 'highly rated' and 'outdoor' categories. "
"Select the top three events based on popularity and return: "
"- Event name "
"- Location "
"- Date & time "
"- Ticket price "
"- Booking link."
)
def attempt_event_search():
"""Run the local event search task."""
return client.act(
model=Anthropic(),
tools=[
BashTool(instance),
ComputerTool(instance),
EditTool(instance),
],
system=UBUNTU_SYSTEM_PROMPT,
prompt=prompt_text,
on_step=print_step,
)
try:
response = attempt_event_search()
except Exception as e:
print("Encountered an error:", e)
print("Final response:")
print(response.text)