Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,10 @@ import importlib.util
|
|
6 |
from typing import Any, Dict
|
7 |
import requests
|
8 |
|
|
|
|
|
|
|
|
|
9 |
# This is the only hardcoded Tool endpoint
|
10 |
def register_tool(tool_data):
|
11 |
# Send a POST request to register the tool
|
@@ -17,7 +21,7 @@ def create_tool(tool_name, tool_data):
|
|
17 |
a AI model can wield this toolto create a new 'tool' script in the tools folder
|
18 |
besides the values for the registration payload,
|
19 |
the 'tool_data' should also be a string value 'tfn' which contains the code for the tool function script
|
20 |
-
|
21 |
print("processing create_tool ")
|
22 |
print(tool_name)
|
23 |
print(dir(tool_data))
|
@@ -38,14 +42,12 @@ def create_tool(tool_name, tool_data):
|
|
38 |
print(dir(tool_payload))
|
39 |
|
40 |
# write the new tool script from tfn
|
41 |
-
with open(f'
|
42 |
f.write(tool_data.get("tfn"))
|
43 |
# send the registation request for the tool
|
44 |
return register_tool(tool_payload)
|
45 |
|
46 |
|
47 |
-
# Define the path to the tools folder
|
48 |
-
TOOLS_DIR = './tools'
|
49 |
|
50 |
# Function to dynamically load methods from files in the ./tools folder
|
51 |
def load_methods_from_tools():
|
|
|
6 |
from typing import Any, Dict
|
7 |
import requests
|
8 |
|
9 |
+
# Define the path to the tools folder
|
10 |
+
TOOLS_DIR = './tools'
|
11 |
+
os.makedirs(TOOLS_DIR, exists_ok=True)
|
12 |
+
|
13 |
# This is the only hardcoded Tool endpoint
|
14 |
def register_tool(tool_data):
|
15 |
# Send a POST request to register the tool
|
|
|
21 |
a AI model can wield this toolto create a new 'tool' script in the tools folder
|
22 |
besides the values for the registration payload,
|
23 |
the 'tool_data' should also be a string value 'tfn' which contains the code for the tool function script
|
24 |
+
"""
|
25 |
print("processing create_tool ")
|
26 |
print(tool_name)
|
27 |
print(dir(tool_data))
|
|
|
42 |
print(dir(tool_payload))
|
43 |
|
44 |
# write the new tool script from tfn
|
45 |
+
with open(f'{TOOLS_DIR}/{tool_data.get("name")}.py' 'w') as f:
|
46 |
f.write(tool_data.get("tfn"))
|
47 |
# send the registation request for the tool
|
48 |
return register_tool(tool_payload)
|
49 |
|
50 |
|
|
|
|
|
51 |
|
52 |
# Function to dynamically load methods from files in the ./tools folder
|
53 |
def load_methods_from_tools():
|