AutoGPT: Fix artifact download

This commit is contained in:
Reinier van der Leer
2023-10-17 15:56:56 -07:00
parent 8adfca5fb7
commit 11eeaeb4b9
2 changed files with 3 additions and 3 deletions

View File

@@ -334,7 +334,7 @@ class AgentProtocolServer:
else:
file_path = artifact.relative_path
workspace = get_task_agent_file_workspace(task_id, self.agent_manager)
retrieved_artifact = workspace.read_file(file_path)
retrieved_artifact = workspace.read_file(file_path, binary=True)
except NotFoundError as e:
raise
except FileNotFoundError as e:

View File

@@ -60,9 +60,9 @@ class FileWorkspace:
full_path = self.get_path(path)
return open(full_path, mode)
def read_file(self, path: str | Path):
def read_file(self, path: str | Path, binary: bool = False):
"""Read a file in the workspace."""
with self.open_file(path, "r") as file:
with self.open_file(path, "rb" if binary else "r") as file:
return file.read()
def write_file(self, path: str | Path, content: str | bytes):