Sborole commited on
Commit
e0aa535
·
verified ·
1 Parent(s): 91ed61f

Create ReadTextTool.py

Browse files
Files changed (1) hide show
  1. tools/ReadTextTool.py +11 -0
tools/ReadTextTool.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents.tools import Tool
2
+
3
+ class ReadTextTool(Tool):
4
+ name = "read_text"
5
+ description = "Reads a text file and returns the text content."
6
+ inputs = {"file_path": {"type": "string"}}
7
+ output_type = "string"
8
+
9
+ def forward(self, file_path: str) -> str:
10
+ with open(file_path, "r", encoding="utf-8") as f:
11
+ return f.read()