diff --git a/app/tool/file_saver.py b/app/tool/file_saver.py index d057067..9f4d3cb 100644 --- a/app/tool/file_saver.py +++ b/app/tool/file_saver.py @@ -1,5 +1,8 @@ +import asyncio import os +import aiofiles + from app.tool.base import BaseTool @@ -49,9 +52,10 @@ The tool accepts content and a file path, and saves the content to that location os.makedirs(directory) # Write directly to the file - with open(file_path, mode, encoding="utf-8") as file: - file.write(content) + async with aiofiles.open(file_path, mode, encoding="utf-8") as file: + await file.write(content) return f"Content successfully saved to {file_path}" except Exception as e: return f"Error saving file: {str(e)}" +