Skip to content

Commit

Permalink
fix tool useage
Browse files Browse the repository at this point in the history
  • Loading branch information
FyZyX committed Jun 18, 2023
1 parent 7c5b616 commit 0c624b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="llmfuncs",
version="0.2.1",
version="0.2.2",
url="https://github.com/FyZyX/llmfuncs",
author="Lucas Lofaro",
author_email="[email protected]",
Expand Down
7 changes: 3 additions & 4 deletions src/llmfuncs/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def schema(self):

class ToolCollection:
def __init__(self, tools: typing.List[Tool] = None):
self._tools = {}
self._tools: typing.Dict[str, Tool] = {}
for tool in tools or []:
self.add_tool(tool)

Expand Down Expand Up @@ -128,12 +128,11 @@ def use_tool(self, tool_name: str, json_args: str | typing.Mapping) -> typing.An
if not tool:
raise ValueError(f"No tool found with name: {tool_name}")

func = tool['function']
params_schema = tool['schema']['parameters']
params_schema = tool.schema()['parameters']
is_string = isinstance(json_args, str)
args = validator.parse_json(json_args) if is_string else json_args
validator.validate_args_with_schema(args, params_schema)
return func(**args)
return tool(**args)

def schema(self) -> typing.List[schema.JsonSchema]:
return [tool.schema() for tool in self._tools.values()]

0 comments on commit 0c624b6

Please sign in to comment.