🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
use resources dir mv test code change logger.info to logger.debug
stellaHSRade5f88b819f
diff --git a/examples/ui_role.py b/examples/ui_role.pyindex 453911a7d..101be9c69 100644--- a/examples/ui_role.py+++ b/examples/ui_role.py@@ -217,7 +217,7 @@ class UIDesign(Action):logger.info("Finish icon design using StableDiffusion API")async def _save(self, css_content, html_content):- save_dir = WORKSPACE_ROOT / "UI" / 'docs/'+ save_dir = WORKSPACE_ROOT / "resources" / 'codes'if not os.path.exists(save_dir):os.makedirs(save_dir, exist_ok=True)# Save CSS and HTML content to filesdiff --git a/metagpt/actions/action.py b/metagpt/actions/action.pyindex 29c10d827..905b044df 100644--- a/metagpt/actions/action.py+++ b/metagpt/actions/action.py@@ -55,10 +55,10 @@ class Action(ABC):system_msgs = []system_msgs.append(self.prefix)content = await self.llm.aask(prompt, system_msgs)- logger.info(content)+ logger.debug(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)+ logger.debug(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 aa469bd5d..957566aab 100644--- a/metagpt/actions/write_prd.py+++ b/metagpt/actions/write_prd.py@@ -132,7 +132,8 @@ 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 = await sas.run(context=requirements, system_text=SEARCH_AND_SUMMARIZE_SYSTEM_EN_US)+ rsp = ""info = f"### Search Results\n{sas.result}\n\n### Search Summary\n{rsp}"if sas.result:logger.info(sas.result)@@ -140,6 +141,6 @@ class WritePRD(Action):prompt = PROMPT_TEMPLATE.format(requirements=requirements, search_information=info,format_example=FORMAT_EXAMPLE)- logger.info(prompt)+ logger.debug(prompt)prd = await self._aask_v1(prompt, "prd", OUTPUT_MAPPING)return prddiff --git a/metagpt/roles/role.py b/metagpt/roles/role.pyindex 4ddb84252..de3bb3369 100644--- a/metagpt/roles/role.py+++ b/metagpt/roles/role.py@@ -114,7 +114,7 @@ class Role:def _set_state(self, state):"""Update the current state."""self._rc.state = state- logger.info(self._actions)+ logger.debug(self._actions)self._rc.todo = self._actions[self._rc.state]def set_env(self, env: 'Environment'):diff --git a/metagpt/tools/sd_engine.py b/metagpt/tools/sd_engine.pyindex 13d51353e..8f7df68fe 100644--- a/metagpt/tools/sd_engine.py+++ b/metagpt/tools/sd_engine.py@@ -79,7 +79,7 @@ class SDEngine:def _save(self, imgs, save_name=""):# fixme:寻址- save_dir = WORKSPACE_ROOT / "SD_Output"+ save_dir = WORKSPACE_ROOT / "resources"/"SD_Output"if not os.path.exists(save_dir):os.makedirs(save_dir, exist_ok=True)batch_decode_base64_to_image(imgs, save_dir, save_name=save_name)diff --git a/tests/metagpt/test_ui_design.py b/tests/metagpt/actions/test_ui_design.pysimilarity index 62%rename from tests/metagpt/test_ui_design.pyrename to tests/metagpt/actions/test_ui_design.pyindex 304241a6c..e01b90477 100644--- a/tests/metagpt/test_ui_design.py+++ b/tests/metagpt/actions/test_ui_design.py@@ -4,9 +4,7 @@#from examples.ui_role import UIDesign-def test_ui_design_parse_css():- ui_design_work = UIDesign(name="UI design action")- llm_resp = '''+llm_resp= '''# UI Design Description```The user interface for the snake game will be designed in a way that is simple, clean, and intuitive. The main elements of the game such as the game grid, snake, food, score, and game over message will be clearly defined and easy to understand. The game grid will be centered on the screen with the score displayed at the top. The game controls will be intuitive and easy to use. The design will be modern and minimalist with a pleasing color scheme.```@@ -102,6 +100,9 @@ body {font-size: 3em;'''+def test_ui_design_parse_css():+ ui_design_work = UIDesign(name="UI design action")+css = '''body {display: flex;@@ -165,101 +166,6 @@ body {def test_ui_design_parse_html():ui_design_work = UIDesign(name="UI design action")- llm_resp = '''- # UI Design Description-```The user interface for the snake game will be designed in a way that is simple, clean, and intuitive. The main elements of the game such as the game grid, snake, food, score, and game over message will be clearly defined and easy to understand. The game grid will be centered on the screen with the score displayed at the top. The game controls will be intuitive and easy to use. The design will be modern and minimalist with a pleasing color scheme.```--## Selected Elements--Game Grid: The game grid will be a rectangular area in the center of the screen where the game will take place. It will be defined by a border and will have a darker background color.--Snake: The snake will be represented by a series of connected blocks that move across the grid. The color of the snake will be different from the background color to make it stand out.--Food: The food will be represented by small objects that are a different color from the snake and the background. The food will be randomly placed on the grid.--Score: The score will be displayed at the top of the screen. The score will increase each time the snake eats a piece of food.--Game Over: When the game is over, a message will be displayed in the center of the screen. The player will be given the option to restart the game.--## HTML Layout-```html-<!DOCTYPE html>-<html lang="en">-<head>- <meta charset="UTF-8">- <meta name="viewport" content="width=device-width, initial-scale=1.0">- <title>Snake Game</title>- <link rel="stylesheet" href="styles.css">-</head>-<body>- <div class="score">Score: 0</div>- <div class="game-grid">- <!-- Snake and food will be dynamically generated here using JavaScript -->- </div>- <div class="game-over">Game Over</div>-</body>-</html>-```--## CSS Styles (styles.css)-```css-body {- display: flex;- flex-direction: column;- justify-content: center;- align-items: center;- height: 100vh;- margin: 0;- background-color: #f0f0f0;-}--.score {- font-size: 2em;- margin-bottom: 1em;-}--.game-grid {- width: 400px;- height: 400px;- display: grid;- grid-template-columns: repeat(20, 1fr);- grid-template-rows: repeat(20, 1fr);- gap: 1px;- background-color: #222;- border: 1px solid #555;-}--.snake-segment {- background-color: #00cc66;-}--.food {- background-color: #cc3300;-}--.control-panel {- display: flex;- justify-content: space-around;- width: 400px;- margin-top: 1em;-}--.control-button {- padding: 1em;- font-size: 1em;- border: none;- background-color: #555;- color: #fff;- cursor: pointer;-}--.game-over {- position: absolute;- top: 50%;- left: 50%;- transform: translate(-50%, -50%);- font-size: 3em;- '''html = '''<!DOCTYPE html>diff --git a/tests/metagpt/test_ui.py b/tests/metagpt/roles/test_ui.pysimilarity index 99%rename from tests/metagpt/test_ui.pyrename to tests/metagpt/roles/test_ui.pyindex a52320676..1e53936a1 100644--- a/tests/metagpt/test_ui.py+++ b/tests/metagpt/roles/test_ui.py@@ -21,5 +21,3 @@ async def test_ui_role(idea: str, investment: float = 3.0, n_round: int = 5):company.invest(investment)company.start_project(idea)await company.run(n_round=n_round)--diff --git a/tests/metagpt/test_sd_tool.py b/tests/metagpt/tools/test_sd_tool.pysimilarity index 100%rename from tests/metagpt/test_sd_tool.pyrename to tests/metagpt/tools/test_sd_tool.py