feat: +unit test

fixbug: PYTHONPATH

fixbug: unit test
This commit is contained in:
莘权 马 2023-12-27 11:24:22 +08:00
parent 641c71bf18
commit 0adabfe53f
33 changed files with 1561 additions and 297 deletions

View file

@ -36,7 +36,8 @@ class PrepareDocuments(Action):
if not path:
name = CONFIG.project_name or FileRepository.new_filename()
path = Path(CONFIG.workspace_path) / name
else:
path = Path(CONFIG.project_path)
if path.exists() and not CONFIG.inc:
shutil.rmtree(path)
CONFIG.git_repo = GitRepository(local_path=path, auto_init=True)

View file

@ -26,6 +26,7 @@ from metagpt.actions.write_prd_an import (
WP_IS_RELATIVE_NODE,
WP_ISSUE_TYPE_NODE,
WRITE_PRD_NODE,
WRITE_PRD_NODE_NO_NAME,
)
from metagpt.config import CONFIG
from metagpt.const import (
@ -123,7 +124,8 @@ class WritePRD(Action):
# logger.info(rsp)
project_name = CONFIG.project_name if CONFIG.project_name else ""
context = CONTEXT_TEMPLATE.format(requirements=requirements, project_name=project_name)
node = await WRITE_PRD_NODE.fill(context=context, llm=self.llm) # schema=schema
write_prd_node = WRITE_PRD_NODE if not project_name else WRITE_PRD_NODE_NO_NAME
node = await write_prd_node.fill(context=context, llm=self.llm) # schema=schema
await self._rename_workspace(node)
return node

View file

@ -34,7 +34,7 @@ ORIGINAL_REQUIREMENTS = ActionNode(
PROJECT_NAME = ActionNode(
key="Project Name",
expected_type=str,
instruction="Name the project using snake case style, like 'game_2048' or 'simple_crm'.",
instruction="According to the content of \"Original Requirements,\" name the project using snake case style , like 'game_2048' or 'simple_crm.",
example="game_2048",
)
@ -141,7 +141,6 @@ NODES = [
LANGUAGE,
PROGRAMMING_LANGUAGE,
ORIGINAL_REQUIREMENTS,
PROJECT_NAME,
PRODUCT_GOALS,
USER_STORIES,
COMPETITIVE_ANALYSIS,
@ -152,7 +151,8 @@ NODES = [
ANYTHING_UNCLEAR,
]
WRITE_PRD_NODE = ActionNode.from_children("WritePRD", NODES)
WRITE_PRD_NODE = ActionNode.from_children("WritePRD", NODES + [PROJECT_NAME])
WRITE_PRD_NODE_NO_NAME = ActionNode.from_children("WritePRD", NODES)
WP_ISSUE_TYPE_NODE = ActionNode.from_children("WP_ISSUE_TYPE", [ISSUE_TYPE, REASON])
WP_IS_RELATIVE_NODE = ActionNode.from_children("WP_IS_RELATIVE", [IS_RELATIVE, REASON])