🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
添加UI基础角色代码,测试流程
stellaHSRb402f5a17ef6
diff --git a/config/config.yaml b/config/config.yamlindex 30168d81e..b0264e908 100644--- a/config/config.yaml+++ b/config/config.yaml@@ -26,8 +26,6 @@ RPM: 10#GOOGLE_API_KEY: "YOUR_API_KEY"## Visit https://programmablesearchengine.google.com/controlpanel/create to get id.#GOOGLE_CSE_ID: "YOUR_CSE_ID"-## Visit https://serper.dev/ to get key.-#SERPER_API_KEY: "YOUR_API_KEY"#### for TTSdiff --git a/metagpt/actions/action.py b/metagpt/actions/action.pyindex a390a8350..948185e45 100644--- a/metagpt/actions/action.py+++ b/metagpt/actions/action.py@@ -13,7 +13,7 @@ from metagpt.actions.action_output import ActionOutputfrom tenacity import retry, stop_after_attempt, wait_fixedfrom pydantic import BaseModelfrom metagpt.utils.common import OutputParser-+from metagpt.logs import loggerclass Action(ABC):def __init__(self, name: str = '', context=None, llm: LLM = None):@@ -46,7 +46,7 @@ class Action(ABC):system_msgs.append(self.prefix)return await self.llm.aask(prompt, system_msgs)- @retry(stop=stop_after_attempt(2), wait=wait_fixed(1))+ @retry(stop=stop_after_attempt(1), wait=wait_fixed(1))async def _aask_v1(self, prompt: str, output_class_name: str,output_data_mapping: dict,system_msgs: Optional[list[str]] = None) -> ActionOutput:@@ -55,8 +55,10 @@ class Action(ABC):system_msgs = []system_msgs.append(self.prefix)content = await self.llm.aask(prompt, system_msgs)+ logger.info(content)output_class = ActionOutput.create_model_class(output_class_name, output_data_mapping)parsed_data = OutputParser.parse_data_with_mapping(content, output_data_mapping)+ logger.info(parsed_data)instruct_content = output_class(**parsed_data)return ActionOutput(content, instruct_content)diff --git a/metagpt/actions/write_prd.py b/metagpt/actions/write_prd.pyindex 449f073c4..aa469bd5d 100644--- a/metagpt/actions/write_prd.py+++ b/metagpt/actions/write_prd.py@@ -59,6 +59,7 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. AND '## <SECTION_NAME>' SHOULD W## Requirement Pool: Provided as Python list[str, str], the parameters are requirement description, priority(P0/P1/P2), respectively, comply with PEP standards; no more than 5 requirements and consider to make its difficulty lower+## UI Design draft: Provide as Plain text. Be simple. Describe the elements and functions, also provide a simple style description and layout description.## Anything UNCLEAR: Provide as Plain text. Make clear here."""FORMAT_EXAMPLE = """@@ -105,6 +106,9 @@ The product should be a ...]```+## UI Design draft+Give a basic function description, and a draft+## Anything UNCLEARThere are no unclear points.---@@ -117,6 +121,7 @@ OUTPUT_MAPPING = {"Competitive Quadrant Chart": (str, ...),"Requirement Analysis": (str, ...),"Requirement Pool": (List[Tuple[str, str]], ...),+ "UI Design draft":(str, ...),"Anything UNCLEAR": (str, ...),}@@ -127,8 +132,7 @@ class WritePRD(Action):async def run(self, requirements, *args, **kwargs) -> ActionOutput:sas = SearchAndSummarize()- # rsp = await sas.run(context=requirements, system_text=SEARCH_AND_SUMMARIZE_SYSTEM_EN_US)- rsp = ""+ rsp = await sas.run(context=requirements, system_text=SEARCH_AND_SUMMARIZE_SYSTEM_EN_US)info = f"### Search Results\n{sas.result}\n\n### Search Summary\n{rsp}"if sas.result:logger.info(sas.result)@@ -136,5 +140,6 @@ class WritePRD(Action):prompt = PROMPT_TEMPLATE.format(requirements=requirements, search_information=info,format_example=FORMAT_EXAMPLE)+ logger.info(prompt)prd = await self._aask_v1(prompt, "prd", OUTPUT_MAPPING)return prddiff --git a/metagpt/roles/role.py b/metagpt/roles/role.pyindex 36269aed2..4ddb84252 100644--- a/metagpt/roles/role.py+++ b/metagpt/roles/role.py@@ -114,6 +114,7 @@ class Role:def _set_state(self, state):"""Update the current state."""self._rc.state = state+ logger.info(self._actions)self._rc.todo = self._actions[self._rc.state]def set_env(self, env: 'Environment'):@@ -170,8 +171,11 @@ class Role:if not self._rc.env:return 0env_msgs = self._rc.env.memory.get()+observed = self._rc.env.memory.get_by_actions(self._rc.watch)+already_observed = self._rc.memory.get()+news: list[Message] = []for i in observed:if i in already_observed: