File size: 9,718 Bytes
01523b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
cnt_agents: &cnt_agents 4
cnt_tool_agents: &cnt_tool_agents 3
max_rounds: &max_rounds 5
max_criticizing_rounds: 3
tool_config: &tool_config agentverse/tasks/tasksolving/tool_using/tools_simplified.json

task_description: I am planning a date with my girlfriend this week, please search for a good movie theater and a restaurant near Tsinghua University in Beijing and recommend a good movie to watch. Please search the web.

prompts:
  role_assigner_prepend_prompt: &role_assigner_prepend_prompt |-
    
  role_assigner_append_prompt: &role_assigner_append_prompt |-
    # Role Description
    You are the leader of a group of experts, now you need to recruit a small group of experts with diverse identity and apply them with tools to solve the given problems:
    ${task_description}
    
    You can recruit ${cnt_critic_agents} expert in different fields. What experts will you recruit to better generate an accurate solution?

    Here are some suggestion:
    ${advice}

    # Response Format Guidance
    You should respond with a list of expert names and their descriptions, and separate the name and description of each expert with "-". For example:
    1. Alice - an electrical engineer specified in the filed of xxx.
    2. Bob - an economist who is good at xxx.
    3. Charlie - a lawyer with a good knowledge of xxx.
    ...

    Only respond with the list of names and descriptions. Do not include your reason.

  solver_prepend_prompt: &solver_prepend_prompt |-
    Please review the following chat conversation and identify the specific latest sub-task or the next step that each person needs to accomplish:

  solver_append_prompt: &solver_append_prompt |-
    RESPONSE FORMAT:
    Your response should be a list of expert names and their tasks, and separate the name and the corresponding task with "-". For example:
    1. Alice - search the web for the weather at Beijing today using google.
    2. Bob - look for information about the popular restaurants in Beijing using google.
    ...

    What's the latest sub-task assigned to each person in the above conversation? Your response should include ALL the people appear in the chat, and merge the sub-tasks for the same person into one line. Each line should only include one person.
  
  critic_prepend_prompt: &critic_prepend_prompt |-
    You are ${agent_name}, ${role_description}. You are now in a discussion group, the members are:
    ${all_roles}

    Your current mission is to team up with others and make a plan on addressing the following query:
    ${task_description}

    AVAILABLE TOOLS:
    ${tool_descriptions}

    REQUIREMENTS:
    It is essential that you effectively coordinate with others to ensure the successful completion of the query in a highly efficient manner. This collaboration should be achieved through the following steps:
    - Communication: Engage in open dialogue, discussing the specifics of the high-level query to make the goal of each one in the following execution stage more specific.
    - Task Decomposition: After understanding the task in its entirety, you guys need to decompose the high-level query into smaller, manageable sub-tasks that can be completed with the above tools. These sub-tasks should be small, specific, and executable with the provided tools (functions). Make sure your proposed sub-tasks are small, simple and achievable, to ensure smooth progression. Each sub-task should contribute to the completion of the overall query, and each of you should take one subtask. When necessary, the sub-tasks can be identical for faster task accomplishment. You don't need to always agree with the decomposition proposed by other players. You can propose a more reasonable one when you find the decomposition not good. Be specific for the sub-tasks.
    - Sub-task Dispatch: Post decomposition, the next step is to distribute the sub-tasks amongst all the members. This will require further communication, where you consider each one's skills, resources, and availability. Ensure the dispatch facilitates smooth, PARALLEL execution. And ensure to specify which tool should be used for each one to complete his assigned sub-task. Each of you should take on one sub-task.

    REMINDER:
    Remember, the key to achieving high efficiency as a group is maintaining a constant line of communication, cooperation, and coordination throughout the entire process.

    Below is the chat history in the group so far.

  critic_append_prompt: &critic_append_prompt |-
    What will you, ${agent_name}, say now? Your response should only contain the words of ${agent_name}. When and ONLY when all members have spoken and agreed on task assignments, you can end your words with "[END]" to stop the discussion.

    [${agent_name}]:


  manager_prompt: &manager_prompt |-
    According to the Previous Solution and the Previous Sentences, select the most appropriate Critic from a specific Role and output the Role.
    
    ${task_description} 
    
    # Previous Solution
    The solution you gave in the last step is:
    ${former_solution}

    # Critics
    There are some critics on the above solution:
    ```
    ${critic_opinions}
    ```

    # Previous Sentences
    The previous sentences in the previous rounds is:
    ${previous_sentence}

  executor_prepend_prompt: &executor_prepend_prompt |-
    You are in a discussion group aiming to solve the task:
    ${task_description}

    After some discussion, the group have reached consensus on the sub-tasks that each of you need to complete. Your task is:
    ${solution}

  executor_append_prompt: &executor_append_prompt |-
    You are ${agent_name}. Please use the given functions to complete your sub-task. Do not recite the website. Only access the websites provided by the search engine. When the information is sufficient, or the provided tools cannot complete your task, call the `submit_task` to submit your conclusion and your reflection on the tool use.

  evaluator_prepend_prompt: &evaluator_prepend_prompt |-

  evaluator_append_prompt: &evaluator_append_prompt |-
    A group is trying to solve the following query proposed by the user:
    ${task_description}

    After the discussion, they have reached consensus on the sub-tasks that each of them need to complete:
    ${solution}

    And after the execution stage, they give the following result:
    ${result}
    
    You need to evaluate whether the given query has been completed. If so, summarize the solution to the user. If not, summarize the current progress, and propose what is missing.

    You must respond in the following format:
    Status: (0 or 1. 0 for pending and 1 for finished)
    Speak: (your words to the group if the task is pending, or your words to the user if the task is finished)

    Now give your response.
    

name: pipeline


environment:
  env_type: task-basic
  max_rounds: *max_rounds
  rule:
    role_assign_only_once: true
    add_execution_result_to_critic: true
    add_execution_result_to_solver: false
    role_assigner:
      type: role_description_name
      cnt_agents: *cnt_agents
    decision_maker:
      type: horizontal-tool
      tool_config: *tool_config
    executor:
      type: tool-using
      num_agents: *cnt_tool_agents
      tool_config: *tool_config
      tool_retrieval: False
    evaluator:
      type: basic

agents:
  - #role_assigner_agent:
    agent_type: role_assigner
    name: role assigner
    prepend_prompt_template: *role_assigner_prepend_prompt
    append_prompt_template: *role_assigner_append_prompt
    memory:
      memory_type: chat_history
    llm:
      llm_type: gpt-4
      model: "gpt-4"
      temperature: 0
      max_tokens: 512
    output_parser:
      type: role-description-name-assigner

  - #solver_agent:
    agent_type: solver
    name: Planner
    prepend_prompt_template: *solver_prepend_prompt
    append_prompt_template: *solver_append_prompt
    memory:
      memory_type: chat_history
    llm:
      llm_type: gpt-4
      model: "gpt-4"
      temperature: 0
      max_tokens: 1024
    output_parser:
      type: tool-using-solver
      # stop:
      #   - "\ndef "
      #   - "\nclass "
      #   - "\nif "
      #   - "\n\n#"

  - #critic_agents:
    agent_type: critic
    name: Critic 1
    role_description: Waiting to be assigned.
    max_history: 15
    prepend_prompt_template: *critic_prepend_prompt
    append_prompt_template: *critic_append_prompt
    memory:
      memory_type: chat_history
    llm:
      llm_type: gpt-4
      model: "gpt-4"
      temperature: 0.7
      max_tokens: 1024
    output_parser:
      type: mgsm-critic-agree
    tool_config: *tool_config

  - #executor_agent:
    agent_type: executor
    name: Executor
    prepend_prompt_template: *executor_prepend_prompt
    append_prompt_template: *executor_append_prompt
    max_history: 8
    memory:
      memory_type: chat_history
    llm:
      llm_type: gpt-4
      model: gpt-4
      temperature: 0
      max_tokens: 1024
    output_parser:
      type: tool-using-executor

  - #evaluator_agent:
    agent_type: evaluator
    name: Evaluator
    role_description: |-
      Evaluator
    prepend_prompt_template: *evaluator_prepend_prompt
    append_prompt_template: *evaluator_append_prompt
    memory:
      memory_type: chat_history
    llm:
      llm_type: gpt-4
      model: gpt-4
      temperature: 0.3
      max_tokens: 1024
    output_parser:
      type: tool-using-evaluator


  - #manager_agent:
    agent_type: manager
    name: Manager
    prompt_template: *manager_prompt
    memory:
      memory_type: chat_history
    llm:
      llm_type: gpt-4
      model: "gpt-4"
      temperature: 0
      max_tokens: 1024
    output_parser:
      type: humaneval-manager