File size: 1,334 Bytes
8b2fc7e
 
 
 
 
8cf77a3
8b2fc7e
 
 
 
 
 
 
 
 
 
 
21611df
8b2fc7e
21611df
8b2fc7e
 
2ea8556
8b2fc7e
 
 
 
 
 
21611df
8b2fc7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

__all__ = ['ToolCreator']


class ToolCreator():
    dependencies = []

    inputSchema = {
        "name": "ToolCreator",
        "description": "Creates a tool for the given function",
        "parameters": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "The name of the tool to create",
                },
                "tool_code": {
                    "type": "string",
                    "description": "The code of the tool to create",
                },
            },
            "required": ["name", "tool_code"],
        }
    }

    def run(self, **kwargs):
        print("Running Tool Creator")
        name = kwargs.get("name")
        content = kwargs.get("tool_code")
        print(f"Tool Name: {name}")
        print(f"Tool Content: {content}")
        # Create the tool file
        tool_file_path = f"tools/{name}.py"
        with open(tool_file_path, "w") as tool_file:
            tool_file.write(content)
        print(f"Tool file created at {tool_file_path}")
        return {
            "status": "success",
            "message": "Tool created successfully",
            "output": {
                "tool_file_path": tool_file_path,
                "tool_name": name,
            }
        }