mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-02-03 05:14:28 +01:00
change to stream respsonse (#5285)
* change to stream respsonse * Changed default log level to INFO
This commit is contained in:
@@ -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}'})
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user