fix(agent/workspace): Fix GCS workspace binary file upload

This commit is contained in:
Reinier van der Leer
2024-01-16 14:20:54 +01:00
parent 97023b9a3c
commit 797c5bbc13
2 changed files with 9 additions and 5 deletions

View File

@@ -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):

View File

@@ -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)