Merge pull request #220 from slavakurilyak/add-search-files-command
Add search_files command to the projectpull/297/head
commit
7080881d56
|
@ -6,7 +6,7 @@ import agent_manager as agents
|
|||
import speak
|
||||
from config import Config
|
||||
import ai_functions as ai
|
||||
from file_operations import read_file, write_to_file, append_to_file, delete_file
|
||||
from file_operations import read_file, write_to_file, append_to_file, delete_file, search_files
|
||||
from execute_code import execute_python_file
|
||||
from json_parser import fix_and_parse_json
|
||||
from duckduckgo_search import ddg
|
||||
|
@ -90,6 +90,8 @@ def execute_command(command_name, arguments):
|
|||
return append_to_file(arguments["file"], arguments["text"])
|
||||
elif command_name == "delete_file":
|
||||
return delete_file(arguments["file"])
|
||||
elif command_name == "search_files":
|
||||
return search_files(arguments["directory"])
|
||||
elif command_name == "browse_website":
|
||||
return browse_website(arguments["url"], arguments["question"])
|
||||
# TODO: Change these to take in a file rather than pasted code, if
|
||||
|
|
|
@ -19,11 +19,12 @@ COMMANDS:
|
|||
11. Read file: "read_file", args: "file": "<file>"
|
||||
12. Append to file: "append_to_file", args: "file": "<file>", "text": "<text>"
|
||||
13. Delete file: "delete_file", args: "file": "<file>"
|
||||
14. Evaluate Code: "evaluate_code", args: "code": "<full _code_string>"
|
||||
15. Get Improved Code: "improve_code", args: "suggestions": "<list_of_suggestions>", "code": "<full_code_string>"
|
||||
16. Write Tests: "write_tests", args: "code": "<full_code_string>", "focus": "<list_of_focus_areas>"
|
||||
17. Execute Python File: "execute_python_file", args: "file": "<file>"
|
||||
18. Task Complete (Shutdown): "task_complete", args: "reason": "<reason>"
|
||||
14. Search Files: "search_files", args: "directory": "<directory>"
|
||||
15. Evaluate Code: "evaluate_code", args: "code": "<full _code_string>"
|
||||
16. Get Improved Code: "improve_code", args: "suggestions": "<list_of_suggestions>", "code": "<full_code_string>"
|
||||
17. Write Tests: "write_tests", args: "code": "<full_code_string>", "focus": "<list_of_focus_areas>"
|
||||
18. Execute Python File: "execute_python_file", args: "file": "<file>"
|
||||
19. Task Complete (Shutdown): "task_complete", args: "reason": "<reason>"
|
||||
|
||||
RESOURCES:
|
||||
|
||||
|
|
|
@ -58,3 +58,16 @@ def delete_file(filename):
|
|||
return "File deleted successfully."
|
||||
except Exception as e:
|
||||
return "Error: " + str(e)
|
||||
|
||||
def search_files(directory):
|
||||
found_files = []
|
||||
search_directory = safe_join(working_directory, directory)
|
||||
|
||||
for root, _, files in os.walk(search_directory):
|
||||
for file in files:
|
||||
if file.startswith('.'):
|
||||
continue
|
||||
relative_path = os.path.relpath(os.path.join(root, file), working_directory)
|
||||
found_files.append(relative_path)
|
||||
|
||||
return found_files
|
Loading…
Reference in New Issue