Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
|
@@ -124,7 +124,7 @@ class VisitWebpageTool(Tool):
|
|
| 124 |
|
| 125 |
class DownloadTaskAttachmentTool(Tool):
|
| 126 |
name = "download_file"
|
| 127 |
-
description = "Downloads the file attached to the task ID and returns the local file path. Supports Excel (.xlsx), image (.png), and audio (.mp3) files."
|
| 128 |
inputs = {'task_id': {'type': 'string', 'description': 'The task id to download attachment from.'}}
|
| 129 |
output_type = "string"
|
| 130 |
|
|
@@ -133,14 +133,14 @@ class DownloadTaskAttachmentTool(Tool):
|
|
| 133 |
self.rate_limiter = rate_limiter
|
| 134 |
self.default_api_url = default_api_url
|
| 135 |
|
| 136 |
-
|
| 137 |
file_url = f"{self.default_api_url}/files/{task_id}"
|
| 138 |
print(f"Downloading file for task ID {task_id} from {file_url}...")
|
| 139 |
try:
|
| 140 |
if self.rate_limiter:
|
| 141 |
while not self.rate_limiter.consume(1):
|
| 142 |
print(f"Rate limit reached for downloading file for task {task_id}. Waiting...")
|
| 143 |
-
|
| 144 |
response = requests.get(file_url, stream=True, timeout=15)
|
| 145 |
response.raise_for_status()
|
| 146 |
|
|
|
|
| 124 |
|
| 125 |
class DownloadTaskAttachmentTool(Tool):
|
| 126 |
name = "download_file"
|
| 127 |
+
description = "Downloads the file attached to the task ID and returns the local file path. Supports Excel (.xlsx), image (.png, .jpg), and audio (.mp3) files."
|
| 128 |
inputs = {'task_id': {'type': 'string', 'description': 'The task id to download attachment from.'}}
|
| 129 |
output_type = "string"
|
| 130 |
|
|
|
|
| 133 |
self.rate_limiter = rate_limiter
|
| 134 |
self.default_api_url = default_api_url
|
| 135 |
|
| 136 |
+
def forward(self, task_id: str) -> str:
|
| 137 |
file_url = f"{self.default_api_url}/files/{task_id}"
|
| 138 |
print(f"Downloading file for task ID {task_id} from {file_url}...")
|
| 139 |
try:
|
| 140 |
if self.rate_limiter:
|
| 141 |
while not self.rate_limiter.consume(1):
|
| 142 |
print(f"Rate limit reached for downloading file for task {task_id}. Waiting...")
|
| 143 |
+
time.sleep(60 / 15) # Assuming 15 RPM
|
| 144 |
response = requests.get(file_url, stream=True, timeout=15)
|
| 145 |
response.raise_for_status()
|
| 146 |
|