Spaces:
Sleeping
Sleeping
File size: 530 Bytes
aa84f48 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from smolagents import Tool
class FileReader(Tool):
name = 'file_reader'
description = "reads saved files"
inputs = {
"file_path": {
"type": "string",
"description": "path to the file"
}
}
output_type = "string"
def forward(self, file_path: str) -> str:
try:
with open(file_path, "r") as file:
content = file.read()
return content
except Exception as e:
return f'Error in reading file: {str(e)}'
|