diff options
author | Reinier van der Leer <pwuts@agpt.co> | 2024-01-16 14:20:54 +0100 |
---|---|---|
committer | Reinier van der Leer <pwuts@agpt.co> | 2024-01-16 14:20:54 +0100 |
commit | 797c5bbc13e861c19c727c4d35b139e4697310b5 (patch) | |
tree | 0025c17773208139857bed3b4a24301b0fb8ae28 | |
parent | feat(agent/server): Make port configurable, add documentation for Agent Proto... (diff) | |
download | Auto-GPT-797c5bbc13e861c19c727c4d35b139e4697310b5.tar.gz Auto-GPT-797c5bbc13e861c19c727c4d35b139e4697310b5.tar.bz2 Auto-GPT-797c5bbc13e861c19c727c4d35b139e4697310b5.zip |
fix(agent/workspace): Fix GCS workspace binary file upload
-rw-r--r-- | autogpts/autogpt/autogpt/app/agent_protocol_server.py | 1 | ||||
-rw-r--r-- | autogpts/autogpt/autogpt/file_workspace/gcs.py | 13 |
2 files changed, 9 insertions, 5 deletions
diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.py index 29ab004a2..6abd9c8c3 100644 --- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py +++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py @@ -339,7 +339,6 @@ class AgentProtocolServer: """ Create an artifact for the task. """ - data = None file_name = file.filename or str(uuid4()) data = b"" while contents := file.file.read(1024 * 1024): diff --git a/autogpts/autogpt/autogpt/file_workspace/gcs.py b/autogpts/autogpt/autogpt/file_workspace/gcs.py index c6ff3fc97..f1203cd57 100644 --- a/autogpts/autogpt/autogpt/file_workspace/gcs.py +++ b/autogpts/autogpt/autogpt/file_workspace/gcs.py @@ -75,10 +75,15 @@ class GCSFileWorkspace(FileWorkspace): """Write to a file in the workspace.""" blob = self._get_blob(path) - if isinstance(content, str): - blob.upload_from_string(content) - else: - blob.upload_from_file(content) + blob.upload_from_string( + data=content, + content_type=( + "text/plain" + if type(content) is str + # TODO: get MIME type from file extension or binary content + else "application/octet-stream" + ), + ) if self.on_write_file: path = Path(path) |