AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Merge branch 'master' into file-context
Reinier van der Leer26d9f46da45f
diff --cc autogpt/agents/agent.pyindex ec72d270b3,baf2b8f92a..09e2d77514--- a/autogpt/agents/agent.py+++ b/autogpt/agents/agent.py@@@ -34,16 -40,11 +34,18 @@@ from autogpt.models.context_item imporfrom autogpt.workspace import Workspacefrom .base import BaseAgent+from .utils.context import ContextMixin+from .utils.exceptions import (+ AgentException,+ CommandExecutionError,+ InvalidAgentResponseError,+ UnknownCommandError,+)+ logger = logging.getLogger(__name__)+-class Agent(BaseAgent):+class Agent(BaseAgent, ContextMixin):"""Agent class for interacting with Auto-GPT."""def __init__(diff --cc autogpt/commands/decorators.pyindex c805e01885,cdb5c78a85..59b952da68--- a/autogpt/commands/decorators.py+++ b/autogpt/commands/decorators.py@@@ -3,12 -4,11 +4,13 @@@ from pathlib import Patfrom typing import Callablefrom autogpt.agents.agent import Agent- from autogpt.logs import logger++ logger = logging.getLogger(__name__)-def sanitize_path_arg(arg_name: str):+def sanitize_path_arg(arg_name: str, make_relative: bool = False):+ """Sanitizes the specified path (str | Path) argument, resolving it to a Path"""+def decorator(func: Callable):# Get position of path parameter, in case it is passed as a positional argumenttry:diff --cc autogpt/commands/file_operations_utils.pyindex d68ef90a49,a987ab8ba3..260a2722d0--- a/autogpt/commands/file_operations_utils.py+++ b/autogpt/commands/file_operations_utils.py@@@ -1,6 -1,6 +1,7 @@@import json+ import loggingimport os+from pathlib import Pathimport charset_normalizerimport docx@@@ -145,18 -145,11 +146,18 @@@ def is_file_binary_fn(file_path: Path)return False- def read_textual_file(file_path: Path, logger: logs.Logger) -> str:-def read_textual_file(file_path: str, logger: logging.Logger) -> str:- if not os.path.isfile(file_path):- raise FileNotFoundError(- f"read_file {file_path} failed: no such file or directory"- )++def read_textual_file(file_path: Path, logger: logging.Logger) -> str:+ if not file_path.is_absolute():+ raise ValueError("File path must be absolute")++ if not file_path.is_file():+ if not file_path.exists():+ raise FileNotFoundError(+ f"read_file {file_path} failed: no such file or directory"+ )+ else:+ raise ValueError(f"read_file failed: {file_path} is not a file")+is_binary = is_file_binary_fn(file_path)file_extension = os.path.splitext(file_path)[1].lower()parser = extension_to_parser.get(file_extension)