File size: 1,154 Bytes
21611df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

__all__ = ['ReadFile']


class ReadFile():
    dependencies = []

    inputSchema = {
        "name": "ReadFile",
        "description": "Reads a file and returns its content",
        "parameters": {
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "The path to the file to read",
                },
            },
            "required": ["file_path"],
        }
    }

    def run(self, **kwargs):
        print("Running Read File tool")
        file_path = kwargs.get("file_path")
        print(f"File Path: {file_path}")
        try:
            with open(file_path, "r", encoding="utf8") as f:
                content = f.read()
            return {
                "status": "success",
                "message": "File read successfully",
                "error": None,
                "output": content
            }
        except Exception as e:
            return {
                "status": "error",
                "message": "Failed to read file",
                "error": str(e),
                "output": None
            }