From 610dd8b4ba2771bb7f1d38b101be7fb2cb425fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Sat, 2 Sep 2023 19:25:06 +0800 Subject: [PATCH] feat: +skill config --- metagpt/utils/s3.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/metagpt/utils/s3.py b/metagpt/utils/s3.py index d13030292..531142737 100644 --- a/metagpt/utils/s3.py +++ b/metagpt/utils/s3.py @@ -131,9 +131,11 @@ class S3: async def cache(self, data: str, format: str = "") -> str: """Save data to remote S3 and return url""" object_name = str(uuid.uuid4()).replace("-", "") - pathname = WORKSPACE_ROOT / "s3_tmp" / object_name + path = WORKSPACE_ROOT / "s3_tmp" + path.mkdir(exist_ok=True) + pathname = path / object_name try: - async with aiofiles.open(pathname, mode="w") as file: + async with aiofiles.open(str(pathname), mode="w") as file: if format == BASE64_FORMAT: data = base64.b64decode(data) await file.write(data) @@ -142,7 +144,7 @@ class S3: object_pathname = CONFIG.S3.get("path") or "system" object_pathname += f"/{object_name}" object_pathname = os.path.normpath(object_pathname) - await self.upload_file(bucket=bucket, local_path=pathname, object_name=object_pathname) + await self.upload_file(bucket=bucket, local_path=str(pathname), object_name=object_pathname) return await self.get_object_url(bucket=bucket, object_name=object_pathname) except Exception as e: logger.exception(f"{e}, stack:{traceback.format_exc()}")