Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

change to stream respsonse (#5285)

Swifty12f3a321b71c
diff --git a/autogpts/forge/forge/sdk/agent.py b/autogpts/forge/forge/sdk/agent.py
index 9537865a61..59ba2c98e1 100644
--- a/autogpts/forge/forge/sdk/agent.py
+++ b/autogpts/forge/forge/sdk/agent.py
@@ -2,6 +2,8 @@ import asyncio
import os
import pathlib
from uuid import uuid4
+from fastapi.responses import StreamingResponse
+from io import BytesIO
from fastapi import APIRouter, FastAPI, UploadFile
from fastapi.middleware.cors import CORSMiddleware
@@ -196,17 +198,11 @@ class Agent:
artifact = await self.db.get_artifact(artifact_id)
file_path = os.path.join(artifact.relative_path, artifact.file_name)
retrieved_artifact = self.workspace.read(task_id=task_id, path=file_path)
- path = artifact.file_name
- with open(path, "wb") as f:
- f.write(retrieved_artifact)
except NotFoundError as e:
raise
except FileNotFoundError as e:
raise
except Exception as e:
raise
- return FileResponse(
- # Note: mimetype is guessed in the FileResponse constructor
- path=path,
- filename=artifact.file_name,
- )
+
+ return StreamingResponse(BytesIO(retrieved_artifact), media_type='application/octet-stream', headers={'Content-Disposition': f'attachment; filename={artifact.file_name}'})
diff --git a/autogpts/forge/forge/sdk/forge_log.py b/autogpts/forge/forge/sdk/forge_log.py
index f27f9df2c3..ea607a2880 100644
--- a/autogpts/forge/forge/sdk/forge_log.py
+++ b/autogpts/forge/forge/sdk/forge_log.py
@@ -179,17 +179,17 @@ logging_config: dict = dict(
"h": {
"class": "logging.StreamHandler",
"formatter": "console",
- "level": logging.DEBUG,
+ "level": logging.INFO,
},
},
root={
"handlers": ["h"],
- "level": logging.DEBUG,
+ "level": logging.INFO,
},
loggers={
"autogpt": {
"handlers": ["h"],
- "level": logging.DEBUG,
+ "level": logging.INFO,
"propagate": False,
},
},