99 trajectory: ${ trajectory }
1010 repeat:
1111 text:
12- - def: type
13- text: ${ trajectory.keys()|first }
14- contribute: []
15- - if: ${ type == 'task'}
16- then: |
17- Task:
18- ${ trajectory[type]|trim }
19- - if: ${ type == 'thought'}
20- then:
21- text:
22- - "\n"
23- - |
24- Assistant:
25- <thought>${ trajectory[type]|trim }</thought>
26- - if: ${ type == 'action'}
27- then: |
28- <execute>
29- ${ trajectory[type]|trim }
30- </execute>
31- - if: ${ type == 'observation'}
32- then:
33- text:
34- - "\n"
35- - |
36- Observation:
37- ${ trajectory[type]|trim }
38- - if: ${ type == 'solution'}
39- then: |-
40- <solution>
41- ${ trajectory[type]|trim }
42- </solution>
43- - if: ${ type not in ['question', 'task', 'thought', 'action', 'observation', 'solution'] }
44- then: "${ type }: ${ trajectory[type]|trim }"
12+ - defs:
13+ type:
14+ text: ${ trajectory.keys()|first }
15+ match: ${ type }
16+ with:
17+ - case: task
18+ then: |
19+ Task:
20+ ${ trajectory[type]|trim }
21+ - case: thought
22+ then:
23+ text:
24+ - "\n"
25+ - |
26+ Assistant:
27+ <thought>${ trajectory[type]|trim }</thought>
28+ - case: action
29+ then: |
30+ <execute>
31+ ${ trajectory[type]|trim }
32+ </execute>
33+ - case: observation
34+ then:
35+ text:
36+ - "\n"
37+ - |
38+ Observation:
39+ ${ trajectory[type]|trim }
40+ - case: solution
41+ then: |-
42+ <solution>
43+ ${ trajectory[type]|trim }
44+ </solution>
45+ - if: ${ type not in ['question'] }
46+ then: "${ type }: ${ trajectory[type]|trim }"
4547 - "\n"
4648 react_demos:
4749 data:
7981 def similar_elements(test_tup1, test_tup2):
8082 res = tuple(set(test_tup1) & set(test_tup2))
8183 return res
82- text:
84+ match: ${ prompt_pattern }
85+ with:
8386 # CoT
84- - if: ${ prompt_pattern == ' cot' }
87+ - case: cot
8588 then:
8689 text:
8790 - for:
@@ -104,7 +107,7 @@ text:
104107 temperature: 0
105108
106109 # ReAct
107- - if: ${ prompt_pattern == ' react' }
110+ - case: react
108111 then:
109112 text:
110113 # see https://github.com/xingyaoww/mint-bench/blob/main/mint/tasks/in_context_examples/mbpp/with_tool.txt for prompt
@@ -139,34 +142,32 @@ text:
139142 - repeat:
140143 text:
141144 - repeat:
145+ defs:
146+ iterations: ${ iterations+1 }
147+ def: THOUGHT
142148 text:
149+ - model: ${ model }
150+ def: THOUGHT_inner
151+ parameters:
152+ temperature: ${ temperature }
153+ stop:
154+ - </execute>
155+ - </solution>
156+ - <|endoftext|>
157+ max_tokens: 1024
158+ include_stop_sequences: true
143159 - defs:
144- iterations: ${ iterations+1 }
145- - def: THOUGHT
146- text:
147- - model: ${ model }
148- def: THOUGHT_inner
149- parameters:
150- temperature: ${ temperature }
151- stop:
152- - </execute>
153- - </solution>
154- - <|endoftext|>
155- max_tokens: 1024
156- include_stop_sequences: true
157- - def: thought_trim
158- contribute: []
159- text: ${ THOUGHT_inner|trim|trim('\n') }
160- until: ${ thought_trim.endswith('</solution>') or (thought_trim).endswith('</execute>') or iterations>max_iterations }
161- - if: ${ (thought_trim).endswith('</execute>') }
160+ thought_trim: ${ THOUGHT_inner|trim|trim('\n') }
161+ until: ${ thought_trim.endswith('</solution>') or thought_trim.endswith('</execute>') or iterations>max_iterations }
162+ - if: ${ thought_trim.endswith('</execute>') }
162163 then:
163164 text:
164165 - "\n\nObservation:\n"
165- - def: observation
166- contribute: []
167- lang: ipython
168- code: |
169- ${ thought_trim.split('<execute>')[-1].strip('</execute>\n\n').lstrip('```python').strip('`') or thought_trim }
166+ - defs:
167+ observation:
168+ lang: ipython
169+ code: |
170+ ${ thought_trim.split('<execute>')[-1].strip('</execute>\n\n').lstrip('```python').strip('`') or thought_trim }
170171 - "${ (observation|trim|trim('\n')) if observation is not none else '[Executed Successfully with No Output]' }"
171172 - |-
172173
0 commit comments