Spaces:
Runtime error
Runtime error
Download Tools/code_reader.py from J3/Final_Assignment_Template: direct link, hf CLI and curl.
- Browser
- Download file 438 Bytes
-
https://huggingface.co/spaces/J3/Final_Assignment_Template/resolve/main/Tools/code_reader.py
- Command line
-
hf download hf://spaces/J3/Final_Assignment_Template/Tools/code_reader.py
-
curl -L -o code_reader.py https://huggingface.co/spaces/J3/Final_Assignment_Template/resolve/main/Tools/code_reader.py
438 Bytes
| from smolagents import tool | |
| def code_reader(python_file_path:str) -> str: | |
| """ | |
| This tool reads python file and returns the code as a string. | |
| Args: | |
| python_file_path: Path of a local python file that needs to be accessed. | |
| """ | |
| try: | |
| with open(python_file_path) as f: | |
| code = f.read() | |
| return code | |
| except Exception as e: | |
| return f'An unexpected error occurred: {str(e)}' |