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

feat(autofix): List directory tool operates more like ls #890

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

jennmueng
Copy link
Member

@jennmueng jennmueng commented Jul 11, 2024

Noticed confusion from the LLM agents with the list directory tool. Improved it to list subdirectories and files like how ls works as the LLM agents should be much more familiar with the use.

This also fixes the bug where an empty string returning the entire git tree.

@jennmueng jennmueng requested a review from a team July 11, 2024 18:35
@jennmueng jennmueng marked this pull request as ready for review July 11, 2024 18:35
repo_client = self.context.get_repo_client(repo_name=repo_name)

all_paths = repo_client.get_index_file_set(repo_client.get_default_branch_head_sha())

paths = [p for p in all_paths if p.startswith(path)]
# Normalize the path
Copy link
Member

@roaga roaga Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we set the path to the empty string if it doesn't have any trailing/leading slashes?

(sorry looks like I highlighted the snippets incorrectly in my review)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.strip("/") should return the path without any trailing/leading slashes, so normalized_path will only be an empty string if path only contains the / character, such as "/"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I was thinking about cases such as "x/y/z" where there are no leading/trailing slashes, but it's still a valid path. But I guess that case wouldn't occur.

src/seer/automation/autofix/tools.py Outdated Show resolved Hide resolved

return paths_str
# Remove duplicates and sort
unique_children = sorted(set(direct_children))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of casting direct_children above to a set, why not just initialize direct_children through set comprehension instead of list comprehension?

src/seer/automation/autofix/tools.py Outdated Show resolved Hide resolved
@jennmueng jennmueng requested a review from roaga July 12, 2024 09:19
Copy link
Member

@roaga roaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM

repo_client = self.context.get_repo_client(repo_name=repo_name)

all_paths = repo_client.get_index_file_set(repo_client.get_default_branch_head_sha())

paths = [p for p in all_paths if p.startswith(path)]
# Normalize the path
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I was thinking about cases such as "x/y/z" where there are no leading/trailing slashes, but it's still a valid path. But I guess that case wouldn't occur.

@jennmueng jennmueng merged commit 2962835 into main Jul 12, 2024
10 checks passed
@jennmueng jennmueng deleted the jenn/autofix/ls-like-list-tool branch July 12, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants