mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
preparing new verion and adding new tools
This commit is contained in:
@@ -4,6 +4,7 @@ from .tools import (
|
|||||||
CSVSearchTool,
|
CSVSearchTool,
|
||||||
DirectorySearchTool,
|
DirectorySearchTool,
|
||||||
DOCXSearchTool,
|
DOCXSearchTool,
|
||||||
|
DirectoryReadTool,
|
||||||
FileReadTool,
|
FileReadTool,
|
||||||
GithubSearchTool,
|
GithubSearchTool,
|
||||||
TXTSearchTool,
|
TXTSearchTool,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from .code_docs_search_tool.code_docs_search_tool import CodeDocsSearchTool
|
from .code_docs_search_tool.code_docs_search_tool import CodeDocsSearchTool
|
||||||
from .csv_search_tool.csv_search_tool import CSVSearchTool
|
from .csv_search_tool.csv_search_tool import CSVSearchTool
|
||||||
from .directory_search_tool.directory_search_tool import DirectorySearchTool
|
from .directory_search_tool.directory_search_tool import DirectorySearchTool
|
||||||
|
from .directory_read_tool.directory_read_tool import DirectoryReadTool
|
||||||
from .docx_search_tool.docx_search_tool import DOCXSearchTool
|
from .docx_search_tool.docx_search_tool import DOCXSearchTool
|
||||||
from .file_read_tool.file_read_tool import FileReadTool
|
from .file_read_tool.file_read_tool import FileReadTool
|
||||||
from .github_search_tool.github_search_tool import GithubSearchTool
|
from .github_search_tool.github_search_tool import GithubSearchTool
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import os
|
||||||
|
from typing import Optional, Type, Any
|
||||||
|
from pydantic.v1 import BaseModel, Field
|
||||||
|
from ..base_tool import BaseTool
|
||||||
|
|
||||||
|
class FixedDirectoryReadToolSchema(BaseModel):
|
||||||
|
"""Input for DirectoryReadTool."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class DirectoryReadToolSchema(FixedDirectoryReadToolSchema):
|
||||||
|
"""Input for DirectoryReadTool."""
|
||||||
|
directory: str = Field(..., description="Mandatory directory to list content")
|
||||||
|
|
||||||
|
class DirectoryReadTool(BaseTool):
|
||||||
|
name: str = "List files in directory"
|
||||||
|
description: str = "A tool that can be used to recursively list a directory's content."
|
||||||
|
args_schema: Type[BaseModel] = DirectoryReadToolSchema
|
||||||
|
directory: Optional[str] = None
|
||||||
|
|
||||||
|
def __init__(self, directory: Optional[str] = None, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
if directory is not None:
|
||||||
|
self.directory = directory
|
||||||
|
self.description = f"A tool that can be used to list {directory}'s content."
|
||||||
|
self.args_schema = FixedDirectoryReadToolSchema
|
||||||
|
|
||||||
|
def _run(
|
||||||
|
self,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> Any:
|
||||||
|
directory = kwargs.get('directory', self.directory)
|
||||||
|
return [(os.path.join(root, file).replace(directory, "").lstrip(os.path.sep)) for root, dirs, files in os.walk(directory) for file in files]
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ class FixedFileReadToolSchema(BaseModel):
|
|||||||
|
|
||||||
class FileReadToolSchema(FixedFileReadToolSchema):
|
class FileReadToolSchema(FixedFileReadToolSchema):
|
||||||
"""Input for FileReadTool."""
|
"""Input for FileReadTool."""
|
||||||
file_path: str = Field(..., description="Mandatory file path to read the file")
|
file_path: str = Field(..., description="Mandatory file full path to read the file")
|
||||||
|
|
||||||
class FileReadTool(BaseTool):
|
class FileReadTool(BaseTool):
|
||||||
name: str = "Read a file's content"
|
name: str = "Read a file's content"
|
||||||
|
|||||||
Reference in New Issue
Block a user