feat: REST API support for tool creation (#1219)

Co-authored-by: cpacker <packercharles@gmail.com>
This commit is contained in:
Sarah Wooders
2024-04-08 22:11:18 -07:00
committed by GitHub
parent beb5813003
commit 806a982b39
12 changed files with 162 additions and 26 deletions

View File

@@ -348,3 +348,29 @@ def test_presets(client, agent):
# List all presets and make sure the preset is NOT in the list
all_presets = client.list_presets()
assert new_preset.id not in [p.id for p in all_presets], (new_preset, all_presets)
def test_tools(client, agent):
# load a function
file_path = "tests/data/functions/dump_json.py"
module_name = "dump_json"
# list functions
response = client.list_tools()
orig_tools = response.tools
print(orig_tools)
# add the tool
create_tool_response = client.create_tool(name=module_name, file_path=file_path)
print(create_tool_response)
# list functions
response = client.list_tools()
new_tools = response.tools
assert module_name in [tool.name for tool in new_tools]
# assert len(new_tools) == len(orig_tools) + 1
# TODO: add a function to a preset
# TODO: add a function to an agent