From a17f752705f7cd2262dc595f78aa7d9140477221 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Fri, 8 Dec 2023 12:36:14 +0100 Subject: [PATCH] fix(agent): Fix artifact download method & response - Update the return type of the `AgentProtocolServer.get_artifact` method to `StreamingResponse`. - Fix the Content-Disposition header in the response to include quotes around the filename. --- autogpts/autogpt/autogpt/app/agent_protocol_server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.py index 3bd3ce68..99eb598e 100644 --- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py +++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py @@ -357,9 +357,9 @@ class AgentProtocolServer: ) return artifact - async def get_artifact(self, task_id: str, artifact_id: str) -> Artifact: + async def get_artifact(self, task_id: str, artifact_id: str) -> StreamingResponse: """ - Get an artifact by ID. + Download a task artifact by ID. """ try: artifact = await self.db.get_artifact(artifact_id) @@ -378,7 +378,7 @@ class AgentProtocolServer: BytesIO(retrieved_artifact), media_type="application/octet-stream", headers={ - "Content-Disposition": f"attachment; filename={artifact.file_name}" + "Content-Disposition": f'attachment; filename="{artifact.file_name}"' }, )