universal-mcp-applications 0.1.13__py3-none-any.whl → 0.1.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of universal-mcp-applications might be problematic. Click here for more details.
- universal_mcp/applications/aws_s3/app.py +71 -71
- universal_mcp/applications/calendly/app.py +199 -199
- universal_mcp/applications/canva/app.py +189 -189
- universal_mcp/applications/domain_checker/app.py +31 -24
- universal_mcp/applications/e2b/app.py +6 -7
- universal_mcp/applications/elevenlabs/app.py +24 -20
- universal_mcp/applications/exa/app.py +25 -20
- universal_mcp/applications/falai/app.py +44 -41
- universal_mcp/applications/file_system/app.py +20 -12
- universal_mcp/applications/firecrawl/app.py +46 -47
- universal_mcp/applications/fireflies/app.py +79 -79
- universal_mcp/applications/fpl/app.py +83 -74
- universal_mcp/applications/github/README.md +0 -1028
- universal_mcp/applications/github/app.py +55 -50227
- universal_mcp/applications/google_calendar/app.py +63 -65
- universal_mcp/applications/google_docs/app.py +78 -78
- universal_mcp/applications/google_drive/app.py +361 -440
- universal_mcp/applications/google_gemini/app.py +34 -17
- universal_mcp/applications/google_mail/app.py +117 -117
- universal_mcp/applications/google_searchconsole/app.py +41 -47
- universal_mcp/applications/google_sheet/app.py +157 -164
- universal_mcp/applications/http_tools/app.py +16 -16
- universal_mcp/applications/linkedin/app.py +26 -31
- universal_mcp/applications/ms_teams/app.py +190 -190
- universal_mcp/applications/openai/app.py +55 -56
- universal_mcp/applications/outlook/app.py +71 -71
- universal_mcp/applications/perplexity/app.py +17 -17
- universal_mcp/applications/reddit/app.py +225 -4053
- universal_mcp/applications/replicate/app.py +40 -42
- universal_mcp/applications/resend/app.py +157 -154
- universal_mcp/applications/scraper/app.py +24 -24
- universal_mcp/applications/serpapi/app.py +18 -20
- universal_mcp/applications/sharepoint/app.py +46 -36
- universal_mcp/applications/slack/app.py +66 -66
- universal_mcp/applications/tavily/app.py +7 -7
- universal_mcp/applications/twitter/api_segments/compliance_api.py +17 -20
- universal_mcp/applications/twitter/api_segments/dm_conversations_api.py +35 -40
- universal_mcp/applications/twitter/api_segments/dm_events_api.py +18 -21
- universal_mcp/applications/twitter/api_segments/likes_api.py +19 -22
- universal_mcp/applications/twitter/api_segments/lists_api.py +59 -68
- universal_mcp/applications/twitter/api_segments/spaces_api.py +36 -42
- universal_mcp/applications/twitter/api_segments/trends_api.py +7 -8
- universal_mcp/applications/twitter/api_segments/tweets_api.py +159 -185
- universal_mcp/applications/twitter/api_segments/usage_api.py +5 -6
- universal_mcp/applications/twitter/api_segments/users_api.py +230 -264
- universal_mcp/applications/unipile/app.py +99 -105
- universal_mcp/applications/whatsapp/app.py +86 -82
- universal_mcp/applications/whatsapp_business/app.py +147 -147
- universal_mcp/applications/youtube/app.py +290 -290
- universal_mcp/applications/zenquotes/app.py +6 -6
- {universal_mcp_applications-0.1.13.dist-info → universal_mcp_applications-0.1.15.dist-info}/METADATA +2 -2
- {universal_mcp_applications-0.1.13.dist-info → universal_mcp_applications-0.1.15.dist-info}/RECORD +54 -54
- {universal_mcp_applications-0.1.13.dist-info → universal_mcp_applications-0.1.15.dist-info}/WHEEL +0 -0
- {universal_mcp_applications-0.1.13.dist-info → universal_mcp_applications-0.1.15.dist-info}/licenses/LICENSE +0 -0
|
@@ -10,7 +10,7 @@ class OutlookApp(APIApplication):
|
|
|
10
10
|
super().__init__(name="outlook", integration=integration, **kwargs)
|
|
11
11
|
self.base_url = "https://graph.microsoft.com/v1.0"
|
|
12
12
|
|
|
13
|
-
def
|
|
13
|
+
def reply_to_message(
|
|
14
14
|
self,
|
|
15
15
|
message_id: str,
|
|
16
16
|
user_id: str | None = None,
|
|
@@ -18,30 +18,30 @@ class OutlookApp(APIApplication):
|
|
|
18
18
|
message: dict[str, Any] | None = None,
|
|
19
19
|
) -> Any:
|
|
20
20
|
"""
|
|
21
|
-
Replies to a specific message
|
|
22
|
-
|
|
21
|
+
Replies to a specific email message identified by its ID. The reply can contain a simple comment or a full message object with attachments. If no user ID is provided, it defaults to the current user, distinguishing it from `user_send_mail` which sends a new email.
|
|
22
|
+
|
|
23
23
|
Args:
|
|
24
24
|
user_id (string, optional): user-id. If not provided, will automatically get the current user's ID.
|
|
25
25
|
message_id (string): message-id
|
|
26
26
|
comment (string): A comment to include in the reply. Example: 'Thank you for your email. Here is my reply.'.
|
|
27
27
|
message (object): A message object to specify additional properties for the reply, such as attachments. Example: {'subject': 'RE: Project Update', 'body': {'contentType': 'Text', 'content': 'Thank you for the update. Looking forward to the next steps.'}, 'toRecipients': [{'emailAddress': {'address': 'alice@contoso.com'}}], 'attachments': [{'@odata.type': '#microsoft.graph.fileAttachment', 'name': 'agenda.pdf', 'contentType': 'application/pdf', 'contentBytes': 'SGVsbG8gV29ybGQh'}]}.
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
Returns:
|
|
30
30
|
Any: Success
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
Raises:
|
|
33
33
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
Tags:
|
|
36
36
|
users.message, important
|
|
37
37
|
"""
|
|
38
38
|
# If user_id is not provided, get it automatically
|
|
39
39
|
if user_id is None:
|
|
40
|
-
user_info = self.
|
|
40
|
+
user_info = self.get_current_user_profile()
|
|
41
41
|
user_id = user_info.get("userPrincipalName")
|
|
42
42
|
if not user_id:
|
|
43
43
|
raise ValueError(
|
|
44
|
-
"Could not retrieve user ID from
|
|
44
|
+
"Could not retrieve user ID from get_current_user_profile response."
|
|
45
45
|
)
|
|
46
46
|
if message_id is None:
|
|
47
47
|
raise ValueError("Missing required parameter 'message-id'.")
|
|
@@ -63,36 +63,36 @@ class OutlookApp(APIApplication):
|
|
|
63
63
|
)
|
|
64
64
|
return self._handle_response(response)
|
|
65
65
|
|
|
66
|
-
def
|
|
66
|
+
def send_mail(
|
|
67
67
|
self,
|
|
68
68
|
message: dict[str, Any],
|
|
69
69
|
user_id: str | None = None,
|
|
70
70
|
saveToSentItems: bool | None = None,
|
|
71
71
|
) -> Any:
|
|
72
72
|
"""
|
|
73
|
-
Sends
|
|
74
|
-
|
|
73
|
+
Sends a new email on behalf of a user, using a provided dictionary for content like recipients and subject. Unlike `users_message_reply`, which replies to an existing message, this function is used to compose and send an entirely new email from scratch.
|
|
74
|
+
|
|
75
75
|
Args:
|
|
76
76
|
user_id (string, optional): user-id. If not provided, will automatically get the current user's ID.
|
|
77
77
|
message (object): message Example: {'subject': 'Meet for lunch?', 'body': {'contentType': 'Text', 'content': 'The new cafeteria is open.'}, 'toRecipients': [{'emailAddress': {'address': 'frannis@contoso.com'}}], 'ccRecipients': [{'emailAddress': {'address': 'danas@contoso.com'}}], 'bccRecipients': [{'emailAddress': {'address': 'bccuser@contoso.com'}}], 'attachments': [{'@odata.type': '#microsoft.graph.fileAttachment', 'name': 'attachment.txt', 'contentType': 'text/plain', 'contentBytes': 'SGVsbG8gV29ybGQh'}]}.
|
|
78
78
|
saveToSentItems (boolean): saveToSentItems Example: 'False'.
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
Returns:
|
|
81
81
|
Any: Success
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
Raises:
|
|
84
84
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
Tags:
|
|
87
87
|
users.user.Actions, important
|
|
88
88
|
"""
|
|
89
89
|
# If user_id is not provided, get it automatically
|
|
90
90
|
if user_id is None:
|
|
91
|
-
user_info = self.
|
|
91
|
+
user_info = self.get_current_user_profile()
|
|
92
92
|
user_id = user_info.get("userPrincipalName")
|
|
93
93
|
if not user_id:
|
|
94
94
|
raise ValueError(
|
|
95
|
-
"Could not retrieve user ID from
|
|
95
|
+
"Could not retrieve user ID from get_current_user_profile response."
|
|
96
96
|
)
|
|
97
97
|
request_body_data = None
|
|
98
98
|
request_body_data = {
|
|
@@ -112,7 +112,7 @@ class OutlookApp(APIApplication):
|
|
|
112
112
|
)
|
|
113
113
|
return self._handle_response(response)
|
|
114
114
|
|
|
115
|
-
def
|
|
115
|
+
def get_mail_folder(
|
|
116
116
|
self,
|
|
117
117
|
mailFolder_id: str,
|
|
118
118
|
user_id: str | None = None,
|
|
@@ -121,31 +121,31 @@ class OutlookApp(APIApplication):
|
|
|
121
121
|
expand: list[str] | None = None,
|
|
122
122
|
) -> Any:
|
|
123
123
|
"""
|
|
124
|
-
Retrieves a specific mail folder for a
|
|
125
|
-
|
|
124
|
+
Retrieves a specific mail folder by its ID for a given user. Allows customization of the response by optionally including hidden folders, selecting specific properties to return, or expanding related entities. It specifically targets folder metadata, not the messages within.
|
|
125
|
+
|
|
126
126
|
Args:
|
|
127
127
|
user_id (string, optional): user-id. If not provided, will automatically get the current user's ID.
|
|
128
128
|
mailFolder_id (string): mailFolder-id
|
|
129
129
|
includeHiddenFolders (string): Include Hidden Folders
|
|
130
130
|
select (array): Select properties to be returned
|
|
131
131
|
expand (array): Expand related entities
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
Returns:
|
|
134
134
|
Any: Retrieved navigation property
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
Raises:
|
|
137
137
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
Tags:
|
|
140
140
|
users.mailFolder, important
|
|
141
141
|
"""
|
|
142
142
|
# If user_id is not provided, get it automatically
|
|
143
143
|
if user_id is None:
|
|
144
|
-
user_info = self.
|
|
144
|
+
user_info = self.get_current_user_profile()
|
|
145
145
|
user_id = user_info.get("userPrincipalName")
|
|
146
146
|
if not user_id:
|
|
147
147
|
raise ValueError(
|
|
148
|
-
"Could not retrieve user ID from
|
|
148
|
+
"Could not retrieve user ID from get_current_user_profile response."
|
|
149
149
|
)
|
|
150
150
|
if mailFolder_id is None:
|
|
151
151
|
raise ValueError("Missing required parameter 'mailFolder-id'.")
|
|
@@ -162,7 +162,7 @@ class OutlookApp(APIApplication):
|
|
|
162
162
|
response = self._get(url, params=query_params)
|
|
163
163
|
return self._handle_response(response)
|
|
164
164
|
|
|
165
|
-
def
|
|
165
|
+
def list_user_messages(
|
|
166
166
|
self,
|
|
167
167
|
user_id: str | None = None,
|
|
168
168
|
select: list[str] = ["bodyPreview"],
|
|
@@ -176,8 +176,8 @@ class OutlookApp(APIApplication):
|
|
|
176
176
|
expand: list[str] | None = None,
|
|
177
177
|
) -> dict[str, Any]:
|
|
178
178
|
"""
|
|
179
|
-
Retrieves a list of messages
|
|
180
|
-
|
|
179
|
+
Retrieves a list of messages from a user's mailbox. This function supports powerful querying using optional parameters for filtering, searching, sorting, and pagination, unlike `user_get_message`, which fetches a single email by its ID.
|
|
180
|
+
|
|
181
181
|
Args:
|
|
182
182
|
user_id (string, optional): user-id. If not provided, will automatically get the current user's ID.
|
|
183
183
|
select (list): Select properties to be returned. Defaults to ['bodyPreview'].
|
|
@@ -196,23 +196,23 @@ class OutlookApp(APIApplication):
|
|
|
196
196
|
count (boolean): Include count of items
|
|
197
197
|
orderby (array): Order items by property values
|
|
198
198
|
expand (array): Expand related entities
|
|
199
|
-
|
|
199
|
+
|
|
200
200
|
Returns:
|
|
201
201
|
dict[str, Any]: Retrieved collection
|
|
202
|
-
|
|
202
|
+
|
|
203
203
|
Raises:
|
|
204
204
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
205
|
-
|
|
205
|
+
|
|
206
206
|
Tags:
|
|
207
207
|
users.message, important
|
|
208
208
|
"""
|
|
209
209
|
# If user_id is not provided, get it automatically
|
|
210
210
|
if user_id is None:
|
|
211
|
-
user_info = self.
|
|
211
|
+
user_info = self.get_current_user_profile()
|
|
212
212
|
user_id = user_info.get("userPrincipalName")
|
|
213
213
|
if not user_id:
|
|
214
214
|
raise ValueError(
|
|
215
|
-
"Could not retrieve user ID from
|
|
215
|
+
"Could not retrieve user ID from get_current_user_profile response."
|
|
216
216
|
)
|
|
217
217
|
|
|
218
218
|
url = f"{self.base_url}/users/{user_id}/messages"
|
|
@@ -241,7 +241,7 @@ class OutlookApp(APIApplication):
|
|
|
241
241
|
response = self._get(url, params=query_params)
|
|
242
242
|
return self._handle_response(response)
|
|
243
243
|
|
|
244
|
-
def
|
|
244
|
+
def get_user_message(
|
|
245
245
|
self,
|
|
246
246
|
message_id: str,
|
|
247
247
|
user_id: str | None = None,
|
|
@@ -250,31 +250,31 @@ class OutlookApp(APIApplication):
|
|
|
250
250
|
expand: list[str] | None = None,
|
|
251
251
|
) -> Any:
|
|
252
252
|
"""
|
|
253
|
-
Retrieves a specific message for a user,
|
|
254
|
-
|
|
253
|
+
Retrieves a specific message by its ID for a user, with options to select fields or expand related data. This function fetches a single item, in contrast to `user_list_message` which retrieves a collection of messages.
|
|
254
|
+
|
|
255
255
|
Args:
|
|
256
256
|
user_id (string, optional): user-id. If not provided, will automatically get the current user's ID.
|
|
257
257
|
message_id (string): message-id
|
|
258
258
|
includeHiddenMessages (string): Include Hidden Messages
|
|
259
259
|
select (array): Select properties to be returned
|
|
260
260
|
expand (array): Expand related entities
|
|
261
|
-
|
|
261
|
+
|
|
262
262
|
Returns:
|
|
263
263
|
Any: Retrieved navigation property
|
|
264
|
-
|
|
264
|
+
|
|
265
265
|
Raises:
|
|
266
266
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
267
|
-
|
|
267
|
+
|
|
268
268
|
Tags:
|
|
269
269
|
users.message, important
|
|
270
270
|
"""
|
|
271
271
|
# If user_id is not provided, get it automatically
|
|
272
272
|
if user_id is None:
|
|
273
|
-
user_info = self.
|
|
273
|
+
user_info = self.get_current_user_profile()
|
|
274
274
|
user_id = user_info.get("userPrincipalName")
|
|
275
275
|
if not user_id:
|
|
276
276
|
raise ValueError(
|
|
277
|
-
"Could not retrieve user ID from
|
|
277
|
+
"Could not retrieve user ID from get_current_user_profile response."
|
|
278
278
|
)
|
|
279
279
|
if message_id is None:
|
|
280
280
|
raise ValueError("Missing required parameter 'message-id'.")
|
|
@@ -293,28 +293,28 @@ class OutlookApp(APIApplication):
|
|
|
293
293
|
|
|
294
294
|
def user_delete_message(self, message_id: str, user_id: str | None = None) -> Any:
|
|
295
295
|
"""
|
|
296
|
-
Deletes a specific message for a
|
|
297
|
-
|
|
296
|
+
Deletes a specific Outlook message for a user, identified by its unique `message_id`. If `user_id` is not provided, it automatically targets the currently authenticated user's mailbox. It makes a DELETE request to the corresponding Microsoft Graph API endpoint to permanently remove the message.
|
|
297
|
+
|
|
298
298
|
Args:
|
|
299
299
|
user_id (string, optional): user-id. If not provided, will automatically get the current user's ID.
|
|
300
300
|
message_id (string): message-id
|
|
301
|
-
|
|
301
|
+
|
|
302
302
|
Returns:
|
|
303
303
|
Any: Success
|
|
304
|
-
|
|
304
|
+
|
|
305
305
|
Raises:
|
|
306
306
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
307
|
-
|
|
307
|
+
|
|
308
308
|
Tags:
|
|
309
309
|
users.message, important
|
|
310
310
|
"""
|
|
311
311
|
# If user_id is not provided, get it automatically
|
|
312
312
|
if user_id is None:
|
|
313
|
-
user_info = self.
|
|
313
|
+
user_info = self.get_current_user_profile()
|
|
314
314
|
user_id = user_info.get("userPrincipalName")
|
|
315
315
|
if not user_id:
|
|
316
316
|
raise ValueError(
|
|
317
|
-
"Could not retrieve user ID from
|
|
317
|
+
"Could not retrieve user ID from get_current_user_profile response."
|
|
318
318
|
)
|
|
319
319
|
if message_id is None:
|
|
320
320
|
raise ValueError("Missing required parameter 'message-id'.")
|
|
@@ -323,7 +323,7 @@ class OutlookApp(APIApplication):
|
|
|
323
323
|
response = self._delete(url, params=query_params)
|
|
324
324
|
return self._handle_response(response)
|
|
325
325
|
|
|
326
|
-
def
|
|
326
|
+
def list_message_attachments(
|
|
327
327
|
self,
|
|
328
328
|
message_id: str,
|
|
329
329
|
user_id: str | None = None,
|
|
@@ -337,8 +337,8 @@ class OutlookApp(APIApplication):
|
|
|
337
337
|
expand: list[str] | None = None,
|
|
338
338
|
) -> dict[str, Any]:
|
|
339
339
|
"""
|
|
340
|
-
Retrieves attachments
|
|
341
|
-
|
|
340
|
+
Retrieves attachments for a specific email message, identified by its ID. Supports advanced querying for filtering, sorting, and pagination, allowing users to select specific fields to return in the result set.
|
|
341
|
+
|
|
342
342
|
Args:
|
|
343
343
|
user_id (string, optional): user-id. If not provided, will automatically get the current user's ID.
|
|
344
344
|
message_id (string): message-id
|
|
@@ -350,23 +350,23 @@ class OutlookApp(APIApplication):
|
|
|
350
350
|
orderby (array): Order items by property values
|
|
351
351
|
select (array): Select properties to be returned
|
|
352
352
|
expand (array): Expand related entities
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
Returns:
|
|
355
355
|
dict[str, Any]: Retrieved collection
|
|
356
|
-
|
|
356
|
+
|
|
357
357
|
Raises:
|
|
358
358
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
359
|
-
|
|
359
|
+
|
|
360
360
|
Tags:
|
|
361
361
|
users.message, important
|
|
362
362
|
"""
|
|
363
363
|
# If user_id is not provided, get it automatically
|
|
364
364
|
if user_id is None:
|
|
365
|
-
user_info = self.
|
|
365
|
+
user_info = self.get_current_user_profile()
|
|
366
366
|
user_id = user_info.get("userPrincipalName")
|
|
367
367
|
if not user_id:
|
|
368
368
|
raise ValueError(
|
|
369
|
-
"Could not retrieve user ID from
|
|
369
|
+
"Could not retrieve user ID from get_current_user_profile response."
|
|
370
370
|
)
|
|
371
371
|
if message_id is None:
|
|
372
372
|
raise ValueError("Missing required parameter 'message-id'.")
|
|
@@ -388,19 +388,19 @@ class OutlookApp(APIApplication):
|
|
|
388
388
|
response = self._get(url, params=query_params)
|
|
389
389
|
return self._handle_response(response)
|
|
390
390
|
|
|
391
|
-
def
|
|
391
|
+
def get_current_user_profile(
|
|
392
392
|
self,
|
|
393
393
|
) -> dict[str, Any]:
|
|
394
394
|
"""
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
395
|
+
Fetches the `userPrincipalName` for the currently authenticated user from the `/me` endpoint. It is a helper function used internally by other methods to automatically obtain the user's ID for API calls when one is not explicitly provided.
|
|
396
|
+
|
|
397
|
+
|
|
398
398
|
Returns:
|
|
399
399
|
dict[str, Any]: Current user information
|
|
400
|
-
|
|
400
|
+
|
|
401
401
|
Raises:
|
|
402
402
|
HTTPStatusError: Raised when the API request fails with detailed error information including status code and response body.
|
|
403
|
-
|
|
403
|
+
|
|
404
404
|
Tags:
|
|
405
405
|
me, important
|
|
406
406
|
"""
|
|
@@ -411,9 +411,9 @@ class OutlookApp(APIApplication):
|
|
|
411
411
|
response = self._get(url, params=query_params)
|
|
412
412
|
return self._handle_response(response)
|
|
413
413
|
|
|
414
|
-
def
|
|
414
|
+
def get_next_page(self, url: str) -> dict[str, Any]:
|
|
415
415
|
"""
|
|
416
|
-
|
|
416
|
+
Executes a GET request using a full URL, typically a pagination link (`@odata.nextLink`) from a previous API response. It validates the URL, extracts the relative path and query parameters, and fetches the corresponding data, simplifying navigation through paginated API results.
|
|
417
417
|
"""
|
|
418
418
|
if not url:
|
|
419
419
|
raise ValueError("Missing required parameter 'url'.")
|
|
@@ -430,13 +430,13 @@ class OutlookApp(APIApplication):
|
|
|
430
430
|
|
|
431
431
|
def list_tools(self):
|
|
432
432
|
return [
|
|
433
|
-
self.
|
|
434
|
-
self.
|
|
435
|
-
self.
|
|
436
|
-
self.
|
|
437
|
-
self.
|
|
433
|
+
self.reply_to_message,
|
|
434
|
+
self.send_mail,
|
|
435
|
+
self.get_mail_folder,
|
|
436
|
+
self.list_user_messages,
|
|
437
|
+
self.get_user_message,
|
|
438
438
|
self.user_delete_message,
|
|
439
|
-
self.
|
|
440
|
-
self.
|
|
441
|
-
self.
|
|
439
|
+
self.list_message_attachments,
|
|
440
|
+
self.get_current_user_profile,
|
|
441
|
+
self.get_next_page,
|
|
442
442
|
]
|
|
@@ -9,7 +9,7 @@ class PerplexityApp(APIApplication):
|
|
|
9
9
|
super().__init__(name="perplexity", integration=integration)
|
|
10
10
|
self.base_url = "https://api.perplexity.ai"
|
|
11
11
|
|
|
12
|
-
def
|
|
12
|
+
def answer_with_search(
|
|
13
13
|
self,
|
|
14
14
|
query: str,
|
|
15
15
|
model: Literal[
|
|
@@ -19,28 +19,28 @@ class PerplexityApp(APIApplication):
|
|
|
19
19
|
"sonar-reasoning",
|
|
20
20
|
"sonar-reasoning-pro",
|
|
21
21
|
"sonar-deep-research",
|
|
22
|
-
] = "sonar",
|
|
22
|
+
] = "sonar-pro",
|
|
23
23
|
temperature: float = 1,
|
|
24
|
-
system_prompt: str = "
|
|
24
|
+
system_prompt: str = "You are a helpful AI assistant that answers questions using real-time information from the web.",
|
|
25
25
|
) -> dict[str, Any] | str:
|
|
26
26
|
"""
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
Queries the Perplexity Chat Completions API for a web-search-grounded answer. It sends the user's prompt and model parameters to the `/chat/completions` endpoint, then parses the response to return the synthesized content and a list of supporting source citations, ideal for real-time information retrieval.
|
|
28
|
+
|
|
29
29
|
Args:
|
|
30
|
-
query: The
|
|
31
|
-
model: The model to use
|
|
32
|
-
temperature: Controls randomness in the model's output. Higher values make output more random, lower values more deterministic. Defaults to 1
|
|
33
|
-
system_prompt:
|
|
34
|
-
|
|
30
|
+
query: The search query or question to ask. For example: "What are the latest developments in AI regulation?"
|
|
31
|
+
model: The Perplexity model to use.
|
|
32
|
+
temperature: Controls randomness in the model's output. Higher values make the output more random, lower values make it more deterministic. Defaults to 1.
|
|
33
|
+
system_prompt: The initial system message to guide the model's behavior.
|
|
34
|
+
|
|
35
35
|
Returns:
|
|
36
|
-
A dictionary containing the generated
|
|
37
|
-
|
|
36
|
+
A dictionary containing the generated 'content' (str) and a list of 'citations' (list) from the web search.
|
|
37
|
+
|
|
38
38
|
Raises:
|
|
39
|
-
AuthenticationError: Raised when API authentication fails due to missing or invalid credentials
|
|
40
|
-
HTTPError: Raised when the API request fails or returns an error status
|
|
41
|
-
|
|
39
|
+
AuthenticationError: Raised when API authentication fails due to missing or invalid credentials.
|
|
40
|
+
HTTPError: Raised when the API request fails or returns an error status.
|
|
41
|
+
|
|
42
42
|
Tags:
|
|
43
|
-
|
|
43
|
+
search, web, research, citations, current events, important
|
|
44
44
|
"""
|
|
45
45
|
endpoint = f"{self.base_url}/chat/completions"
|
|
46
46
|
messages = []
|
|
@@ -61,5 +61,5 @@ class PerplexityApp(APIApplication):
|
|
|
61
61
|
|
|
62
62
|
def list_tools(self):
|
|
63
63
|
return [
|
|
64
|
-
self.
|
|
64
|
+
self.answer_with_search,
|
|
65
65
|
]
|