From 662102d188227259a7702fbbe45da63c11168599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Thu, 11 Jan 2024 10:55:54 +0800 Subject: [PATCH] feat: save + return --- metagpt/utils/file_repository.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metagpt/utils/file_repository.py b/metagpt/utils/file_repository.py index 01b78cd77..1cb347a19 100644 --- a/metagpt/utils/file_repository.py +++ b/metagpt/utils/file_repository.py @@ -45,7 +45,7 @@ class FileRepository: # Initializing self.workdir.mkdir(parents=True, exist_ok=True) - async def save(self, filename: Path | str, content, dependencies: List[str] = None): + async def save(self, filename: Path | str, content, dependencies: List[str] = None) -> Document: """Save content to a file and update its dependencies. :param filename: The filename or path within the repository. @@ -63,6 +63,8 @@ class FileRepository: await dependency_file.update(pathname, set(dependencies)) logger.info(f"update dependency: {str(pathname)}:{dependencies}") + return Document(root_path=str(self._relative_path), filename=filename, content=content) + async def get_dependency(self, filename: Path | str) -> Set[str]: """Get the dependencies of a file.