mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 15:48:29 +00:00
Merge pull request #22 from joaomdmoura/gui/fix-github-search-tool
Fix GithubSearchTool
This commit is contained in:
@@ -36,18 +36,21 @@ class GithubSearchTool(RagTool):
|
||||
def __init__(self, github_repo: Optional[str] = None, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
if github_repo is not None:
|
||||
self.add(github_repo)
|
||||
self.add(repo=github_repo)
|
||||
self.description = f"A tool that can be used to semantic search a query the {github_repo} github repo's content."
|
||||
self.args_schema = FixedGithubSearchToolSchema
|
||||
|
||||
def add(
|
||||
self,
|
||||
*args: Any,
|
||||
repo: str,
|
||||
content_types: List[str] | None = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
content_types = content_types or self.content_types
|
||||
|
||||
kwargs["data_type"] = "github"
|
||||
kwargs["loader"] = GithubLoader(config={"token": self.gh_token})
|
||||
super().add(*args, **kwargs)
|
||||
super().add(f"repo:{repo} type:{','.join(content_types)}", **kwargs)
|
||||
|
||||
def _before_run(
|
||||
self,
|
||||
@@ -55,7 +58,9 @@ class GithubSearchTool(RagTool):
|
||||
**kwargs: Any,
|
||||
) -> Any:
|
||||
if "github_repo" in kwargs:
|
||||
self.add(kwargs["github_repo"])
|
||||
self.add(
|
||||
repo=kwargs["github_repo"], content_types=kwargs.get("content_types")
|
||||
)
|
||||
|
||||
def _run(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user