mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
use resources dir
mv test code change logger.info to logger.debug
This commit is contained in:
parent
2dc34fb9b4
commit
ade5f88b81
8 changed files with 12 additions and 107 deletions
|
|
@ -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 files
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 prd
|
||||
|
|
|
|||
|
|
@ -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'):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -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)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue