Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/codegen/extensions/langchain/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
class ViewFileTool(BaseTool):
"""Tool for viewing file contents and metadata."""

name: ClassVar[str] = "view_file"

Check failure on line 69 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
description: ClassVar[str] = """View the contents and metadata of a file in the codebase.

Check failure on line 70 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
For large files (>500 lines), content will be paginated. Use start_line and end_line to navigate through the file.
The response will indicate if there are more lines available to view."""
args_schema: ClassVar[type[BaseModel]] = ViewFileInput

Check failure on line 73 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
codebase: Codebase = Field(exclude=True)

def __init__(self, codebase: Codebase) -> None:
Expand Down Expand Up @@ -108,9 +108,9 @@
class ListDirectoryTool(BaseTool):
"""Tool for listing directory contents."""

name: ClassVar[str] = "list_directory"

Check failure on line 111 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
description: ClassVar[str] = "List contents of a directory in the codebase"

Check failure on line 112 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
args_schema: ClassVar[type[BaseModel]] = ListDirectoryInput

Check failure on line 113 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
codebase: Codebase = Field(exclude=True)

def __init__(self, codebase: Codebase) -> None:
Expand Down Expand Up @@ -138,9 +138,9 @@
class RipGrepTool(BaseTool):
"""Tool for searching the codebase via RipGrep."""

name: ClassVar[str] = "search"

Check failure on line 141 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
description: ClassVar[str] = "Search the codebase using `ripgrep` or regex pattern matching"

Check failure on line 142 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
args_schema: ClassVar[type[BaseModel]] = SearchInput

Check failure on line 143 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
codebase: Codebase = Field(exclude=True)

def __init__(self, codebase: Codebase) -> None:
Expand All @@ -162,7 +162,7 @@
class EditFileTool(BaseTool):
"""Tool for editing files."""

name: ClassVar[str] = "edit_file"

Check failure on line 165 in src/codegen/extensions/langchain/tools.py

View workflow job for this annotation

GitHub Actions / mypy

error: Cannot override instance variable (previously declared on base class "BaseTool") with class variable [misc]
description: ClassVar[str] = r"""
Edit a file by replacing its entire content. This tool should only be used for replacing entire file contents.
Input for searching the codebase.
Expand Down Expand Up @@ -518,20 +518,27 @@
"""Input for searching GitHub issues."""

query: str = Field(..., description="Search query string to find issues")
assignee_id: str | None = Field(default=None, description="Optional GitHub username or ID to filter issues by assignee")


class GithubSearchIssuesTool(BaseTool):
"""Tool for searching GitHub issues."""

name: ClassVar[str] = "search_issues"
description: ClassVar[str] = "Search for GitHub issues/PRs using a query string from pygithub, e.g. 'is:pr is:open test_query'"
description: ClassVar[str] = "Search for GitHub issues/PRs using a query string from pygithub, e.g. 'is:pr is:open test_query'. You can also filter by assignee using the assignee_id parameter."
args_schema: ClassVar[type[BaseModel]] = GithubSearchIssuesInput
codebase: Codebase = Field(exclude=True)

def __init__(self, codebase: Codebase) -> None:
super().__init__(codebase=codebase)

def _run(self, query: str) -> str:
def _run(self, query: str, assignee_id: str | None = None) -> str:
# If assignee_id is provided, add it to the query
if assignee_id:
# Check if the query already contains an assignee filter
if "assignee:" not in query:
query = f"{query} assignee:{assignee_id}"

result = search(self.codebase, query)
return result.render()

Expand Down
6 changes: 4 additions & 2 deletions src/codegen/extensions/tools/github/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ def search(
To search for issues specifically, include 'is:issue' in your query.
If neither is specified, both issues and PRs will be included in results.

To filter by assignee, include 'assignee:USERNAME' in your query or use the assignee_id parameter
in the search_issues tool.

Args:
codebase: The codebase to operate on
query: Search query string (e.g. "is:pr label:bug", "is:issue is:open")
state: Filter by state ("open", "closed", or "all")
query: Search query string (e.g. "is:pr label:bug", "is:issue is:open", "assignee:username")
max_results: Maximum number of results to return
"""
try:
Expand Down