Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Improve expand_document tool to automatically determine repository name when possible. #2047

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 15 additions & 4 deletions src/seer/automation/autofix/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,19 @@ class FilePath(BaseModel):

@observe(name="Expand Document")
@ai_track(description="Expand Document")
def expand_document(self, file_path: str, repo_name: str):
def expand_document(self, file_path: str, repo_name: str | None = None):
# If repo_name is not provided, try to determine it automatically
if repo_name is None:
repo_names = self._get_repo_names()
if len(repo_names) == 1:
# If there's only one repository, use it automatically
repo_name = repo_names[0]
self.context.event_manager.add_log(f"Automatically using repository: {repo_name}")
else:
# If there are multiple repositories, we need the user to specify which one
repos_list = ", ".join(repo_names)
return f"Repository name not specified. Please specify one of the following repositories: {repos_list}"

file_contents = self.context.get_file_contents(file_path, repo_name=repo_name)

self.context.event_manager.add_log(f"Looking at `{file_path}` in `{repo_name}`...")
Expand Down Expand Up @@ -396,7 +408,6 @@ def google_search(self, question: str, llm_client: LlmClient = injected):
)

def get_tools(self, can_access_repos: bool = True):

tools = [
FunctionTool(
name="google_search",
Expand Down Expand Up @@ -452,10 +463,10 @@ def get_tools(self, can_access_repos: bool = True):
{
"name": "repo_name",
"type": "string",
"description": "Name of the repository containing the file.",
"description": "Name of the repository containing the file. If omitted and there's only one repository, that repository will be used automatically.",
},
],
required=["file_path", "repo_name"],
required=["file_path"],
),
FunctionTool(
name="keyword_search",
Expand Down