diff --git a/loopgpt/tools/__init__.py b/loopgpt/tools/__init__.py index ccfe2fe..ddf0c03 100644 --- a/loopgpt/tools/__init__.py +++ b/loopgpt/tools/__init__.py @@ -17,6 +17,8 @@ DeleteFile, CheckIfFileExists, ListFiles, + GetCWD, + MakeDirectory, FileSystemTools, ) from loopgpt.tools.shell import Shell diff --git a/loopgpt/tools/filesystem.py b/loopgpt/tools/filesystem.py index f986812..b4577d0 100644 --- a/loopgpt/tools/filesystem.py +++ b/loopgpt/tools/filesystem.py @@ -126,6 +126,50 @@ def run(self, path, recursive, show_hidden=False, exclude_dirs=False): return {"result": entries_list} +class GetCWD(BaseTool): + @property + def args(self): + return {} + + @property + def resp(self): + return {"path": "Path to the current working directory"} + + @property + def desc(self): + return "Find the current working directory using this command" + + def run(self): + try: + cwd = os.getcwd() + return {"path": cwd} + except Exception as e: + return ( + f"An error occurred while getting the current working directory: {e}." + ) + + +class MakeDirectory(BaseTool): + @property + def args(self): + return {"path": "Path of the directory to be made"} + + @property + def resp(self): + return {"success": "True if the directory was created, False otherwise."} + + @property + def desc(self): + return "Make a new directory at the given path" + + def run(self, path): + try: + os.makedirs(path) + return {"success": True} + except Exception as e: + return f"An error occurred while creating a new directory path: {e}." + + FileSystemTools = [ WriteToFile, ReadFromFile, @@ -133,4 +177,6 @@ def run(self, path, recursive, show_hidden=False, exclude_dirs=False): DeleteFile, CheckIfFileExists, ListFiles, + GetCWD, + MakeDirectory, ]