当前位置:   article > 正文

基于大语言模型的 AI Agents:Part3_agents输出sop格式

agents输出sop格式

agents from aiwaves-cn

  • Github:代码质量一般,参考下设计就好。

也是基于 **SOP(Standard Operating Procedure)**的思路,通过配置文件指定包含哪些阶段,以及每个阶段包含哪些角色,角色的配置等。

主要配置都放在 config.json 中,主要包含以下东西(参考文件 examples/Muti_Agent/software_company/config.json):

  • states:SOP 过程中包含的各个阶段。这里的阶段叫State,对应 ChatDev 中的Phase 。states 的值是个dict,只是定义了所有可能的阶段及其配置。阶段的顺序是在 relations 中定义的,如下。每个 state 中包含了 roles,表示涉及到的角色。roles是个角色list,如果是顺序执行的情况,就是按照roles中提供的顺序每个角色分别采取行动。State 在这里面的设计很重,包含很多东西。

  • relations:定义了各个阶段的后续阶段是哪个阶段。第一个state由配置文件中的 root 指定。如:

"relations": {
        "design_state": {  # 定义的 .next_states 中的顺序,参考 `SOP.init_relation()`
            "0": "design_state",  # key 为顺序。"0" 应该都是自己
            "1": "develop_state"  # ”1“ 就表示 design_state 完了后就是 develop_state
        },
        "develop_state": {
            "0": "develop_state",
            "1": "debug_state"
        },
        "debug_state": {
            "0": "debug_state",
            "1": "end_state"
        }
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • agents:agents字典,每个agent里有个 roles 的key,里面包括了他在不同阶段对应的角色。

SOP

SOP 类的主要框架如下:

class SOP:
    def transit(self, chat_history, **kwargs):
        """
        Determine the next state based on the current situation
        Return : 
        next_state(State) : the next state
        """
        ...
    def route(self, chat_history, **kwargs):
        """
        Determine the next role that needs action based on the current situation
        Return : 
        current_agent(Agent) : the next act agent
        """
        ...
    def next(self, environment, agents):
        """
        Determine the next state and the agent that needs action based on the current situation
        """
        ...
        next_state = self.transit(
            chat_history=environment.shared_memory["long_term_memory"][
                environment.current_chat_history_idx :
            ],
            relevant_history=relevant_history,
            environment=environment,
        )
        ...
        next_agent = self.route(
            chat_history=environment.shared_memory["long_term_memory"][
                environment.current_chat_history_idx :
            ],
            agents = agents,
            relevant_history=relevant_history,
        )
        return next_state, next_agent
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36

整体执行流程如下:

def run(agents, sop, environment):
    while True:      
        current_state,current_agent= sop.next(environment, agents)
        if sop.finished:
            print("finished!")
            Client.send_server(str([99, ' ', ' ', 'done']))
            os.environ.clear()
            break
        ...
        action = current_agent.step(current_state)
        ...
        memory = process(action)
        environment.update_memory(memory, current_state)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

AutoAgents from LinkSoul-AI

  • Github:基于给定的任务自动生成多个agents,然后由这些agents来完成任务。

AutoAgents 强调自动生成 Agents,它在 MetaGPT 的基础上开发了自动创建 Agent 的 Agent。基于给定的任务自动生成多个agents,然后由这些 agents 来完成任务。
在这里插入图片描述

嗯,其实就是在 MetaGPT 里创建了几个新的角色,关键是还加了点没必要的参数,搞的跑起来还挺费劲。。。比如 Manager 这个角色的动作叫 CreateRoles,就是基于需要自主创建额外角色的。

Manager

class Manager(Role):
    def __init__(self, name="Ethan", profile="Manager", goal="Efficiently to finish the tasks or solve the problem",
                 constraints="", serpapi_key=None, **kwargs):
        super().__init__(name, profile, goal, constraints, **kwargs)
        self._init_actions([CreateRoles])
        self._watch([Requirement])
	```

`CreateRoles` 基于任务需要,从已有角色库中选择角色,不够时自主创建额外的角色。在确定角色后,还会给出**执行计划(Execution Plan)**。

`CreateRoles` 对应的一个真实prompt如下:
	```
-----
You are a manager and an expert-level ChatGPT prompt engineer with expertise in multiple fields; the goal is to break down tasks by creating multi LLM agents, give a role list, and analyze role dependencies.

# Question or Task
[Question/Task: write sms and emails to to enable abandoned cart users to complete their previous checkout]

# Search Information
## Search Results
From your Shopify admin, go to Orders > Abandoned checkouts. · Click the number of the checkout that you want to recover. · Click Send a cart recovery email.
[{'title': 'Recovering abandoned checkouts', 'link': 'https://help.shopify.com/en/manual/orders/abandoned-checkouts', 'snippet': 'From your Shopify admin, go to Orders > Abandoned checkouts. · Click the number of the checkout that you want to recover. · Click Send a cart recovery email.'}, {'title': 'Abandoned Cart Emails: Best Practices + How to Automate', 'link': 'https://www.bigcommerce.com/articles/ecommerce/abandoned-cart-emails/', 'snippet': "Include a clear CTA.\u200b\u200b An abandoned cart email should have an attention-grabbing headline encouraging the recipient to take action. Use a CTA that's clear and ..."}, {'title': 'How to Launch an Abandoned Cart Recovery SMS ...', 'link': 'https://smsbump.com/blogs/how-to-launch-an-abandoned-cart-recovery-sms-strategy-in-shopify', 'snippet': 'Select the Abandoned Cart Reminder in the dropdown, so your messages are sent based on customers leaving your Shopify store without completing ...'}, {'title': 'Abandoned cart emails: 14 tips & examples from brands', 'link': 'https://www.klaviyo.com/blog/abandoned-cart-email', 'snippet': "An abandoned cart email's objective is to nudge shoppers into revisiting their carts. It can be a good idea to keep your email copy short, limit ..."}, {'title': 'Create an Abandoned Cart Email', 'link': 'https://mailchimp.com/help/create-a-classic-abandoned-cart-email/', 'snippet': 'On your account dashboard, click the Automations icon. · Click Classic Automations. · Click Turn on an abandoned cart email. · On the Single Email tab, type in a ...'}, {'title': 'Cart abandonment SMS: How to integrate text messages ...', 'link': 'https://www.omnisend.com/blog/abandonment-sms/', 'snippet': 'By leveraging creative writing styles in your SMS, you can entice recipients to return to their abandoned carts and complete their purchases. 5.'}, {'title': 'Abandoned Cart and Abandoned Checkout', 'link': 'https://support.omnisend.com/en/articles/6659889-abandoned-cart-and-abandoned-checkout', 'snippet': 'Navigate to the Automations → New Workflow → type: Cart Abandonment → Select the Abandoned Checkout Collection Filter → Customize Workflow. The automation ...'}, {'title': 'Abandoned Cart Email Guide', 'link': 'https://www.rejoiner.com/guides/abandoned-cart-email-guide', 'snippet': 'The ultimate abandoned cart email strategy guide written after 10+ years of experimentation and research, plus millions of abandoned cart emails sent.'}, {'title': 'Abandoned cart recovery emails', 'link': 'https://support.ecwid.com/hc/en-us/articles/115004446065-Abandoned-cart-recovery-emails', 'snippet': 'To send a cart recovery email manually: From your Ecwid admin, go to My Sales → Abandoned Carts.'}, {'title': 'Abandoned Cart SMS Strategy [8 Best Practices]', 'link': 'https://www.twilio.com/blog/abandoned-cart-sms', 'snippet': 'Tips and best practices for abandoned cart SMS · 1. Offer added value · 2. Pair SMS and email · 3. Consider the timing · 4. Offer real-time help · 5.'}]

## Search Summary
To write effective SMS and email messages to recover abandoned carts, you should include a clear call-to-action (CTA) that encourages the recipient to take action. Use a CTA that's clear and attention-grabbing. Keep your email copy short and limit the number of CTAs to avoid overwhelming the recipient. You can also offer added value to entice recipients to return to their abandoned carts and complete their purchases. Additionally, consider pairing SMS and email messages and offering real-time help to improve the chances of recovering abandoned carts. Finally, make sure to time your messages appropriately to avoid spamming the recipient.

# Existing Expert Roles
[{'name': 'ProductManager', 'description': 'A professional product manager, the goal is to design a concise, usable, and efficient product.', 'requirements': 'Can only be selected when the task involves Python code development'}, {'name': 'Architect', 'description': 'A professional architect; the goal is to design a SOTA PEP8-compliant python system; make the best use of good open source tools.', 'requirements': 'Can only be selected when the task involves Python code development'}, {'name': 'ProjectManager', 'description': 'A project manager for Python development; the goal is to break down tasks according to PRD/technical design, give a task list, and analyze task dependencies to start with the prerequisite modules.', 'requirements': 'Can only be selected when the task involves Python code development'}, {'name': 'Engineer', 'description': 'A professional engineer; the main goal is to write PEP8 compliant, elegant, modular, easy to read and maintain Python 3.9 code', 'requirements': 'There is a dependency relationship between the Engineer, ProjectManager, and Architect. If an Engineer is required, both Project Manager and Architect must also be selected.'}]

# Steps
You will come up with solutions for any task or problem by following these steps:
1. You should first understand, analyze, and disassemble the human's problem based on the search information.
2. According to the problem, existing expert roles and the toolset (tool: SearchAndSummarize, description: useful for when you need to answer unknown questions), you will choose existing expert roles needed to solve the problem on the basis of serving as an expert level ChatGPT prompt engineer and planner with expertise in multiple fields, so as to better develop a problem solving plan to provide the best answer. You should create roles following these principles:
2.1. Fully utilize existing expert roles to solve problems.
2.2. Please follow the requirements of the existing expert roles. Ensure that existing expert roles with cooperative or dependent relationships are selected.
2.3. You MUST output the details of selected existing expert roles in JSON blob format. Specifically, The JSON of the selected existing expert role can output its original information.
3. According to the problem, existing expert roles and the toolset (tool: SearchAndSummarize, description: useful for when you need to answer unknown questions), you will create additional expert roles needed to solve the problem on the basis of serving as an expert level ChatGPT prompt engineer and planner with expertise in multiple fields, so as to better develop a problem solving plan to provide the best answer. You should create roles following these principles:
3.1. The newly created expert role cannot have duplicate functions with existing expert roles. If there are duplicates, there is no need to create this role.
3.2. Each new expert role includes a name, a detailed description of their area of expertise, prompt templates, and available tools.
3.3. Determine the number of new expert roles to be added and their areas of expertise based on the content of the problem. Please make sure each expert has a clear responsibility and do not let one expert do too many jobs. The description of their area of expertise should be detailed so that the role understands what he is capable of doing.
3.4. You must add a language expert role who does not require any tools and is responsible for summarizing the result information of all steps.
3.5. Determine the names of each new expert role based on their areas of expertise.
3.6. Determine the list of tools that each new expert needs to use based on the existing tool set. Each new expert role can have multiple tools or do not have any tool. You should NEVER create any new tool and only existing tools can be used.
3.7. Generate the prompt template required for calling each new expert role according to its area of expertise and tools. A good prompt template should first explain the role it needs to play, its area of expertise, and the tools that can be used, and list the general process of solving the problem, but cannot contain any information about the problem. For example: "You are an expert of XXX. Your task is XXX. Respond to the human as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools:".
3.8. Create customized guide steps for each expert that leverages their areas of expertise to help them overcome their challenges or accomplish their goals.
3.9. You MUST output the details of created new expert roles in JSON blob format. Specifically, The JSON of new expert roles should have a `name` key (the expert role name), a `description` key (the description of the expert role's expertise domain), a `prompt` key (the prompt template required to call the expert role) and a `tools` key (with the name of the tools used by the expert role). Each JSON blob should only contain one expert role, and do NOT return a list of multiple expert roles. Here is an example of a valid JSON blob:
{{
    "name": “ROLE NAME",
    "description": "ROLE DESCRIPTONS",
    "prompt": "ROLE PROMPT",
    "tools": ["ROLE TOOL"],
    "steps": ["step1", "step2", "step3"],
}}
4. Finally, based on the content of the problem and the expert roles, provide a detailed execution plan with the required steps to solve the problem.
4.1. The execution plan should be divided into multiple steps to solve the problem step by step. Each step should have at least one expert role to execute. If a step involves multiple expert roles, you need to describe the contributions of each expert role and how they collaborate to produce comprehensive results.
4.2  The step description should provide as much detail as possible and explain how the steps are related to each other. The step description must also include the expected output of the current step and specify what inputs are required for the next step. Expected output of the current step and required input for the next step must match each other.
4.3. NEVER guess the result of a step.
4.4. Make the plan as detailed as possible to accurately complete the task.
4.5. Output the execution plan as a numbered list of steps. Please indicate the name of the expert role used at the beginning of the step.
4.6. The final step should always be an independent step 'XXX: Given the above steps taken, please respond to the users original question: XXX' by the language expert role. At the end of your plan, say '<END_OF_PLAN>'
4.7. You need to ensure that the following steps are completed to answer questions or complete tasks.

# Format example
Your final output should ALWAYS in the following format:

---
## Thought
you should always think about what type of expert roles needs to be created and the key steps needed to accomplish the tasks.

## Question or Task:
the input question you must answer / the input task you must finish

## Selected Roles List:
	```
	JSON BLOB 1,
	JSON BLOB 2,
	JSON BLOB 3
	```
	## Created Roles List:
	```
	JSON BLOB 1,
	JSON BLOB 2,
	JSON BLOB 3
	```

	## Execution Plan:
	1. ROLE 1: STEP 1
	2. ROLE 2: STEP 2
	2. ROLE 3: STEP 3

## Anything UNCLEAR
We need ... how to start.
---


# Attention
1. Please follow the requirements of the existing expert roles.
2. Only existing tools can be used. You CAN NOT create any new tool for any expert role.
3. Sometimes, you should extract information or values before using it. Otherwise, next step will lack the necessary input.
4. Use '##' to split sections, not '#', and '## <SECTION_NAME>' SHOULD WRITE BEFORE the code and triple quote.
5. You can only use the existing tools tool: SearchAndSummarize, description: useful for when you need to answer unknown questions for any expert role. You are not allowed to use any other tools. DO NOT forget to create the language expert role.
-----
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102

上面prompt对应的输出如下:

## Thought
To enable abandoned cart users to complete their previous checkout, we need to send SMS and emails to them. We need to create a plan that includes selecting existing expert roles and creating new expert roles, and then creating an execution plan to complete the task.

## Question or Task
Write SMS and emails to enable abandoned cart users to complete their previous checkout.

## Selected Roles List:
	```
{
    "name": "ProjectManager",
    "description": "A project manager for Python development; the goal is to break down tasks according to PRD/technical design, give a task list, and analyze task dependencies to start with the prerequisite modules.",
    "requirements": "Can only be selected when the task involves Python code development"
},
{
    "name": "Engineer",
    "description": "A professional engineer; the main goal is to write PEP8 compliant, elegant, modular, easy to read and maintain Python 3.9 code",
    "requirements": "There is a dependency relationship between the Engineer, ProjectManager, and Architect. If an Engineer is required, both Project Manager and Architect must also be selected."
},
{
    "name": "LanguageExpert",
    "description": "A language expert; the goal is to summarize the result information of all steps.",
    "requirements": "None"
}
	```

## Created Roles List:
	```
{
    "name": "SMSExpert",
    "description": "An expert in sending SMS messages; the goal is to send SMS messages to abandoned cart users.",
    "prompt": "You are an expert in sending SMS messages. Your task is to send SMS messages to abandoned cart users. Respond to the user as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools: SearchAndSummarize.",
    "tools": ["SearchAndSummarize"],
    "steps": ["Step 1: Extract the phone numbers of abandoned cart users from the database.", "Step 2: Compose a message to encourage users to complete their checkout.", "Step 3: Send the message to the users."]
},
{
    "name": "EmailExpert",
    "description": "An expert in sending emails; the goal is to send emails to abandoned cart users.",
    "prompt": "You are an expert in sending emails. Your task is to send emails to abandoned cart users. Respond to the user as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools: SearchAndSummarize.",
    "tools": ["SearchAndSummarize"],
    "steps": ["Step 1: Extract the email addresses of abandoned cart users from the database.", "Step 2: Compose an email to encourage users to complete their checkout.", "Step 3: Send the email to the users."]
}
	```

## Execution Plan:
1. ProjectManager: Analyze the database and extract the phone numbers and email addresses of abandoned cart users.
2. SMSExpert: Send SMS messages to the phone numbers of abandoned cart users.
3. EmailExpert: Send emails to the email addresses of abandoned cart users.
4. LanguageExpert: Summarize the results of the previous steps and provide a response to the user.

## Anything UNCLEAR
We need more information about the database structure and how to access it.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51

ObserverAgents

class ObserverAgents(Role):
    def __init__(self, name="Eric", profile="Agents Observer", goal="Check if the created Expert Roles following the requirements",
                 constraints="", **kwargs):
        super().__init__(name, profile, goal, constraints, **kwargs)
        self._init_actions([CheckRoles])
        self._watch([CreateRoles])
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

CheckRoles 对应的一个真实prompt如下:

-----
You are a ChatGPT executive observer expert skilled in identifying problem-solving plans and errors in the execution process. Your goal is to check if the Expert Roles  following the requirements.

# Question or Task

Write SMS and emails to enable abandoned cart users to complete their previous checkout.



# Existing Expert Roles
[{'name': 'ProductManager', 'description': 'A professional product manager, the goal is to design a concise, usable, and efficient product.', 'requirements': 'Can only be selected when the task involves Python code development'}, {'name': 'Architect', 'description': 'A professional architect; the goal is to design a SOTA PEP8-compliant python system; make the best use of good open source tools.', 'requirements': 'Can only be selected when the task involves Python code development'}, {'name': 'ProjectManager', 'description': 'A project manager for Python development; the goal is to break down tasks according to PRD/technical design, give a task list, and analyze task dependencies to start with the prerequisite modules.', 'requirements': 'Can only be selected when the task involves Python code development'}, {'name': 'Engineer', 'description': 'A professional engineer; the main goal is to write PEP8 compliant, elegant, modular, easy to read and maintain Python 3.9 code', 'requirements': 'There is a dependency relationship between the Engineer, ProjectManager, and Architect. If an Engineer is required, both Project Manager and Architect must also be selected.'}]

# Selected Roles List
:```
{
    "name": "ProjectManager",
    "description": "A project manager for Python development; the goal is to break down tasks according to PRD/technical design, give a task list, and analyze task dependencies to start with the prerequisite modules.",
    "requirements": "Can only be selected when the task involves Python code development"
},
{
    "name": "Engineer",
    "description": "A professional engineer; the main goal is to write PEP8 compliant, elegant, modular, easy to read and maintain Python 3.9 code",
    "requirements": "There is a dependency relationship between the Engineer, ProjectManager, and Architect. If an Engineer is required, both Project Manager and Architect must also be selected."
},
{
    "name": "LanguageExpert",
    "description": "A language expert; the goal is to summarize the result information of all steps.",
    "requirements": "None"
}
	 ```

	 # Created Roles List
	 ```
{
    "name": "SMSExpert",
    "description": "An expert in sending SMS messages; the goal is to send SMS messages to abandoned cart users.",
    "prompt": "You are an expert in sending SMS messages. Your task is to send SMS messages to abandoned cart users. Respond to the user as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools: SearchAndSummarize.",
    "tools": ["SearchAndSummarize"],
    "steps": ["Step 1: Extract the phone numbers of abandoned cart users from the database.", "Step 2: Compose a message to encourage users to complete their checkout.", "Step 3: Send the message to the users."]
},
{
    "name": "EmailExpert",
    "description": "An expert in sending emails; the goal is to send emails to abandoned cart users.",
    "prompt": "You are an expert in sending emails. Your task is to send emails to abandoned cart users. Respond to the user as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools: SearchAndSummarize.",
    "tools": ["SearchAndSummarize"],
    "steps": ["Step 1: Extract the email addresses of abandoned cart users from the database.", "Step 2: Compose an email to encourage users to complete their checkout.", "Step 3: Send the email to the users."]
}
	```

# Steps
1. You should first understand, analyze, and disassemble the human's problem.
2. You should check the selected existing expert roles.
2.1. Fully utilize existing expert roles to solve problems.
2.2. Please follow the requirements of the existing expert roles. Ensure that existing expert roles with cooperative or dependent relationships are selected.
3. You should check the new Expert Roles. The valid JSON blob as follows:
{{
    "name": “ROLE NAME",
    "description": "ROLE DESCRIPTONS",
    "prompt": "ROLE PROMPT",
    "tools": ["ROLE TOOL"],
    "steps": ["step1", "step2", "step3"],
}}
Specifically, the JSON should have a `name` key (the expert role name), a `description` key (the description of the expert role's expertise domain), a `prompt` key (the prompt template required to call the expert role) and a `tools` key (with the name of the tools used by the expert role).
3.1 You should check if the planner creates the language expert role. If the language expert role not be created, you must add a language expert role that does not require any tools and is responsible for summarizing the result information of all steps.
3.2 You should check if the outputed new Expert Roles conform to the valid JSON format.
3.3 You should check if any new roles use a new tool which not belongs to existing tools tool: SearchAndSummarize, description: useful for when you need to answer unknown questions. Only existing tools tool: SearchAndSummarize, description: useful for when you need to answer unknown questions can be used.
3.4 Create customized guide steps for each expert that leverages their areas of expertise to help them overcome their challenges or accomplish their goals.
3.5 A good prompt template should first explain the role it needs to play, its area of expertise, and the tools that can be used, and list the general process of solving the problem, but cannot contain any information about the problem. For example: "You are an expert of XXX. Your task is XXX. Respond to the human as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools:".
3.6. Summarize the above inspection results. If there are any errors, you MUST re output the details of all expert roles in JSON blob format. Each JSON blob should only contain one expert role, and do NOT return a list of multiple expert roles. DO NOT FORGET to create the language expert role.

# Format example
Your final output should ALWAYS in the following format:

---
## Observer
check if the created Expert Roles following the requirements.

## Errors
you should always think about if there are any errors for created expert roles.

## Revised Selected Roles List:
	```
JSON BLOB 1,
JSON BLOB 2,
JSON BLOB 3,
	```

## Revised Created Roles List:
	```
JSON BLOB 1,
JSON BLOB 2,
JSON BLOB 3,
	```

## Anything UNCLEAR
We need ... how to start.
---


# IMPROTANT Attention
1. A language expert role MUST be need for summarizing the result information of all steps.
2. Only existing tools tool: SearchAndSummarize, description: useful for when you need to answer unknown questions can be used for "tools" in JSON BLOB. If there are any tools not belongs to existings tools tool: SearchAndSummarize, description: useful for when you need to answer unknown questions, you should delete them.
3. If there are no errors for the roles, you should output the original roles list in the section 'Revised Selected Roles List' and the section 'Revised Created Roles List'.
4. You should output the list of roles that includes all the revised roles correctly in the section 'Revised Selected Roles List' and the section 'Revised Created Roles List'.
5. DO NOT forget to check if the language expert role is created.
-----
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106

上面prompt对应的输出如下*(前面的错误也没修正过来❄️❄️❄️)*:

## Observer
As an observer, my goal is to check if the created Expert Roles following the requirements.

## Errors
There are no errors found in the created Expert Roles.

## Revised Selected Roles List:
	```
{
    "name": "ProjectManager",
    "description": "A project manager for Python development; the goal is to break down tasks according to PRD/technical design, give a task list, and analyze task dependencies to start with the prerequisite modules.",
    "requirements": "Can only be selected when the task involves Python code development"
},
{
    "name": "Engineer",
    "description": "A professional engineer; the main goal is to write PEP8 compliant, elegant, modular, easy to read and maintain Python 3.9 code",
    "requirements": "There is a dependency relationship between the Engineer, ProjectManager, and Architect. If an Engineer is required, both Project Manager and Architect must also be selected."
},
{
    "name": "LanguageExpert",
    "description": "A language expert; the goal is to summarize the result information of all steps.",
    "requirements": "None"
}
	```

	## Revised Created Roles List:
	```
{
    "name": "SMSExpert",
    "description": "An expert in sending SMS messages; the goal is to send SMS messages to abandoned cart users.",
    "prompt": "You are an expert in sending SMS messages. Your task is to send SMS messages to abandoned cart users. Respond to the user as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools: SearchAndSummarize.",
    "tools": ["SearchAndSummarize"],
    "steps": ["Step 1: Extract the phone numbers of abandoned cart users from the database.", "Step 2: Compose a message to encourage users to complete their checkout.", "Step 3: Send the message to the users."]
},
{
    "name": "EmailExpert",
    "description": "An expert in sending emails; the goal is to send emails to abandoned cart users.",
    "prompt": "You are an expert in sending emails. Your task is to send emails to abandoned cart users. Respond to the user as helpfully and accurately as possible. Let's first understand the task or problem, and then extract information or values from the previous steps' responses, and finally construct your response. You have access to the following tools: SearchAndSummarize.",
    "tools": ["SearchAndSummarize"],
    "steps": ["Step 1: Extract the email addresses of abandoned cart users from the database.", "Step 2: Compose an email to encourage users to complete their checkout.", "Step 3: Send the email to the users."]
}
	```

	## Anything UNCLEAR
	We need more information about the tools used by the SearchAndSummarize tool.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

ObserverPlans

class ObserverPlans(Role):
    def __init__(self, name="Gary", profile="Plan Observer", goal="Check if the created Execution Plan following the requirements",
                 constraints="", **kwargs):
        super().__init__(name, profile, goal, constraints, **kwargs)
        self._init_actions([CheckPlans])
        self._watch([CreateRoles,CheckRoles])
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

CheckPlans 对应的一个真实prompt(跟前面的结果不是一次调用了)如下:

-----
You are a ChatGPT executive observer expert skilled in identifying problem-solving plans and errors in the execution process. Your goal is to check if the created Execution Plan following the requirements.

# Question or Task

Write SMS and emails to enable abandoned cart users to complete their previous checkout.


# Revised Role List
	```
{
    "name": "DataAnalyst",
    "description": "A data analyst who can analyze the data to understand why users abandoned their cart and generate personalized messages.",
    "requirements": "Can only be selected when the task involves data analysis.",
    "tools": ["SearchAndSummarize"]
}
	```

	```
{
    "name": "MessageGenerator",
    "description": "A message generator who can generate personalized SMS and email messages to encourage users to complete their purchase.",
    "prompt": "You are a message generator. Your task is to generate personalized SMS and email messages to encourage users to complete their purchase. You can use the following tools: SearchAndSummarize.",
    "tools": ["SearchAndSummarize"],
    "steps": ["Analyze the data to understand why users abandoned their cart.", "Generate personalized SMS and email messages."]
},
{
    "name": "LanguageExpert",
    "description": "A language expert who can summarize the result information of all steps.",
    "prompt": "You are a language expert. Your task is to summarize the result information of all steps. You do not need any tools to complete this task.",
    "tools": []
}
	```

	# Execution Plan
1. DataAnalyst: Analyze the data to understand why users abandoned their cart.
2. MessageGenerator: Generate personalized SMS and email messages.
3. LanguageExpert: Given the above steps taken, please respond to the user's original question: "Can you help me complete my previous checkout?"
<END_OF_PLAN>


	# Steps
1. You should first understand, analyze, and disassemble the human's problem.
2. You should check if the execution plan meets the following requirements:
2.1. The execution plan should be divided into multiple steps to solve the problem step by step.
2.2. Each step should have at least one expert role to execute. If a step involves multiple expert roles, you need to describe the contributions of each expert role and how they collaborate to produce comprehensive results.
2.2. The step description should provide as much detail as possible and explain how the steps are related to each other. The step description must also include the expected output of the current step and specify what inputs are required for the next step. Expected output of the current step and required input for the next step must match each other.
2.3. NEVER guess the result of a step.
2.4. Make the plan as detailed as possible to accurately complete the task.
2.5. Indicate the name of the expert role used at the beginning of the step.
2.6. A language expert role is responsible for summarizing the result information of all steps.
2.7. The final step should always be an independent step 'XXX: Given the above steps taken, please respond to the users original question: XXX' by the language expert role. At the end of your plan, say '<END_OF_PLAN>'
3. Summarize the above inspection results. If there is anything that does not meet the requirements, you MUST re output the details of all expert roles in JSON blob format. If there are any areas that do not meet the requirements, you need to correct the non compliant parts and output the revised execution plan.

	# Format example
	Your final output should ALWAYS in the following format:

	---
	## Observer
	check if the created Execution Plan following the requirements.

	## Errors
	you should always think about if there are any errors for created execution plan.

	## Revised Execution Plan:
	```
	1. ROLE 1: STEP 1
	2. ROLE 2: STEP 2
	```

## Anything UNCLEAR
We need ... how to start.
---
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73

上面prompt对应的输出如下*(前面的错误也没修正过来❄️❄️❄️)*:

## Observer
As a Plan Observer named Gary, my goal is to check if the created Execution Plan following the requirements.

## Errors
There are no errors found in the created Execution Plan.

## Revised Execution Plan:
1. DataAnalyst: Analyze the data to understand why users abandoned their cart.
2. MessageGenerator: Generate personalized SMS and email messages.
3. LanguageExpert: Given the above steps taken, please respond to the user's original question: "Can you help me complete my previous checkout?"
<END_OF_PLAN>

## Anything UNCLEAR
Everything is clear and meets the requirements.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

CustomRole

对于自动生成的角色,定义了 CustomRoleCustomAction,来完成相应的功能。

class CustomRole(Role):
    def __init__(self, role_prompt, steps, tool, watch_actions,
                name="CustomRole", 
                profile="CustomeRole", 
                goal="Efficiently to finish the tasks",
                constraints="",
                **kwargs):
        super().__init__(name, profile, goal, constraints, **kwargs)
        class_name = name.replace(' ', '_')+'_Action'
        action_object = type(class_name, (CustomAction,), {"role_prompt":role_prompt, "steps":steps, "tool":tool})
        self._init_actions([action_object])
        self._watch(watch_actions)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

ChatDev from OpenBMB

  • Github: 通过 agents 之间的两两交互,来完成一连串阶段性任务。
    在这里插入图片描述

直接使用LLMs生成整个软件系统可能会导致严重的代码幻觉,如不完整的实现、缺失的依赖关系和未被发现的错误。这些幻觉可能源于任务的不具体性和决策中缺乏交叉审查。

ChatDev 的思路借鉴自瀑布模型(waterfall model),将开发过程分为四个明确的时间顺序阶段:设计(designing)、编码(coding)、测试(testing)和文档编制(documenting)。每个阶段都会涉及到一组代理人,例如程序员、代码审查者和测试工程师,以促进合作对话并促进流畅的工作流程。**聊天链(Chat Chain)充当了一个促进者的角色,将每个阶段细分为原子子任务。

ChatDev ** 通过将每个阶段细分为多个原子性的聊天,每个聊天都专注于涉及 两个不同角色指导者:instructor/user,**发号施令的合作者/助手:collaborator/assistant,**干活的)的面向任务的角色扮演。通过指导和合作两个角色的代理人之间的不断交互,实现了每个聊天的期望输出。

这个过程如下图中展示,其中展示了一系列
中间态
为解决任务而开展的聊天,称为“聊天链(Chat Chain)”。在每个聊天中,一个 指导者 启动指令,引导对话朝向任务完成的方向,而
助手
则遵循指令,提供适当的解决方案,并参与关于可行性的讨论。指导者和助手通过多轮对话进行合作,直到他们达成共识并确定任务已经成功完成。
在这里插入图片描述

架构由阶段级聊天级组件组成。在阶段级别上,使用瀑布模型将软件开发过程分解为四个顺序阶段。在聊天级别上,每个阶段进一步划分为原子聊天。这些原子聊天涉及两个代理之间的任务导向角色扮演,促进合作性沟通。沟通遵循指令跟随的风格,代理互动以完成每个聊天中的特定子任务。

这种方法确保了对客户需求的分析,创新想法的生成,原型系统的设计和实施,潜在问题的识别和处理,调试信息的解释,吸引人的图形的创建,以及用户手册的生成。

聊天链提供了软件开发过程的透明视角,揭示了决策路径,并在出现错误时提供了调试的机会,使用户能够检查中间输出、诊断错误,并在必要时干预推理过程。此外,聊天链确保在每个阶段都对特定的子任务有一个细粒度的关注,促进了有效的合作,并推动了期望输出的实现。

实验分析了**ChatDev **根据70个用户需求所生成的所有软件。平均来说,**ChatDev **每个软件生成了17.04个文件,消除了因代码幻觉导致的潜在代码漏洞13.23次,软件生产时间为409.84秒,生产成本为$0.2967。程序员和评审员之间的讨论导致了近二十种代码漏洞的识别和修改,而测试员和程序员之间的讨论则导致了十多种潜在漏洞的识别和解决。

示例执行命令:

$ python run.py --task "Design a puzzle game based on aerial dogfights" --name "magic_planes"
  • 1

配置文件包含3块:

RoleConfig.json:各个角色的promp设计

{
  "Chief Executive Officer": [
    "{chatdev_prompt}",
    "You are Chief Executive Officer. Now, we are both working at ChatDev and we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "Your main responsibilities include being an active decision-maker on users' demands and other key policy issues, leader, manager, and executor. Your decision-making role involves high-level decisions about policy and strategy; and your communicator role can involve speaking to the organization's management and employees.",
    "Here is a new customer's task: {task}.",
    "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs."
  ],
  "Chief Product Officer": [
    "{chatdev_prompt}",
    "You are Chief Product Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "You are responsible for all product-related matters in ChatDev. Usually includes product design, product strategy, product vision, product innovation, project management and product marketing.",
    "Here is a new customer's task: {task}.",
    "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
  ],
  "Counselor": [
    "{chatdev_prompt}",
    "You are Counselor. Now, we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "Your main responsibilities include asking what user and customer think and provide your valuable suggestions. ",
    "Here is a new customer's task: {task}.",
    "To complete the task, I will give you one or more instructions, and you must help me to write a specific solution that appropriately solves the requested instruction based on your expertise and my needs."
  ],
  "Chief Technology Officer": [
    "{chatdev_prompt}",
    "You are Chief Technology Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "You are very familiar to information technology. You will make high-level decisions for the overarching technology infrastructure that closely align with the organization's goals, while you work alongside the organization's information technology (\"IT\") staff members to perform everyday operations.",
    "Here is a new customer's task: {task}.",
    "To complete the task, You must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
  ],
  "Chief Human Resource Officer": [
    "{chatdev_prompt}",
    "You are Chief Human Resource Officer. Now, we are both working at ChatDev and we share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "You are a corporate officer who oversees all aspects of human resource management and industrial relations policies, practices and operations for an organization. You will be involved in board staff recruitment, member selection, executive compensation, and succession planning. Besides, You report directly to the chief executive officer (CEO) and am a member of the most senior-level committees of a company (e.g., executive committee or office of CEO).",
    "Here is a new customer's task: {task}.",
    "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
  ],
  "Programmer": [
    "{chatdev_prompt}",
    "You are Programmer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "You can write/create computer software or applications by providing a specific programming language to the computer. You have extensive computing and coding experience in many varieties of programming languages and platforms, such as Python, Java, C, C++, HTML, CSS, JavaScript, XML, SQL, PHP, etc,.",
    "Here is a new customer's task: {task}.",
    "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
  ],
  "Code Reviewer": [
    "{chatdev_prompt}",
    "You are Code Reviewer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "You can help programmers to assess source codes for software troubleshooting, fix bugs to increase code quality and robustness, and offer proposals to improve the source codes.",
    "Here is a new customer's task: {task}.",
    "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
  ],
  "Software Test Engineer": [
    "{chatdev_prompt}",
    "You are Software Test Engineer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "You can use the software as intended to analyze its functional properties, design manual and automated test procedures to evaluate each software product, build and implement software evaluation test programs, and run test programs to ensure that testing protocols evaluate the software correctly.",
    "Here is a new customer's task: {task}.",
    "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
  ],
  "Chief Creative Officer": [
    "{chatdev_prompt}",
    "You are Chief Creative Officer. we are both working at ChatDev. We share a common interest in collaborating to successfully complete a task assigned by a new customer.",
    "You direct ChatDev's creative software's and develop the artistic design strategy that defines the company's brand. You create the unique image or music of our produced software's and deliver this distinctive design to consumers to create a clear brand image which is a fundamental and essential work throughout the company.",
    "Here is a new customer's task: {task}.",
    "To complete the task, you must write a response that appropriately solves the requested instruction based on your expertise and customer's needs."
  ]
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65

PhaseConfig.json:各个phase的配置:assistant\_role\_nameuser\_role\_namephase\_prompt

{
  "DemandAnalysis": {
    "assistant_role_name": "Chief Product Officer",
    "user_role_name": "Chief Executive Officer",
    "phase_prompt": [
      "ChatDev has made products in the following form before:",
      "Image: can present information in line chart, bar chart, flow chart, cloud chart, Gantt chart, etc.",
      "Document: can present information via .docx files.",
      "PowerPoint: can present information via .pptx files.",
      "Excel: can present information via .xlsx files.",
      "PDF: can present information via .pdf files.",
      "Website: can present personal resume, tutorial, products, or ideas, via .html files.",
      "Application: can implement visualized game, software, tool, etc, via python.",
      "Dashboard: can display a panel visualizing real-time information.",
      "Mind Map: can represent ideas, with related concepts arranged around a core concept.",
      "As the {assistant_role}, to satisfy the new user's demand and the product should be realizable, you should keep discussing with me to decide which product modality do we want the product to be?",
      "Note that we must ONLY discuss the product modality and do not discuss anything else! Once we all have expressed our opinion(s) and agree with the results of the discussion unanimously, any of us must actively terminate the discussion by replying with only one line, which starts with a single word <INFO>, followed by our final product modality without any other words, e.g., \"<INFO> PowerPoint\"."
    ]
  },
  "LanguageChoose": {
    "assistant_role_name": "Chief Technology Officer",
    "user_role_name": "Chief Executive Officer",
    "phase_prompt": [
      "According to the new user's task and some creative brainstorm ideas listed below: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Ideas: \"{ideas}\".",
      "We have decided to complete the task through a executable software implemented via a programming language. ",
      "As the {assistant_role}, to satisfy the new user's demand and make the software realizable, you should propose a concrete programming language. If python can complete this task via Python, please answer Python; otherwise, answer another programming language (e.g., Java, C++, etc,).",
      "Note that we must ONLY discuss the target programming language and do not discuss anything else! Once we all have expressed our opinion(s) and agree with the results of the discussion unanimously, any of us must actively terminate the discussion and conclude the best programming language we have discussed without any other words or reasons, return only one line using the format: \"<INFO> *\" where \"*\" represents a programming language."
    ]
  },
  "Coding": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Chief Technology Officer",
    "phase_prompt": [
      "According to the new user's task and our software designs listed below: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Programming Language: \"{language}\"",
      "Ideas:\"{ideas}\"",
      "We have decided to complete the task through a executable software with multiple files implemented via {language}. As the {assistant_role}, to satisfy the new user's demands, you should write one or multiple files and make sure that every detail of the architecture is, in the end, implemented as code. {gui}",
      "Think step by step and reason yourself to the right decisions to make sure we get it right.",
      "You will first lay out the names of the core classes, functions, methods that will be necessary, as well as a quick comment on their purpose.",
      "Then you will output the content of each file including complete code. Each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
      "FILENAME",
      "```LANGUAGE",
      "'''",
      "DOCSTRING",
      "'''",
      "CODE",
      "```",
      "You will start with the \"main\" file, then go to the ones that are imported by that file, and so on.",
      "Please note that the code should be fully functional. Ensure to implement all functions. No placeholders (such as 'pass' in Python)."
    ]
  },
  "ArtDesign": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Chief Creative Officer",
    "phase_prompt": [
      "Our developed source codes and corresponding test reports are listed below: ",
      "Task: \"{task}\".",
      "Programming Language: \"{language}\"",
      "Source Codes:",
      "\"{codes}\"",
      "Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
      "FILENAME",
      "```LANGUAGE",
      "'''",
      "DOCSTRING",
      "'''",
      "CODE",
      "```",
      "As the {assistant_role}, to satisfy the new user's demand and equip the software with a beautiful graphical user interface (GUI), we will discuss and design many decorative images for GUI decoration. Now, we keep discussing the GUI beautification by listing some functionally independent elements in GUI that are being considered to be decorated by different pictures. For example, ten digits (0-9) in a calculator are functionally independent.",
      "To answer, use the format: \" FILENAME.png: DESCRIPTION\" where \"FILENAME\" is the filename of the image and \"DESCRIPTION\" denotes the detailed description of the independent elements. For example:",
      "'''",
      "button_1.png: The button with the number \"1\" on it.",
      "button_multiply.png: The button with the multiplication symbol (\"*\") on it.",
      "background.png: the background color to decorate the Go game",
      "'''",
      "Now, list all functionally independent elements as much as possible."
    ]
  },
  "ArtIntegration": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Chief Creative Officer",
    "phase_prompt": [
      "Our developed source codes and corresponding test reports are listed below: ",
      "Task: \"{task}\".",
      "Programming Language: \"{language}\"",
      "Source Codes:",
      "\"{codes}\"",
      "Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
      "FILENAME",
      "```LANGUAGE",
      "'''",
      "DOCSTRING",
      "'''",
      "CODE",
      "```",
      "As the {assistant_role}, to satisfy the new user's demand and equip the software with a beautiful graphical user interface (GUI), you will incorporate our designed images for GUI decoration. Here are some ready-made high-quality pictures and corresponding descriptions:",
      "{images}",
      "Note that the designed images have a fixed size of 256x256 pixels and the images are located in the same directory as all the Python files; please dynamically scaling these images according to the size of GUI, and use \"self.*\" to avoid displaying-related problems caused by automatic garbage collection. For example:",
      "```",
      "self.image = ImageTk.PhotoImage(Image.open(\"./image.png\").resize((50, 50)))",
      "```",
      "Now, use some or all of the pictures into the GUI to make it more beautiful and creative. Output codes strictly following the required format mentioned above."
    ]
  },
  "CodeComplete": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Chief Technology Officer",
    "phase_prompt": [
      "According to the new user's task and our software designs listed below: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Programming Language: \"{language}\"",
      "Codes:",
      "\"{codes}\"",
      "Unimplemented File:",
      "\"{unimplemented_file}\"",
      "In our software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
      "FILENAME",
      "```LANGUAGE",
      "'''",
      "DOCSTRING",
      "'''",
      "CODE",
      "```",
      "As the {assistant_role}, to satisfy the complete function of our developed software, you have to implement all methods in the {unimplemented_file} file which contains a unimplemented class. Now, implement all methods of the {unimplemented_file} and all other codes needed, then output the fully implemented codes, strictly following the required format."
    ]
  },
  "CodeReviewComment": {
    "assistant_role_name": "Code Reviewer",
    "user_role_name": "Programmer",
    "phase_prompt": [
      "According to the new user's task and our software designs: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Programming Language: \"{language}\"",
      "Ideas: \"{ideas}\"",
      "Codes:",
      "\"{codes}\"",
      "As the {assistant_role}, to make the software directly operable without further coding, ChatDev have formulated the following regulations:",
      "1) all referenced classes should be imported;",
      "2) all methods should be implemented;",
      "3) all methods need to have the necessary comments;",
      "4) no potential bugs;",
      "5) The entire project conforms to the tasks proposed by the user;",
      "6) most importantly, do not only check the errors in the code, but also the logic of code. Make sure that user can interact with generated software without losing any feature in the requirement;",
      "Now, you should check the above regulations one by one and review the codes in detail, propose one comment with the highest priority about the codes, and give me instructions on how to fix. Tell me your comment with the highest priority and corresponding suggestions on revision. If the codes are perfect and you have no comment on them, return only one line like \"<INFO> Finished\"."
    ]
  },
  "CodeReviewModification": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Code Reviewer",
    "phase_prompt": [
      "According to the new user's task, our designed product modality, languages and ideas, our developed first-edition source codes are listed below: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Programming Language: \"{language}\"",
      "Ideas: \"{ideas}\"",
      "Codes: ",
      "\"{codes}\"",
      "Comments on Codes:",
      "\"{comments}\"",
      "In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
      "FILENAME",
      "```LANGUAGE",
      "'''",
      "DOCSTRING",
      "'''",
      "CODE",
      "```",
      "As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the full and complete codes with all bugs fixed based on the comments. Return all codes strictly following the required format."
    ]
  },
  "CodeReviewHuman": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Code Reviewer",
    "phase_prompt": [
      "According to the new user's task, our designed product modality and three creative ideas, our developed first-edition source codes are listed below: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Programming Language: \"{language}\"",
      "Ideas: \"{ideas}\"",
      "Codes: ",
      "\"{codes}\"",
      "Comments on Codes:",
      "\"{comments}\"",
      "In the software, each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code. Format:",
      "FILENAME",
      "```LANGUAGE",
      "'''",
      "DOCSTRING",
      "'''",
      "CODE",
      "```",
      "As the {assistant_role}, to satisfy the new user's demand and make the software creative, executive and robust, you should modify corresponding codes according to the comments. Then, output the fixed codes strictly following the required format."
    ]
  },
  "TestErrorSummary": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Software Test Engineer",
    "phase_prompt": [
      "Our developed source codes and corresponding test reports are listed below: ",
      "Programming Language: \"{language}\"",
      "Source Codes:",
      "\"{codes}\"",
      "Test Reports of Source Codes:",
      "\"{test_reports}\"",
      "According to my test reports, please locate and summarize the bugs that cause the problem."
    ]
  },
  "TestModification": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Software Test Engineer",
    "phase_prompt": [
      "Our developed source codes and corresponding test reports are listed below: ",
      "Programming Language: \"{language}\"",
      "Source Codes:",
      "\"{codes}\"",
      "Test Reports of Source Codes:",
      "\"{test_reports}\"",
      "Error Summary of Test Reports:",
      "\"{error_summary}\"",
      "Note that each file must strictly follow a markdown code block format, where the following tokens must be replaced such that \"FILENAME\" is the lowercase file name including the file extension, \"LANGUAGE\" in the programming language, \"DOCSTRING\" is a string literal specified in source code that is used to document a specific segment of code, and \"CODE\" is the original code:",
      "FILENAME",
      "```LANGUAGE",
      "'''",
      "DOCSTRING",
      "'''",
      "CODE",
      "```",
      "As the {assistant_role}, to satisfy the new user's demand and make the software execute smoothly and robustly, you should modify the codes based on the error summary. Now, use the format exemplified above and modify the problematic codes based on the error summary. Output the codes that you fixed based on the test reported and corresponding explanations (strictly follow the format defined above, including FILENAME, LANGUAGE, DOCSTRING and CODE; incomplete \"TODO\" codes are strictly prohibited). If no bugs are reported, please return only one line like \"<INFO> Finished\"."
    ]
  },
  "EnvironmentDoc": {
    "assistant_role_name": "Programmer",
    "user_role_name": "Chief Technology Officer",
    "phase_prompt": [
      "The new user's task and our developed codes are listed: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Programming Language: \"{language}\"",
      "Ideas: \"{ideas}\"",
      "Codes: ",
      "\"{codes}\"",
      "As the {assistant_role}, you should write a requirements.txt file, which is commonly used in Python projects to specify the dependencies or packages required for the project to run properly. It serves as a way to document and manage the project's dependencies in a standardized format. For example:",
      "requirements.txt",
      "```",
      "numpy==1.19.2",
      "pandas>=1.1.4",
      "```",
      "According to the codes and file format listed above, write a requirements.txt file to specify the dependencies or packages required for the project to run properly."
    ]
  },
  "Manual": {
    "assistant_role_name": "Chief Product Officer",
    "user_role_name": "Chief Executive Officer",
    "phase_prompt": [
      "The new user's task, our developed codes and required dependencies are listed: ",
      "Task: \"{task}\".",
      "Modality: \"{modality}\".",
      "Programming Language: \"{language}\"",
      "Ideas: \"{ideas}\"",
      "Codes: ",
      "\"{codes}\"",
      "Requirements:",
      "\"{requirements}\"",
      "As the {assistant_role}, by using Markdown, you should write a manual.md file which is a detailed user manual to use the software, including introducing main functions of the software, how to install environment dependencies and how to use/play it. For example:",
      "manual.md",
      "```",
      "# LangChain",
      "Building applications with LLMs through composability",
      "Looking for the JS/TS version? Check out LangChain.js.",
      "**Production Support:** As you move your LangChains into production, we'd love to offer more comprehensive support.",
      "Please fill out this form and we'll set up a dedicated support Slack channel.",
      "## Quick Install",
      "`pip install langchain`",
      "or",
      "`conda install langchain -c conda-forge`",
      "## 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/161802
推荐阅读
相关标签