AutoGPT
AutoGPT copied to clipboard
Fix list files function to accept more arguments
Background
A lot of times agents come up with arguments against the list_files() function (former search_files) which are not accepted, this makes the agent end up in a loop, not finding anything but an error.
Changes
While a lot of times the args are just a replacement of the original "filename" argument i've also seen extension as an argument, with literally an ".ext" as search query.
I changed the function to accept all, although it might be better to take care of this on the agent side which makes up all the arguments, but in the meantime I couldn't take it anymore :)
Documentation
Mainly in-code comments:
directory (str): The directory to search in extension (str, optional): The file extension to filter by. If provided, all other arguments except 'directory' and 'keywords' will be ignored. Defaults to None. filename (str, optional): A partial file name to filter by. If provided and 'extension' is not, all other arguments except 'directory' will be ignored. Defaults to None. query (str, optional): A query to filter by. If provided and 'extension' and 'filename' are not, all other arguments except 'directory' will be ignored. Defaults to None. filename_query (str, optional): A query to filter file names by. If provided and 'extension', 'filename', and 'query' are not, all other arguments except 'directory' will be ignored. Defaults to None. filename_substring (str, optional): A substring to filter file names by. If provided and 'extension', 'filename', 'query', and 'filename_query' are not, all other arguments except 'directory' will be ignored. Defaults to None. keywords (list[str], optional): A list of keywords to filter by. If provided and 'extension', 'filename', 'query', 'filename_query', and 'filename_substring' are not, 'extension' will be appended to each keyword before filtering. Defaults to None.
Test Plan
Tested for a week with continuously changing file and creating file goals and I haven't seen an error or stall since.
PR Quality Checklist
- [x] My pull request is atomic and focuses on a single change.
- [x] I have thoroughly tested my changes with multiple different prompts.
- [x] I have considered potential risks and mitigations for my changes.
- [x] I have documented my changes clearly and comprehensively.
- [x] I have not snuck in any "extra" small tweaks changes
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
docs | ⬜️ Ignored (Inspect) | Visit Preview | May 25, 2023 11:01am |
This is a mass message from the AutoGPT core team. Our apologies for the ongoing delay in processing PRs. This is because we are re-architecting the AutoGPT core!
For more details (and for infor on joining our Discord), please refer to: https://github.com/Significant-Gravitas/Auto-GPT/wiki/Architecting
indeed, that looks like an excellent little addition that is very useful (keep seeing the exact behavior you described) - I'd suggest to consider this PR as a candidate for being reviewed/integrated regardless of the ongoing re-arch effort
Tested for a week with continuously changing file and creating file goals and I haven't seen an error or stall since.
I think, the point is providing pytest/unit test integration - which admittedly seems to be lacking currently for file_utilities.py anyway ...
Is anything needed for this or has it been solved already from another angle ?
I have been using this function for over 2 weeks now and hadn't had any search query errors since.
would also like to see this reviewed and integrated - if you haven't done so already, you should consider adding the corresponding pytest files to test all aspects of your changes. You can usually use autogpt/gpt itself to come up with the corresponding stubs, so should not take you very long. If in doubt, you can copy/paste relevant unit tests into GPT and adapt them based on your changes.
Codecov Report
Patch coverage: 93.10
% and project coverage change: +0.25
:tada:
Comparison is base (
5168cb5
) 64.91% compared to head (41bb66d
) 65.17%.
:exclamation: Current head 41bb66d differs from pull request most recent head 7e64db5. Consider uploading reports for the commit 7e64db5 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## master #3712 +/- ##
==========================================
+ Coverage 64.91% 65.17% +0.25%
==========================================
Files 75 75
Lines 3543 3569 +26
Branches 520 529 +9
==========================================
+ Hits 2300 2326 +26
Misses 1071 1071
Partials 172 172
Impacted Files | Coverage Δ | |
---|---|---|
autogpt/commands/file_operations.py | 85.78% <93.10%> (+2.16%) |
:arrow_up: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
We committed some changes to this branch, please run
git fetch
git rebase origin/fix-list_files-to-accept-more-arguments
before pushing more changes to the remote.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
We committed some changes to this branch, please run
git fetch
git rebase origin/fix-list_files-to-accept-more-arguments
before pushing more changes to the remote.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
We committed some changes to this branch, please run
git fetch
git rebase origin/fix-list_files-to-accept-more-arguments
before pushing more changes to the remote.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size
We committed some changes to this branch, please run
git fetch
git rebase origin/fix-list_files-to-accept-more-arguments
before pushing more changes to the remote.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
Deployment failed with the following error:
Resource is limited - try again in 31 minutes (more than 100, code: "api-deployments-free-per-day").
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size