Create fetch_file_url.py
Browse files- tools/fetch_file_url.py +18 -0
tools/fetch_file_url.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any, Optional
|
2 |
+
from smolagents.tools import Tool
|
3 |
+
from gradio_client import Client
|
4 |
+
|
5 |
+
class FetchFileURLTool(Tool):
|
6 |
+
name = "fetch_file_url"
|
7 |
+
description = "Get the correct URL at which a task's file is located for download."
|
8 |
+
inputs = {'lookup_link': {'type': 'any', 'description': 'The link at which to get the URL of the file. It has the pattern https://agents-course-unit4-scoring.hf.space/files/{{ task_id }}'}}
|
9 |
+
output_type = "any"
|
10 |
+
|
11 |
+
def forward(self, lookup_link: Any) -> Any:
|
12 |
+
print('*$%: Performing fetching of file URL at '+lookup_link)
|
13 |
+
requests.get(lookup_link)
|
14 |
+
|
15 |
+
return result['markdown_content']
|
16 |
+
|
17 |
+
def __init__(self, *args, **kwargs):
|
18 |
+
self.is_initialized = False
|