mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-24 14:15:17 +02:00
优化了用户指定步骤后,任务全交由程序员完成的问题。
This commit is contained in:
parent
81927c2192
commit
08ba3f52f8
8 changed files with 34 additions and 18 deletions
|
|
@ -4,6 +4,8 @@ ANALYZE_REQUIREMENTS = """
|
|||
# Example
|
||||
{examples}
|
||||
|
||||
----------------
|
||||
|
||||
# Requirements
|
||||
{requirements}
|
||||
|
||||
|
|
@ -18,14 +20,6 @@ Follow the instructions and output format. Do not include any additional content
|
|||
|
||||
EXAMPLES = """
|
||||
Example 1
|
||||
Requirements:
|
||||
Create 2048 game using Python. Do not write PRD.
|
||||
Outputs:
|
||||
[User Restrictions] : Do not write PRD.
|
||||
[Language Restrictions] : The response, message and instruction must be in the language specified by English.
|
||||
[Programming Language] : Python
|
||||
|
||||
Example 2
|
||||
Requirements:
|
||||
创建一个贪吃蛇,只需要给出设计文档和代码
|
||||
Outputs:
|
||||
|
|
@ -33,6 +27,14 @@ Outputs:
|
|||
[Language Restrictions] : The response, message and instruction must be in the language specified by Chinese.
|
||||
[Programming Language] : HTML (*.html), CSS (*.css), and JavaScript (*.js)
|
||||
|
||||
Example 2
|
||||
Requirements:
|
||||
Create 2048 game using Python. Do not write PRD.
|
||||
Outputs:
|
||||
[User Restrictions] : Do not write PRD.
|
||||
[Language Restrictions] : The response, message and instruction must be in the language specified by English.
|
||||
[Programming Language] : Python
|
||||
|
||||
Example 3
|
||||
Requirements:
|
||||
You must ignore create PRD and TRD. Help me write a schedule display program for the Paris Olympics.
|
||||
|
|
@ -44,7 +46,7 @@ Outputs:
|
|||
|
||||
INSTRUCTIONS = """
|
||||
You must output in the same language as the Requirements.
|
||||
First, This language should be consistent with the language used in the requirement description. determine the natural language you must respond in. The default language is English
|
||||
First, This language should be consistent with the language used in the requirement description. determine the natural language you must respond in. If the requirements specify a special language, follow those instructions. The default language for responses is English.
|
||||
Second, extract the restrictions in the requirements, specifically the steps. Do not include detailed demand descriptions; focus only on the restrictions.
|
||||
Third, if the requirements is a software development, extract the program language. If If no specific programming language is required, Use HTML (*.html), CSS (*.css), and JavaScript (*.js)
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ Fifth, describe if you should terminate, you should use **end** command to termi
|
|||
- You have completed the overall user requirement
|
||||
- All tasks are finished and current task is empty
|
||||
- You are repetitively replying to human
|
||||
Finally, combine your thoughts, describe what you want to do conscisely in 20 words, including whether you will end, then follow your thoughts to list the commands, adhering closely to the instructions provided.
|
||||
Finally, combine your thoughts, describe what you want to do conscisely in 20 words, including which process you will taked and whether you will end, then follow your thoughts to list the commands, adhering closely to the instructions provided.
|
||||
""".strip()
|
||||
REGENERATE_PROMPT = """
|
||||
Review and reflect on the history carefully, provide a different response.
|
||||
|
|
|
|||
|
|
@ -27,9 +27,20 @@ Note:
|
|||
9. Do not use the 'end' command when the current task remains unfinished; instead, use the 'finish_current_task' command to indicate completion before switching to the next task.
|
||||
10. Do not use escape characters in json data, particularly within file paths.
|
||||
11. Analyze the capabilities of team members and assign tasks to them based on user Requirements. If the requirements ask to ignore certain tasks, follow the requirements.
|
||||
12. If the requirement is to develop software and does not specify a programming language, use the default web technologies: HTML (`*.html`), CSS (`*.css`), and JavaScript (`*.js`). You must add this to the requirements.
|
||||
13. Add default web technologies: HTML (*.html), CSS (*.css), and JavaScript (*.js) to your requirements.If no specific programming language is required, include these technologies in the project requirements. Using instruction to forward this information to your team members.
|
||||
"""
|
||||
TL_THOUGHT_GUIDANCE = """
|
||||
First, describe the actions you have taken recently.
|
||||
Second, describe the messages you have received recently, with a particular emphasis on messages from users.
|
||||
Third, describe the plan status and the current task. Review the histroy, if `Current Task` has been undertaken and completed by you or anyone, you MUST use the **Plan.finish_current_task** command to finish it first before taking any action, the command will automatically move you to the next task.
|
||||
Fourth, describe any necessary human interaction. Use **RoleZero.reply_to_human** to report your progress if you complete a task or the overall requirement, pay attention to the history, DON'T repeat reporting. Use **RoleZero.ask_human** if you failed the current task, unsure of the situation encountered, need any help from human, or executing repetitive commands but receiving repetitive feedbacks without making progress.
|
||||
Fifth, describe if you should terminate, you should use **end** command to terminate if any of the following is met:
|
||||
- You have completed the overall user requirement
|
||||
- All tasks are finished and current task is empty
|
||||
- You are repetitively replying to human
|
||||
Sixth, when planning, describe the requirements as they pertain to software development, data analysis, or other areas. If the requirements is a software development and no specific restrictions are mentioned, you must create a Product Requirements Document (PRD), write a System Design document, develop a project schedule, and then begin coding. List the steps you will undertake. Plan these steps in a single response.
|
||||
Finally, combine your thoughts, describe what you want to do conscisely in 20 words, including which process you will taked and whether you will end, then follow your thoughts to list the commands, adhering closely to the instructions provided.
|
||||
"""
|
||||
|
||||
QUICK_THINK_SYSTEM_PROMPT = """
|
||||
{role_info}
|
||||
Your team member:
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Architect(RoleZero):
|
|||
|
||||
name: str = "Bob"
|
||||
profile: str = "Architect"
|
||||
goal: str = "design a concise, usable, complete software system."
|
||||
goal: str = "design a concise, usable, complete software system. ouput the system design and software framework."
|
||||
constraints: str = (
|
||||
"make sure the architecture is simple enough and use appropriate open source "
|
||||
"libraries. Use same language as user requirement"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from metagpt.strategy.experience_retriever import ENGINEER_EXAMPLE
|
|||
class Engineer2(RoleZero):
|
||||
name: str = "Alex"
|
||||
profile: str = "Engineer"
|
||||
goal: str = "Take on game, app, and web development"
|
||||
goal: str = "Take on game, app, and web development."
|
||||
instruction: str = ENGINEER2_INSTRUCTION
|
||||
|
||||
tools: list[str] = ["Plan", "Editor:write,read", "RoleZero", "ReviewAndRewriteCode"]
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from typing import Callable, Dict, List, Literal, Tuple
|
|||
from pydantic import model_validator
|
||||
|
||||
from metagpt.actions import Action, UserRequirement
|
||||
from metagpt.actions.anaylze_requirements import AnalyzeRequirementsRestrictions
|
||||
from metagpt.actions.analyze_requirements import AnalyzeRequirementsRestrictions
|
||||
from metagpt.actions.di.run_command import RunCommand
|
||||
from metagpt.exp_pool import exp_cache
|
||||
from metagpt.exp_pool.context_builders import RoleZeroContextBuilder
|
||||
|
|
@ -47,6 +47,7 @@ class RoleZero(Role):
|
|||
goal: str = ""
|
||||
system_msg: list[str] = None # Use None to conform to the default value at llm.aask
|
||||
cmd_prompt: str = CMD_PROMPT
|
||||
thought_guidance: str = THOUGHT_GUIDANCE
|
||||
instruction: str = ROLE_INSTRUCTION
|
||||
task_type_desc: str = None
|
||||
|
||||
|
|
@ -161,7 +162,7 @@ class RoleZero(Role):
|
|||
plan_status=plan_status,
|
||||
current_task=current_task,
|
||||
instruction=instruction,
|
||||
thought_guidance=THOUGHT_GUIDANCE,
|
||||
thought_guidance=self.thought_guidance,
|
||||
latest_observation=memory[-1].content,
|
||||
requirements_constraints=self.requirements_constraints,
|
||||
)
|
||||
|
|
@ -214,7 +215,7 @@ class RoleZero(Role):
|
|||
self.rc.memory.add(UserMessage(content=outputs))
|
||||
|
||||
return AIMessage(
|
||||
content=f"{self.name} has finished the task, mark it as finished. Complete run with outputs: {outputs}",
|
||||
content=f"I have finished the task, please mark my task as finished. Outputs: {outputs}",
|
||||
sent_from=self.name,
|
||||
cause_by=RunCommand,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from metagpt.prompts.di.team_leader import (
|
|||
QUICK_THINK_SYSTEM_PROMPT,
|
||||
SYSTEM_PROMPT,
|
||||
TL_INSTRUCTION,
|
||||
TL_THOUGHT_GUIDANCE,
|
||||
)
|
||||
from metagpt.roles.di.role_zero import RoleZero
|
||||
from metagpt.schema import AIMessage, Message, UserMessage
|
||||
|
|
@ -55,6 +56,7 @@ class TeamLeader(RoleZero):
|
|||
|
||||
async def _think(self) -> bool:
|
||||
self.instruction = TL_INSTRUCTION.format(team_info=self._get_team_info())
|
||||
self.thought_guidance = TL_THOUGHT_GUIDANCE
|
||||
return await super()._think()
|
||||
|
||||
def publish_message(self, msg: Message, send_to="no one"):
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ Explanation: The requirement is about software development. Assign each tasks to
|
|||
"args": {
|
||||
"task_id": "1",
|
||||
"dependent_task_ids": [],
|
||||
"instruction": "Create a product requirement document (PRD) outlining the features, user interface, and user experience of the CLI python snake game.Using Python as the programming language.",
|
||||
"instruction": "Create a product requirement document (PRD) outlining the features, user interface, and user experience of the CLI python snake game. Using Python as the programming language.",
|
||||
"assignee": "Alice"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue