From 1568008db61d63eadb4b6f03657b785e3aec00f1 Mon Sep 17 00:00:00 2001 From: Carter Chen Date: Mon, 13 Jan 2025 21:33:40 -0500 Subject: [PATCH 1/2] remove _generate_description on file_read_tool --- .../tools/file_read_tool/file_read_tool.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/crewai_tools/tools/file_read_tool/file_read_tool.py b/src/crewai_tools/tools/file_read_tool/file_read_tool.py index 323a26d51..9106533fa 100644 --- a/src/crewai_tools/tools/file_read_tool/file_read_tool.py +++ b/src/crewai_tools/tools/file_read_tool/file_read_tool.py @@ -49,6 +49,7 @@ class FileReadTool(BaseTool): if file_path is not None: self.file_path = file_path self.description = f"A tool that reads file content. The default file is {file_path}, but you can provide a different 'file_path' parameter to read another file." + self._generate_description() def _run( self, @@ -68,14 +69,3 @@ class FileReadTool(BaseTool): except Exception as e: return f"Error: Failed to read file {file_path}. {str(e)}" - def _generate_description(self) -> None: - """Generate the tool description based on file path. - - This method updates the tool's description to include information about - the default file path while maintaining the ability to specify a different - file at runtime. - - Returns: - None - """ - self.description = f"A tool that can be used to read {self.file_path}'s content." From fe2a5abf8d19b72bedd2c7d0c099976e7abf7051 Mon Sep 17 00:00:00 2001 From: Carter Chen Date: Tue, 14 Jan 2025 21:16:11 -0500 Subject: [PATCH 2/2] restructure init statement to remove duplicate call to _generate_description --- src/crewai_tools/tools/file_read_tool/file_read_tool.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crewai_tools/tools/file_read_tool/file_read_tool.py b/src/crewai_tools/tools/file_read_tool/file_read_tool.py index 9106533fa..22a1204f6 100644 --- a/src/crewai_tools/tools/file_read_tool/file_read_tool.py +++ b/src/crewai_tools/tools/file_read_tool/file_read_tool.py @@ -45,11 +45,11 @@ class FileReadTool(BaseTool): this becomes the default file path for the tool. **kwargs: Additional keyword arguments passed to BaseTool. """ - super().__init__(**kwargs) if file_path is not None: - self.file_path = file_path - self.description = f"A tool that reads file content. The default file is {file_path}, but you can provide a different 'file_path' parameter to read another file." - self._generate_description() + kwargs['description'] = f"A tool that reads file content. The default file is {file_path}, but you can provide a different 'file_path' parameter to read another file." + + super().__init__(**kwargs) + self.file_path = file_path def _run( self,