File size: 1,413 Bytes
576227b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a3a158e
fde43e7
a3a158e
 
0487f91
a3a158e
 
576227b
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
import importlib

__all__ = ['ToolDeletor']


class ToolDeletor():
    dependencies = ["os"]

    inputSchema = {
        "name": "ToolDeletor",
        "description": "Deletes a tool for the given function",
        "parameters": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "The name of the tool to create",
                },
                "file_path": {
                    "type": "string",
                    "description": "The path of the tool to create",
                },
            },
            "required": ["name", "file_path"],
        }
    }

    def run(self, **kwargs):
        print("Running Tool Deletor")
        name = kwargs.get("name")
        file_path = kwargs.get("file_path")
        # make sure the file path is in tools/
        if not file_path.startswith("src/tools/user_tools/"):
            return {
                "status": "error",
                "message": "File path must start with src/tools/user_tools/",
                "output": None
            }
        os = importlib.import_module("os")
        os.remove(file_path)
        return {
            "status": "success",
            "message": "Tool deleted successfully",
            "output": {
                "tool_file_path": file_path,
                "tool_name": name,
            }
        }