Download utilities.py from stc-face/Final_Assignment_Template_3: direct link, hf CLI and curl.
- Browser
- Download file 611 Bytes
-
https://huggingface.co/spaces/stc-face/Final_Assignment_Template_3/resolve/main/utilities.py
- Command line
-
hf download hf://spaces/stc-face/Final_Assignment_Template_3/utilities.py
-
curl -L -o utilities.py https://huggingface.co/spaces/stc-face/Final_Assignment_Template_3/resolve/main/utilities.py
611 Bytes
| import requests | |
| from langchain_core.tools import tool | |
| from typing import IO | |
| from io import BytesIO | |
| def get_file(task_id: str) -> IO: | |
| ''' | |
| Downloads the file associated with the given task_id, if one exists and is mapped. | |
| If the question mentions an attachment, use this function. | |
| Args: | |
| task_id: Id of the question. | |
| Returns: | |
| The file associated with the question as a BytesIO object. | |
| ''' | |
| file_request = requests.get(url=f'https://agents-course-unit4-scoring.hf.space/files/{task_id}') | |
| file_request.raise_for_status() | |
| return BytesIO(file_request.content) |