Update product_requirement_pool to product_requirement_pools

This commit is contained in:
mannaandpoem 2024-01-13 08:51:35 +08:00
parent b7adb1dc7d
commit d077605720
3 changed files with 25 additions and 15 deletions

View file

@ -110,7 +110,7 @@ CODE_GUIDELINE_CONTEXT = """
{user_requirement}
## Product Requirement Pool
{product_requirement_pool}
{product_requirement_pools}
## Design
{design}

View file

@ -159,15 +159,21 @@ class WriteCodeReview(Action):
docs_file_repo = CONFIG.git_repo.new_file_repository(relative_path=DOCS_FILE_REPO)
requirement_doc = await docs_file_repo.get(filename=REQUIREMENT_FILENAME)
user_requirement = requirement_doc.content if requirement_doc else ""
prd_file_repo = CONFIG.git_repo.new_file_repository(PRDS_FILE_REPO)
prd = await prd_file_repo.get_all()
prd_json = json.loads(prd[0].content)
product_requirement_pool = prd_json.get("Requirement Pool", prd_json.get("Refined Requirement Pool"))
prd = await CONFIG.git_repo.new_file_repository(PRDS_FILE_REPO).get_all()
contents = []
for doc in prd:
prd_json = json.loads(doc.content)
product_requirement_pool = prd_json.get(
"Requirement Pool", prd_json.get("Refined Requirement Pool")
)
contents.append(str(product_requirement_pool))
product_requirement_pools = "\n".join(contents)
context = "\n".join(
[
"## User New Requirements\n" + str(user_requirement) + "\n",
"## Product Requirement Pool\n" + str(product_requirement_pool) + "\n",
"## Product Requirement Pool\n" + product_requirement_pools + "\n",
"## Guidelines and Incremental Change\n" + guideline + "\n",
"## System Design\n" + str(self.context.design_doc) + "\n",
"## Tasks\n" + task_content + "\n",

View file

@ -347,22 +347,26 @@ class Engineer(Role):
logger.info("Writing code guideline..")
user_requirement = str(self.rc.memory.get_by_role("Human")[0])
prd_file_repo = CONFIG.git_repo.new_file_repository(PRDS_FILE_REPO)
design_file_repo = CONFIG.git_repo.new_file_repository(SYSTEM_DESIGN_FILE_REPO)
task_file_repo = CONFIG.git_repo.new_file_repository(TASK_FILE_REPO)
contents = []
prd = await CONFIG.git_repo.new_file_repository(PRDS_FILE_REPO).get_all()
for doc in prd:
prd_json = json.loads(doc.content)
product_requirement_pool = prd_json.get("Requirement Pool", prd_json.get("Refined Requirement Pool"))
contents.append(str(product_requirement_pool))
prd = await prd_file_repo.get_all()
prd_json = json.loads(prd[0].content)
product_requirement_pool = prd_json.get("Requirement Pool", prd_json.get("Refined Requirement Pool"))
design = await design_file_repo.get_all()
product_requirement_pools = "\n".join(contents)
design = await CONFIG.git_repo.new_file_repository(SYSTEM_DESIGN_FILE_REPO).get_all()
design = "\n".join([doc.content for doc in design])
tasks = await task_file_repo.get_all()
tasks = await CONFIG.git_repo.new_file_repository(TASK_FILE_REPO).get_all()
tasks = "\n".join([doc.content for doc in tasks])
old_codes = await self.get_old_codes()
context = CODE_GUIDELINE_CONTEXT.format(
user_requirement=user_requirement,
product_requirement_pool=str(product_requirement_pool),
product_requirement_pools=product_requirement_pools,
tasks=tasks,
design=design,
code=old_codes,