From a5d283943160e10185aa6bc6353d7c79d1c64aa9 Mon Sep 17 00:00:00 2001 From: Jakub Strnad Date: Fri, 5 Jul 2024 16:30:41 +0200 Subject: [PATCH 1/2] arguments descriptions added to tool description so now the agent knows how to use the tools params --- src/crewai_tools/tools/base_tool.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/crewai_tools/tools/base_tool.py b/src/crewai_tools/tools/base_tool.py index 4e0bd1fd5..dff1e37aa 100644 --- a/src/crewai_tools/tools/base_tool.py +++ b/src/crewai_tools/tools/base_tool.py @@ -86,13 +86,16 @@ class BaseTool(BaseModel, ABC): ) def _generate_description(self): - args = [] - for arg, attribute in self.args_schema.schema()["properties"].items(): - if "type" in attribute: - args.append(f"{arg}: '{attribute['type']}'") + args = [] + args_description = [] + for arg, attribute in self.args_schema.schema()["properties"].items(): + if "type" in attribute: + args.append(f"{arg}: '{attribute['type']}'") + if "description" in attribute: + args_description.append(f"{arg}: '{attribute['description']}'") - description = self.description.replace("\n", " ") - self.description = f"{self.name}({', '.join(args)}) - {description}" + description = self.description.replace("\n", " ") + self.description = f"{self.name}({', '.join(args)}) - {description} {', '.join(args_description)}" class Tool(BaseTool): From cb1dc13a9d214622f8ea8d0c3573b4207c9402bf Mon Sep 17 00:00:00 2001 From: Jakub Date: Fri, 5 Jul 2024 18:42:16 +0200 Subject: [PATCH 2/2] fixed intendation --- src/crewai_tools/tools/base_tool.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/crewai_tools/tools/base_tool.py b/src/crewai_tools/tools/base_tool.py index dff1e37aa..4b60d93d4 100644 --- a/src/crewai_tools/tools/base_tool.py +++ b/src/crewai_tools/tools/base_tool.py @@ -86,16 +86,16 @@ class BaseTool(BaseModel, ABC): ) def _generate_description(self): - args = [] - args_description = [] - for arg, attribute in self.args_schema.schema()["properties"].items(): - if "type" in attribute: - args.append(f"{arg}: '{attribute['type']}'") - if "description" in attribute: - args_description.append(f"{arg}: '{attribute['description']}'") + args = [] + args_description = [] + for arg, attribute in self.args_schema.schema()["properties"].items(): + if "type" in attribute: + args.append(f"{arg}: '{attribute['type']}'") + if "description" in attribute: + args_description.append(f"{arg}: '{attribute['description']}'") - description = self.description.replace("\n", " ") - self.description = f"{self.name}({', '.join(args)}) - {description} {', '.join(args_description)}" + description = self.description.replace("\n", " ") + self.description = f"{self.name}({', '.join(args)}) - {description} {', '.join(args_description)}" class Tool(BaseTool):