Skip to content

Commit 56741a5

Browse files
authored
Merge branch 'main' into adubatl/model_fetching_PoC
2 parents f7abfe3 + 9e383c7 commit 56741a5

File tree

10 files changed

+686
-19
lines changed

10 files changed

+686
-19
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
from agentmail import AgentMail
2+
from typing import Optional, List
3+
4+
5+
client = AgentMail()
6+
7+
8+
def list_inboxes(limit: Optional[int] = None, last_key: Optional[str] = None):
9+
"""
10+
List inboxes.
11+
12+
Args:
13+
limit: The maximum number of inboxes to return.
14+
last_key: The last key returned from the previous page.
15+
16+
Returns:
17+
A list of inboxes.
18+
"""
19+
return client.inboxes.list(limit=limit, last_key=last_key)
20+
21+
22+
def get_inbox(inbox_id: str):
23+
"""
24+
Get an inbox by ID.
25+
26+
Args:
27+
inbox_id: The ID of the inbox to get.
28+
29+
Returns:
30+
An inbox.
31+
"""
32+
return client.inboxes.get(inbox_id)
33+
34+
35+
def create_inbox(
36+
username: Optional[str] = None,
37+
domain: Optional[str] = None,
38+
display_name: Optional[str] = None,
39+
):
40+
"""
41+
Create an inbox.
42+
43+
Args:
44+
username: The username of the inbox.
45+
domain: The domain of the inbox.
46+
display_name: The display name of the inbox.
47+
48+
Returns:
49+
An inbox.
50+
"""
51+
return client.inboxes.create(
52+
username=username, domain=domain, display_name=display_name
53+
)
54+
55+
56+
def list_threads(
57+
inbox_id: str, limit: Optional[int] = None, last_key: Optional[str] = None
58+
):
59+
"""
60+
List threads in an inbox.
61+
62+
Args:
63+
inbox_id: The ID of the inbox to list threads for.
64+
limit: The maximum number of threads to return.
65+
last_key: The last key returned from the previous page.
66+
67+
Returns:
68+
A list of threads.
69+
"""
70+
return client.threads.list(inbox_id=inbox_id, limit=limit, last_key=last_key)
71+
72+
73+
def get_thread(inbox_id: str, thread_id: str):
74+
"""
75+
Get a thread by ID.
76+
77+
Args:
78+
inbox_id: The ID of the inbox to get the thread for.
79+
thread_id: The ID of the thread to get.
80+
81+
Returns:
82+
A thread.
83+
"""
84+
return client.threads.get(inbox_id=inbox_id, thread_id=thread_id)
85+
86+
87+
def list_messages(
88+
inbox_id: str, limit: Optional[int] = None, last_key: Optional[str] = None
89+
):
90+
"""
91+
List messages in an inbox.
92+
93+
Args:
94+
inbox_id: The ID of the inbox to list messages for.
95+
limit: The maximum number of messages to return.
96+
last_key: The last key returned from the previous page.
97+
98+
Returns:
99+
A list of messages.
100+
"""
101+
return client.messages.list(inbox_id=inbox_id, limit=limit, last_key=last_key)
102+
103+
104+
def get_message(inbox_id: str, message_id: str):
105+
"""
106+
Get a message by ID.
107+
108+
Args:
109+
inbox_id: The ID of the inbox to get the message for.
110+
message_id: The ID of the message to get.
111+
112+
Returns:
113+
A message.
114+
"""
115+
return client.messages.get(inbox_id=inbox_id, message_id=message_id)
116+
117+
118+
def get_attachment(inbox_id: str, message_id: str, attachment_id: str):
119+
"""
120+
Get an attachment by message ID and attachment ID.
121+
122+
Args:
123+
inbox_id: The ID of the inbox to get the attachment for.
124+
message_id: The ID of the message to get the attachment for.
125+
attachment_id: The ID of the attachment to get.
126+
127+
Returns:
128+
An attachment.
129+
"""
130+
return client.messages.get_attachment(
131+
inbox_id=inbox_id, message_id=message_id, attachment_id=attachment_id
132+
)
133+
134+
135+
def send_message(
136+
inbox_id: str,
137+
to: List[str],
138+
cc: Optional[List[str]] = None,
139+
bcc: Optional[List[str]] = None,
140+
subject: Optional[str] = None,
141+
text: Optional[str] = None,
142+
html: Optional[str] = None,
143+
):
144+
"""
145+
Send a message.
146+
147+
Args:
148+
inbox_id: The ID of the inbox to send the message from.
149+
to: The list of recipients.
150+
cc: The list of CC recipients.
151+
bcc: The list of BCC recipients.
152+
subject: The subject of the message.
153+
text: The plain text body of the message.
154+
html: The HTML body of the message.
155+
156+
Returns:
157+
A message.
158+
"""
159+
return client.messages.send(
160+
inbox_id=inbox_id, to=to, cc=cc, bcc=bcc, subject=subject, text=text, html=html
161+
)
162+
163+
164+
def reply_to_message(
165+
inbox_id: str,
166+
message_id: str,
167+
text: Optional[str] = None,
168+
html: Optional[str] = None,
169+
):
170+
"""
171+
Reply to a message.
172+
173+
Args:
174+
inbox_id: The ID of the inbox to reply to the message in.
175+
message_id: The ID of the message to reply to.
176+
text: The plain text body of the reply.
177+
html: The HTML body of the reply.
178+
179+
Returns:
180+
A message.
181+
"""
182+
return client.messages.reply(
183+
inbox_id=inbox_id, message_id=message_id, text=text, html=html
184+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "agentmail",
3+
"category": "email",
4+
"tools": ["list_inboxes", "get_inbox", "create_inbox", "list_threads", "get_thread", "list_messages", "get_message", "get_attachment", "send_message", "reply_to_message"],
5+
"url": "https://agentmail.to",
6+
"cta": "Get your AgentMail API key at https://agentmail.to",
7+
"env": {
8+
"AGENTMAIL_API_KEY": null
9+
},
10+
"dependencies": [
11+
"agentmail>=0.0.19"
12+
]
13+
}

agentstack/_tools/agentql/__init__.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
API_KEY = os.getenv("AGENTQL_API_KEY")
1010

1111

12-
def extract_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:
12+
def extract_data(
13+
url: str,
14+
query: Optional[str],
15+
prompt: Optional[str],
16+
is_stealth_mode_enabled: bool = False,
17+
) -> dict:
1318
"""
1419
url: url of website to scrape
1520
query: described below
1621
prompt: Natural language description of the data you want to scrape
17-
22+
is_stealth_mode_enabled: Enable stealth mode for web scraping (default: False)
1823
1924
AgentQL query to scrape the url.
2025
@@ -45,9 +50,20 @@ def extract_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:
4550
}
4651
```
4752
"""
48-
payload = {"url": url, "query": query, "prompt": prompt}
53+
payload = {
54+
"url": url,
55+
"query": query,
56+
"prompt": prompt,
57+
"metadata": {
58+
"experimental_stealth_mode_enabled": is_stealth_mode_enabled,
59+
},
60+
}
4961

50-
headers = {"X-API-Key": f"{API_KEY}", "Content-Type": "application/json"}
62+
headers = {
63+
"X-API-Key": f"{API_KEY}",
64+
"Content-Type": "application/json",
65+
"X-TF-Request-Origin": "agentstack",
66+
}
5167

5268
try:
5369
response = httpx.post(

0 commit comments

Comments
 (0)