-
Notifications
You must be signed in to change notification settings - Fork 2
/
add_tools_to_db.py
49 lines (41 loc) · 1.49 KB
/
add_tools_to_db.py
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
49
from dotenv import load_dotenv
import os
load_dotenv("config.env")
from agents.planner_executor.tool_helpers.all_tools import tools
from db_utils import add_tool
import asyncio
async def main():
# initialise basic tools in db
for key in tools:
tool = tools[key]
function_name = tool["function_name"]
description = tool["description"]
code = tool["code"]
tool_name = tool["tool_name"]
toolbox = tool["toolbox"]
input_metadata = tool["input_metadata"]
output_metadata = tool["output_metadata"]
api_keys = os.environ["DEFOG_API_KEY"].split(",")
# create embedding for the tool name + description
for api_key in api_keys:
err = await add_tool(
api_key=api_key,
tool_name=tool_name,
function_name=function_name,
description=description,
code=code,
input_metadata=input_metadata,
output_metadata=output_metadata,
toolbox=toolbox,
cannot_delete=True,
cannot_disable=True,
)
if err:
if "already exists" in err:
print(f"Tool {function_name} already exists in the database.")
else:
print(f"Error adding tool {tool_name}: {err}")
else:
print(f"Tool {function_name} added to the database.")
# Run the main function
asyncio.run(main())