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.
This commit is contained in:
Reinier van der Leer
2023-12-08 12:36:14 +01:00
parent 05321c9dce
commit a17f752705

View File

@@ -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}"'
},
)