Spaces:
Sleeping
Sleeping
Download tools/ReadTextTool.py from umarbalak/agents_course: direct link, hf CLI and curl.
- Browser
- Download file 463 Bytes
-
https://huggingface.co/spaces/umarbalak/agents_course/resolve/main/tools/ReadTextTool.py
- Command line
-
hf download hf://spaces/umarbalak/agents_course/tools/ReadTextTool.py
-
curl -L -o ReadTextTool.py https://huggingface.co/spaces/umarbalak/agents_course/resolve/main/tools/ReadTextTool.py
463 Bytes
| from smolagents.tools import Tool | |
| class ReadTextTool(Tool): | |
| name = "read_text" | |
| description = "Reads a text file and returns the text content." | |
| inputs = { | |
| "file_path": { | |
| "type": "string", | |
| "description": "The full path of the text file to read" | |
| } | |
| } | |
| output_type = "string" | |
| def forward(self, file_path: str) -> str: | |
| with open(file_path, "r", encoding="utf-8") as f: | |
| return f.read() |