mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 08:38:30 +00:00
Merge pull request #188 from meerkat-citronella/bugfix/fix-description-on-file_read_tool
Fix description on FileReadTool
This commit is contained in:
@@ -46,10 +46,11 @@ class FileReadTool(BaseTool):
|
|||||||
this becomes the default file path for the tool.
|
this becomes the default file path for the tool.
|
||||||
**kwargs: Additional keyword arguments passed to BaseTool.
|
**kwargs: Additional keyword arguments passed to BaseTool.
|
||||||
"""
|
"""
|
||||||
super().__init__(**kwargs)
|
|
||||||
if file_path is not None:
|
if file_path is not None:
|
||||||
self.file_path = file_path
|
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."
|
||||||
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."
|
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.file_path = file_path
|
||||||
|
|
||||||
def _run(
|
def _run(
|
||||||
self,
|
self,
|
||||||
@@ -67,18 +68,4 @@ class FileReadTool(BaseTool):
|
|||||||
except PermissionError:
|
except PermissionError:
|
||||||
return f"Error: Permission denied when trying to read file: {file_path}"
|
return f"Error: Permission denied when trying to read file: {file_path}"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Error: Failed to read file {file_path}. {str(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."
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user