From fa675ea3157a4a4a1b09209f52e4714d7a5e60d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Mon, 27 Nov 2023 19:32:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/actions/project_management.py | 9 ++++----- metagpt/const.py | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/metagpt/actions/project_management.py b/metagpt/actions/project_management.py index 641d21533..d679a730c 100644 --- a/metagpt/actions/project_management.py +++ b/metagpt/actions/project_management.py @@ -15,7 +15,7 @@ from typing import List from metagpt.actions import ActionOutput from metagpt.actions.action import Action from metagpt.config import CONFIG -from metagpt.const import SYSTEM_DESIGN_FILE_REPO, TASK_FILE_REPO, TASK_PDF_FILE_REPO +from metagpt.const import SYSTEM_DESIGN_FILE_REPO, TASK_FILE_REPO, TASK_PDF_FILE_REPO, PACKAGE_REQUIREMENTS_FILENAME from metagpt.logs import logger from metagpt.schema import Document, Documents from metagpt.utils.get_template import get_template @@ -263,16 +263,15 @@ class WriteTasks(Action): m = json.loads(doc.content) packages = set(m.get("Required Python third-party packages", set())) file_repo = CONFIG.git_repo.new_file_repository() - filename = "requirements.txt" - requirement_doc = await file_repo.get(filename) + requirement_doc = await file_repo.get(filename=PACKAGE_REQUIREMENTS_FILENAME) if not requirement_doc: - requirement_doc = Document(filename=filename, root_path=".", content="") + requirement_doc = Document(filename=PACKAGE_REQUIREMENTS_FILENAME, root_path=".", content="") lines = requirement_doc.content.splitlines() for pkg in lines: if pkg == "": continue packages.add(pkg) - await file_repo.save(filename, content="\n".join(packages)) + await file_repo.save(PACKAGE_REQUIREMENTS_FILENAME, content="\n".join(packages)) @staticmethod async def _save_pdf(task_doc): diff --git a/metagpt/const.py b/metagpt/const.py index a8c7356ca..ce06655f1 100644 --- a/metagpt/const.py +++ b/metagpt/const.py @@ -53,6 +53,8 @@ MESSAGE_ROUTE_TO_ALL = "" MESSAGE_ROUTE_TO_NONE = "" REQUIREMENT_FILENAME = "requirement.txt" +PACKAGE_REQUIREMENTS_FILENAME = "requirements.txt" + DOCS_FILE_REPO = "docs" PRDS_FILE_REPO = "docs/prds" SYSTEM_DESIGN_FILE_REPO = "docs/system_design"