-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
89 lines (69 loc) · 3.24 KB
/
main.py
File metadata and controls
89 lines (69 loc) · 3.24 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import asyncio
from browser_use import Agent, Browser, ChatBrowserUse
SITES = [
("https://lu.ma/dublin", "luma"),
("https://www.meetup.com/find/?location=ie--Dublin", "meetup"),
("https://www.eventbrite.ie/d/ireland--dublin/events/", "eventbrite"),
]
async def search_events(topic: str) -> str:
"""Search for events across multiple sites based on the given topic."""
browsers = [
Browser(
user_data_dir=f'./temp-profile-{i}',
headless=True,
)
for i in range(len(SITES))
]
agents = [
Agent(
task=f"""
The topic at hand is: {topic}
It is possible that the topic may be a sentence for instance "Find me xyz of abc" - You must be able to identify intent and use a proper
pattern for searching.
Goal: Is to find events (max 3 per instance/website you are accessing) - We are looking for the name of the event,
the organisers, the address if applicable, the date and time range if applicable and also the URL of the said event
RULESET: You may only click to focus further information on an event if you need to get its URL dont do it for all events you see,
choose the top 3 most relevant ones to the topic at hand.
1. Go to {url}
NOTE: If the instance website is luma, you do not need to use the search feature, you may just scroll down - for the other
instance websites you might need to search up.
2. Locate the top 3 events that are relevant to the topic - sometimes the information may not be shown yet or may require to be clicked on to further check it.
3. Once collected the websites return in this format:
Return in results ONLY markdown format syntax, they cannot be inlined and must follow separated line for each point.
use #, for hierarchy etc. - Ensure you use MARKDOWN syntax.
Format must be this, and ONLY THIS. Do not return anything else for instance: Incorrect format - "I could only find two results.." etc,
Return this EXACT format.
# Event 1 : [Title]
**Organiser** : [Organiser]
**Date** : [Date]
**Location** : [Location]
*URL:* [URL]
If one of the [] such as organiser isnt available, just put N/A
Do not use seperator lines at ALL
If you cant find a 3rd event, just dont include it at all in the MD output.
Name of event:
Organiser:
Date:
Location:
URL:
""",
browser=browsers[i],
llm=ChatBrowserUse(),
)
for i, (url, name) in enumerate(SITES)
]
results = await asyncio.gather(
*[agent.run() for agent in agents], return_exceptions=True
)
# Build markdown output
output = []
for (url, name), r in zip(SITES, results):
if not isinstance(r, Exception):
text = str(r.final_result()).replace('\\n', '\n')
output.append(f"# {name.upper()}\n\n{text}\n\n---\n")
return '\n'.join(output)
if __name__ == "__main__":
# CLI usage
topic = "tech events"
result = asyncio.run(search_events(topic))
print(result)