Commit
·
f748a3e
1
Parent(s):
6fffc74
Fix bugs, clean code, bring everything up-to-date and standardize a bit more.
Browse files- CF_Code.yaml +3 -2
- CF_CodeCollab.yaml +11 -6
- CF_CodeDebug.yaml +9 -7
- CF_CodeReflect.yaml +7 -2
- CF_CodeTesting.yaml +7 -4
- CF_CodeWithPlan.yaml +3 -3
- CF_Plan.yaml +19 -18
- CF_PlanCollab.yaml +10 -6
- CF_PlanCollab_Code.yaml +8 -1
- CF_PlanReflect.yaml +24 -20
- CF_Plan_Code.yaml +12 -9
- FixedReply_CodeReflect.yaml +11 -11
- FixedReply_PlanReflect.py +6 -0
- FixedReply_PlanReflect.yaml +21 -0
- __init__.py +1 -3
- src/data_transformations/__init__.py +1 -1
- src/data_transformations/correctness_flag.py +1 -2
- src/data_transformations/{test_results_summary_generation.py → testing_results_summary_generation.py} +5 -4
CF_Code.yaml
CHANGED
@@ -65,14 +65,13 @@ query_message_prompt_template:
|
|
65 |
code_placeholder: "{{python_code}}"
|
66 |
template_format: jinja2
|
67 |
|
|
|
68 |
input_keys:
|
69 |
- "problem_description"
|
70 |
- "input_description"
|
71 |
- "output_description"
|
72 |
- "io_examples_and_explanation"
|
73 |
|
74 |
-
output_keys:
|
75 |
-
- "code"
|
76 |
output_data_transformations:
|
77 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
78 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
@@ -82,3 +81,5 @@ output_data_transformations:
|
|
82 |
strip: True
|
83 |
assert_unique: True
|
84 |
verbose: True
|
|
|
|
|
|
65 |
code_placeholder: "{{python_code}}"
|
66 |
template_format: jinja2
|
67 |
|
68 |
+
input_data_transformations: []
|
69 |
input_keys:
|
70 |
- "problem_description"
|
71 |
- "input_description"
|
72 |
- "output_description"
|
73 |
- "io_examples_and_explanation"
|
74 |
|
|
|
|
|
75 |
output_data_transformations:
|
76 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
77 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
|
|
81 |
strip: True
|
82 |
assert_unique: True
|
83 |
verbose: True
|
84 |
+
output_keys:
|
85 |
+
- "code"
|
CF_CodeCollab.yaml
CHANGED
@@ -2,20 +2,24 @@ name: "CodeCollab_Flow"
|
|
2 |
verbose: True
|
3 |
description: "ToDO: add description"
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
input_keys:
|
6 |
- "problem_description"
|
7 |
- "input_description"
|
8 |
- "output_description"
|
9 |
- "io_examples_and_explanation"
|
10 |
|
|
|
|
|
|
|
|
|
11 |
output_keys:
|
12 |
- "code"
|
13 |
-
- "end_of_interaction"
|
14 |
-
|
15 |
-
reset_generator_every_round: False
|
16 |
-
reset_critic_every_round: True
|
17 |
-
max_rounds: 2 # ToDO: To increase to 4
|
18 |
-
early_exit_key: "end_of_interaction"
|
19 |
|
20 |
subflows_config:
|
21 |
- _target_: flows.flow_verse.instantiate_flow
|
@@ -23,6 +27,7 @@ subflows_config:
|
|
23 |
class_name: CF_Code
|
24 |
overrides:
|
25 |
name: "CodeGenerator"
|
|
|
26 |
human_message_prompt_template:
|
27 |
_target_: langchain.PromptTemplate
|
28 |
template: |2-
|
|
|
2 |
verbose: True
|
3 |
description: "ToDO: add description"
|
4 |
|
5 |
+
reset_generator_every_round: False
|
6 |
+
reset_critic_every_round: True
|
7 |
+
max_rounds: 2 # ToDO: To increase to 4
|
8 |
+
early_exit_key: "end_of_interaction"
|
9 |
+
|
10 |
+
input_data_transformations: []
|
11 |
input_keys:
|
12 |
- "problem_description"
|
13 |
- "input_description"
|
14 |
- "output_description"
|
15 |
- "io_examples_and_explanation"
|
16 |
|
17 |
+
output_data_transformations:
|
18 |
+
- _target_: flows.data_transformations.KeyRename
|
19 |
+
old_key2new_key:
|
20 |
+
raw_response.code: "code"
|
21 |
output_keys:
|
22 |
- "code"
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
subflows_config:
|
25 |
- _target_: flows.flow_verse.instantiate_flow
|
|
|
27 |
class_name: CF_Code
|
28 |
overrides:
|
29 |
name: "CodeGenerator"
|
30 |
+
model_name: "gpt-4"
|
31 |
human_message_prompt_template:
|
32 |
_target_: langchain.PromptTemplate
|
33 |
template: |2-
|
CF_CodeDebug.yaml
CHANGED
@@ -7,12 +7,18 @@ reset_critic_every_round: True
|
|
7 |
max_rounds: 2 # ToDo: To increase to 4
|
8 |
early_exit_key: "end_of_interaction"
|
9 |
|
|
|
10 |
input_keys:
|
11 |
- "problem_description"
|
12 |
- "input_description"
|
13 |
- "output_description"
|
14 |
- "io_examples_and_explanation"
|
15 |
- "public_tests_individual_io"
|
|
|
|
|
|
|
|
|
|
|
16 |
output_keys:
|
17 |
- "code"
|
18 |
|
@@ -25,7 +31,7 @@ subflows_config:
|
|
25 |
model_name: "gpt-4"
|
26 |
human_message_prompt_template:
|
27 |
template: |2-
|
28 |
-
{{
|
29 |
|
30 |
|
31 |
Consider the problem statement, the last proposed solution, and its issue. Provide a corrected version of the code that solves the original problem and resolves the issue, without any explanation, in the following format:
|
@@ -33,13 +39,10 @@ subflows_config:
|
|
33 |
{{code_placeholder}}
|
34 |
```
|
35 |
input_variables:
|
36 |
-
-
|
37 |
partial_variables:
|
38 |
code_placeholder: "{{python_code}}"
|
39 |
-
|
40 |
-
- _target_: flows.data_transformations.KeyRename
|
41 |
-
old_key2new_key:
|
42 |
-
"test_results_summary": "query"
|
43 |
output_data_transformations:
|
44 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
45 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
@@ -56,7 +59,6 @@ subflows_config:
|
|
56 |
output_keys:
|
57 |
- "code"
|
58 |
- "end_of_interaction"
|
59 |
-
|
60 |
- _target_: flows.flow_verse.instantiate_flow
|
61 |
repository_id: ${oc.env:CC_FLOWS}
|
62 |
class_name: CF_CodeTesting
|
|
|
7 |
max_rounds: 2 # ToDo: To increase to 4
|
8 |
early_exit_key: "end_of_interaction"
|
9 |
|
10 |
+
input_data_transformations: []
|
11 |
input_keys:
|
12 |
- "problem_description"
|
13 |
- "input_description"
|
14 |
- "output_description"
|
15 |
- "io_examples_and_explanation"
|
16 |
- "public_tests_individual_io"
|
17 |
+
|
18 |
+
output_data_transformations:
|
19 |
+
- _target_: flows.data_transformations.KeyRename
|
20 |
+
old_key2new_key:
|
21 |
+
raw_response.code: "code"
|
22 |
output_keys:
|
23 |
- "code"
|
24 |
|
|
|
31 |
model_name: "gpt-4"
|
32 |
human_message_prompt_template:
|
33 |
template: |2-
|
34 |
+
{{testing_results_summary}}
|
35 |
|
36 |
|
37 |
Consider the problem statement, the last proposed solution, and its issue. Provide a corrected version of the code that solves the original problem and resolves the issue, without any explanation, in the following format:
|
|
|
39 |
{{code_placeholder}}
|
40 |
```
|
41 |
input_variables:
|
42 |
+
- testing_results_summary
|
43 |
partial_variables:
|
44 |
code_placeholder: "{{python_code}}"
|
45 |
+
default_human_input_key: "testing_results_summary"
|
|
|
|
|
|
|
46 |
output_data_transformations:
|
47 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
48 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
|
|
59 |
output_keys:
|
60 |
- "code"
|
61 |
- "end_of_interaction"
|
|
|
62 |
- _target_: flows.flow_verse.instantiate_flow
|
63 |
repository_id: ${oc.env:CC_FLOWS}
|
64 |
class_name: CF_CodeTesting
|
CF_CodeReflect.yaml
CHANGED
@@ -7,11 +7,17 @@ reset_critic_every_round: True
|
|
7 |
max_rounds: 2 # ToDo: To increase to 4
|
8 |
early_exit_key: "end_of_interaction"
|
9 |
|
|
|
10 |
input_keys:
|
11 |
- "problem_description"
|
12 |
- "input_description"
|
13 |
- "output_description"
|
14 |
- "io_examples_and_explanation"
|
|
|
|
|
|
|
|
|
|
|
15 |
output_keys:
|
16 |
- "code"
|
17 |
|
@@ -25,12 +31,11 @@ subflows_config:
|
|
25 |
input_data_transformations:
|
26 |
- _target_: flows.data_transformations.KeyRename
|
27 |
old_key2new_key:
|
28 |
-
|
29 |
output_data_transformations:
|
30 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
31 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
32 |
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
33 |
-
input_key: "raw_response"
|
34 |
output_key: "code"
|
35 |
strip: True
|
36 |
assert_unique: True
|
|
|
7 |
max_rounds: 2 # ToDo: To increase to 4
|
8 |
early_exit_key: "end_of_interaction"
|
9 |
|
10 |
+
input_data_transformations: []
|
11 |
input_keys:
|
12 |
- "problem_description"
|
13 |
- "input_description"
|
14 |
- "output_description"
|
15 |
- "io_examples_and_explanation"
|
16 |
+
|
17 |
+
output_data_transformations:
|
18 |
+
- _target_: flows.data_transformations.KeyRename
|
19 |
+
old_key2new_key:
|
20 |
+
raw_response.code: "code"
|
21 |
output_keys:
|
22 |
- "code"
|
23 |
|
|
|
31 |
input_data_transformations:
|
32 |
- _target_: flows.data_transformations.KeyRename
|
33 |
old_key2new_key:
|
34 |
+
code_reflect_message: "query"
|
35 |
output_data_transformations:
|
36 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
37 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
38 |
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
|
|
39 |
output_key: "code"
|
40 |
strip: True
|
41 |
assert_unique: True
|
CF_CodeTesting.yaml
CHANGED
@@ -1,16 +1,19 @@
|
|
1 |
description: "ToDo: add description"
|
|
|
|
|
2 |
input_keys:
|
3 |
- "code"
|
4 |
- "public_tests_individual_io"
|
|
|
5 |
output_keys:
|
6 |
- "all_tests_passed"
|
7 |
-
- "
|
8 |
output_data_transformations:
|
9 |
- _target_: CC_flows.src.data_transformations.CorrectnessFlag # ToDo: This import style would not work if the flow is synced in the current implementation (the outer directory is a hash and not the name; figure out how to do the import robustly; e.g., using relative imports)
|
10 |
-
input_key: "
|
11 |
output_key: "all_tests_passed"
|
12 |
-
- _target_: CC_flows.src.data_transformations.
|
13 |
-
output_key: "
|
14 |
|
15 |
single_test_error_message: True
|
16 |
|
|
|
1 |
description: "ToDo: add description"
|
2 |
+
|
3 |
+
input_data_transformations: []
|
4 |
input_keys:
|
5 |
- "code"
|
6 |
- "public_tests_individual_io"
|
7 |
+
|
8 |
output_keys:
|
9 |
- "all_tests_passed"
|
10 |
+
- "testing_results_summary"
|
11 |
output_data_transformations:
|
12 |
- _target_: CC_flows.src.data_transformations.CorrectnessFlag # ToDo: This import style would not work if the flow is synced in the current implementation (the outer directory is a hash and not the name; figure out how to do the import robustly; e.g., using relative imports)
|
13 |
+
input_key: "raw_response.public_tests_results"
|
14 |
output_key: "all_tests_passed"
|
15 |
+
- _target_: CC_flows.src.data_transformations.TestingResultsSummaryGeneration
|
16 |
+
output_key: "testing_results_summary"
|
17 |
|
18 |
single_test_error_message: True
|
19 |
|
CF_CodeWithPlan.yaml
CHANGED
@@ -71,6 +71,7 @@ query_message_prompt_template:
|
|
71 |
code_placeholder: "{{python_code}}"
|
72 |
template_format: jinja2
|
73 |
|
|
|
74 |
input_keys:
|
75 |
- "problem_description"
|
76 |
- "input_description"
|
@@ -78,9 +79,6 @@ input_keys:
|
|
78 |
- "io_examples_and_explanation"
|
79 |
- "plan"
|
80 |
|
81 |
-
output_keys:
|
82 |
-
- "code"
|
83 |
-
|
84 |
output_data_transformations:
|
85 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
86 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
@@ -89,3 +87,5 @@ output_data_transformations:
|
|
89 |
strip: True
|
90 |
assert_unique: True
|
91 |
verbose: True
|
|
|
|
|
|
71 |
code_placeholder: "{{python_code}}"
|
72 |
template_format: jinja2
|
73 |
|
74 |
+
input_data_transformations: []
|
75 |
input_keys:
|
76 |
- "problem_description"
|
77 |
- "input_description"
|
|
|
79 |
- "io_examples_and_explanation"
|
80 |
- "plan"
|
81 |
|
|
|
|
|
|
|
82 |
output_data_transformations:
|
83 |
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
84 |
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
|
|
87 |
strip: True
|
88 |
assert_unique: True
|
89 |
verbose: True
|
90 |
+
output_keys:
|
91 |
+
- "code"
|
CF_Plan.yaml
CHANGED
@@ -13,6 +13,25 @@ generation_parameters:
|
|
13 |
frequency_penalty: 0
|
14 |
presence_penalty: 0
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
system_message_prompt_template:
|
17 |
_target_: langchain.PromptTemplate
|
18 |
template: |2-
|
@@ -66,21 +85,3 @@ query_message_prompt_template:
|
|
66 |
plan_placeholder: "{{conceptual_solution}}"
|
67 |
template_format: jinja2
|
68 |
|
69 |
-
input_keys:
|
70 |
-
- "problem_description"
|
71 |
-
- "input_description"
|
72 |
-
- "output_description"
|
73 |
-
- "io_examples_and_explanation"
|
74 |
-
|
75 |
-
output_keys:
|
76 |
-
- "plan"
|
77 |
-
|
78 |
-
output_data_transformations:
|
79 |
-
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
80 |
-
regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
81 |
-
regex_fallback:
|
82 |
-
- '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
83 |
-
output_key: "plan"
|
84 |
-
strip: True
|
85 |
-
assert_unique: True
|
86 |
-
verbose: True
|
|
|
13 |
frequency_penalty: 0
|
14 |
presence_penalty: 0
|
15 |
|
16 |
+
input_data_transformations: []
|
17 |
+
input_keys:
|
18 |
+
- "problem_description"
|
19 |
+
- "input_description"
|
20 |
+
- "output_description"
|
21 |
+
- "io_examples_and_explanation"
|
22 |
+
|
23 |
+
output_data_transformations:
|
24 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
25 |
+
regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
26 |
+
regex_fallback:
|
27 |
+
- '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
28 |
+
output_key: "plan"
|
29 |
+
strip: True
|
30 |
+
assert_unique: True
|
31 |
+
verbose: True
|
32 |
+
output_keys:
|
33 |
+
- "plan"
|
34 |
+
|
35 |
system_message_prompt_template:
|
36 |
_target_: langchain.PromptTemplate
|
37 |
template: |2-
|
|
|
85 |
plan_placeholder: "{{conceptual_solution}}"
|
86 |
template_format: jinja2
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CF_PlanCollab.yaml
CHANGED
@@ -2,20 +2,24 @@ name: "PlanCollab_Flow"
|
|
2 |
verbose: True
|
3 |
description: "ToDO: add description"
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
input_keys:
|
6 |
- "problem_description"
|
7 |
- "input_description"
|
8 |
- "output_description"
|
9 |
- "io_examples_and_explanation"
|
10 |
|
|
|
|
|
|
|
|
|
11 |
output_keys:
|
12 |
- "plan"
|
13 |
-
- "end_of_interaction"
|
14 |
-
|
15 |
-
reset_generator_every_round: False
|
16 |
-
reset_critic_every_round: True
|
17 |
-
max_rounds: 2 # ToDo: To increase to 4
|
18 |
-
early_exit_key: "end_of_interaction"
|
19 |
|
20 |
subflows_config:
|
21 |
- _target_: flows.flow_verse.instantiate_flow
|
|
|
2 |
verbose: True
|
3 |
description: "ToDO: add description"
|
4 |
|
5 |
+
reset_generator_every_round: False
|
6 |
+
reset_critic_every_round: True
|
7 |
+
max_rounds: 2 # ToDo: To increase to 4
|
8 |
+
early_exit_key: "end_of_interaction"
|
9 |
+
|
10 |
+
input_data_transformations: []
|
11 |
input_keys:
|
12 |
- "problem_description"
|
13 |
- "input_description"
|
14 |
- "output_description"
|
15 |
- "io_examples_and_explanation"
|
16 |
|
17 |
+
output_data_transformations:
|
18 |
+
- _target_: flows.data_transformations.KeyRename
|
19 |
+
old_key2new_key:
|
20 |
+
raw_response.plan: "plan"
|
21 |
output_keys:
|
22 |
- "plan"
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
subflows_config:
|
25 |
- _target_: flows.flow_verse.instantiate_flow
|
CF_PlanCollab_Code.yaml
CHANGED
@@ -1,12 +1,19 @@
|
|
1 |
-
name: "
|
2 |
description: "ToDO: add description"
|
3 |
|
|
|
|
|
|
|
4 |
input_keys:
|
5 |
- "problem_description"
|
6 |
- "input_description"
|
7 |
- "output_description"
|
8 |
- "io_examples_and_explanation"
|
9 |
|
|
|
|
|
|
|
|
|
10 |
output_keys:
|
11 |
- "code"
|
12 |
|
|
|
1 |
+
name: "PlanCollab_Code_Flow"
|
2 |
description: "ToDO: add description"
|
3 |
|
4 |
+
early_exit_key: null
|
5 |
+
|
6 |
+
input_data_transformations: []
|
7 |
input_keys:
|
8 |
- "problem_description"
|
9 |
- "input_description"
|
10 |
- "output_description"
|
11 |
- "io_examples_and_explanation"
|
12 |
|
13 |
+
output_data_transformations:
|
14 |
+
- _target_: flows.data_transformations.KeyRename
|
15 |
+
old_key2new_key:
|
16 |
+
raw_response.code: "code"
|
17 |
output_keys:
|
18 |
- "code"
|
19 |
|
CF_PlanReflect.yaml
CHANGED
@@ -7,12 +7,17 @@ reset_critic_every_round: True
|
|
7 |
max_rounds: 2 # ToDo: increase to 4
|
8 |
early_exit_key: "end_of_interaction"
|
9 |
|
|
|
10 |
input_keys:
|
11 |
- "problem_description"
|
12 |
- "input_description"
|
13 |
- "output_description"
|
14 |
- "io_examples_and_explanation"
|
15 |
|
|
|
|
|
|
|
|
|
16 |
output_keys:
|
17 |
- "plan"
|
18 |
|
@@ -21,31 +26,30 @@ subflows_config:
|
|
21 |
repository_id: ${oc.env:CC_FLOWS}
|
22 |
class_name: CF_Plan
|
23 |
overrides:
|
24 |
-
name: "
|
25 |
model_name: "gpt-4"
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
end_of_interaction_string: "Final answer"
|
30 |
-
|
31 |
verbose: True
|
32 |
output_keys:
|
33 |
- "plan"
|
34 |
- "end_of_interaction"
|
|
|
35 |
- _target_: flows.flow_verse.instantiate_flow
|
36 |
repository_id: ${oc.env:CC_FLOWS}
|
37 |
-
class_name:
|
38 |
-
|
39 |
-
name: "PlanFixedReplyCritic"
|
40 |
-
description: "ToDo: Add description"
|
41 |
-
input_keys:
|
42 |
-
- "plan"
|
43 |
-
output_keys:
|
44 |
-
- "query"
|
45 |
-
fixed_reply: |2-
|
46 |
-
Consider the problem statement and the last proposed solution. Are you sure that the solution is provided in the requested format, and crucially, solves the problem?
|
47 |
-
If that is not the case, provide the corrected version of the conceptual solution in the following format:
|
48 |
-
# Conceptual solution
|
49 |
-
{{conceptual_solution}}
|
50 |
-
otherwise, reply:
|
51 |
-
"Final answer."
|
|
|
7 |
max_rounds: 2 # ToDo: increase to 4
|
8 |
early_exit_key: "end_of_interaction"
|
9 |
|
10 |
+
input_data_transformations: []
|
11 |
input_keys:
|
12 |
- "problem_description"
|
13 |
- "input_description"
|
14 |
- "output_description"
|
15 |
- "io_examples_and_explanation"
|
16 |
|
17 |
+
output_data_transformations:
|
18 |
+
- _target_: flows.data_transformations.KeyRename
|
19 |
+
old_key2new_key:
|
20 |
+
raw_response.plan: "plan"
|
21 |
output_keys:
|
22 |
- "plan"
|
23 |
|
|
|
26 |
repository_id: ${oc.env:CC_FLOWS}
|
27 |
class_name: CF_Plan
|
28 |
overrides:
|
29 |
+
name: "PlanGenerator_Flow"
|
30 |
model_name: "gpt-4"
|
31 |
+
input_data_transformations:
|
32 |
+
- _target_: flows.data_transformations.KeyRename
|
33 |
+
old_key2new_key:
|
34 |
+
plan_reflect_message: "query"
|
35 |
+
output_data_transformations:
|
36 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
37 |
+
regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
38 |
+
regex_fallback:
|
39 |
+
- '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
40 |
+
output_key: "plan"
|
41 |
+
strip: True
|
42 |
+
assert_unique: True
|
43 |
+
verbose: True
|
44 |
+
- _target_: flows.data_transformations.EndOfInteraction
|
45 |
end_of_interaction_string: "Final answer"
|
46 |
+
output_key: "end_of_interaction"
|
47 |
verbose: True
|
48 |
output_keys:
|
49 |
- "plan"
|
50 |
- "end_of_interaction"
|
51 |
+
|
52 |
- _target_: flows.flow_verse.instantiate_flow
|
53 |
repository_id: ${oc.env:CC_FLOWS}
|
54 |
+
class_name: FixedReply_PlanReflect
|
55 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CF_Plan_Code.yaml
CHANGED
@@ -3,7 +3,19 @@ description: "ToDO: add description"
|
|
3 |
|
4 |
early_exit_key: null
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
subflows_config:
|
9 |
- _target_: flows.flow_verse.instantiate_flow
|
@@ -16,12 +28,3 @@ subflows_config:
|
|
16 |
class_name: CF_CodeWithPlan
|
17 |
overrides:
|
18 |
model_name: "gpt-4"
|
19 |
-
|
20 |
-
input_keys:
|
21 |
-
- "problem_description"
|
22 |
-
- "input_description"
|
23 |
-
- "output_description"
|
24 |
-
- "io_examples_and_explanation"
|
25 |
-
|
26 |
-
output_keys:
|
27 |
-
- "code"
|
|
|
3 |
|
4 |
early_exit_key: null
|
5 |
|
6 |
+
input_data_transformations: []
|
7 |
+
input_keys:
|
8 |
+
- "problem_description"
|
9 |
+
- "input_description"
|
10 |
+
- "output_description"
|
11 |
+
- "io_examples_and_explanation"
|
12 |
|
13 |
+
output_data_transformations:
|
14 |
+
- _target_: flows.data_transformations.KeyRename
|
15 |
+
old_key2new_key:
|
16 |
+
raw_response.code: "code"
|
17 |
+
output_keys:
|
18 |
+
- "code"
|
19 |
|
20 |
subflows_config:
|
21 |
- _target_: flows.flow_verse.instantiate_flow
|
|
|
28 |
class_name: CF_CodeWithPlan
|
29 |
overrides:
|
30 |
model_name: "gpt-4"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FixedReply_CodeReflect.yaml
CHANGED
@@ -2,24 +2,24 @@ name: "CodeReflectCritic"
|
|
2 |
description: "A flow that prompts the user to reflect on their code and provide a corrected version if necessary."
|
3 |
verbose: True
|
4 |
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
output_keys:
|
9 |
-
- "code_reflect_message"
|
10 |
output_data_transformations:
|
11 |
- _target_: flows.data_transformations.KeyRename
|
12 |
old_key2new_key:
|
13 |
raw_response: "code_reflect_message"
|
|
|
|
|
14 |
|
15 |
fixed_reply: |2-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
|
25 |
|
|
|
2 |
description: "A flow that prompts the user to reflect on their code and provide a corrected version if necessary."
|
3 |
verbose: True
|
4 |
|
5 |
+
input_data_transformations: []
|
6 |
+
input_keys: []
|
7 |
|
|
|
|
|
8 |
output_data_transformations:
|
9 |
- _target_: flows.data_transformations.KeyRename
|
10 |
old_key2new_key:
|
11 |
raw_response: "code_reflect_message"
|
12 |
+
output_keys:
|
13 |
+
- "code_reflect_message"
|
14 |
|
15 |
fixed_reply: |2-
|
16 |
+
Consider the problem statement and the last proposed solution. Are you sure that the solution is provided in the requested format, and crucially, solves the problem?
|
17 |
+
If that is not the case, provide the corrected version of the code in the following format:
|
18 |
+
```python
|
19 |
+
{{python_code}}
|
20 |
+
```
|
21 |
+
otherwise, reply:
|
22 |
+
"Final answer."
|
23 |
|
24 |
|
25 |
|
FixedReply_PlanReflect.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import FixedReplyAtomicFlow
|
2 |
+
|
3 |
+
|
4 |
+
class FixedReply_PlanReflect(FixedReplyAtomicFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
FixedReply_PlanReflect.yaml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "PlanReflectCritic"
|
2 |
+
description: "A flow that prompts the user to reflect on their conceptual solution and provide a corrected version if necessary."
|
3 |
+
verbose: True
|
4 |
+
|
5 |
+
input_data_transformations: []
|
6 |
+
input_keys: []
|
7 |
+
|
8 |
+
output_data_transformations:
|
9 |
+
- _target_: flows.data_transformations.KeyRename
|
10 |
+
old_key2new_key:
|
11 |
+
raw_response: "plan_reflect_message"
|
12 |
+
output_keys:
|
13 |
+
- "plan_reflect_message"
|
14 |
+
|
15 |
+
fixed_reply: |2-
|
16 |
+
Consider the problem statement and the last proposed solution. Are you sure that the solution is provided in the requested format, and crucially, solves the problem?
|
17 |
+
If that is not the case, provide the corrected version of the conceptual solution in the following format:
|
18 |
+
# Conceptual solution
|
19 |
+
{{conceptual_solution}}
|
20 |
+
otherwise, reply:
|
21 |
+
"Final answer."
|
__init__.py
CHANGED
@@ -15,6 +15,7 @@ from .CF_CodeWithPlan import CF_CodeWithPlan
|
|
15 |
from .CF_Plan_Code import CF_Plan_Code
|
16 |
|
17 |
# cf-plan_reflect-code
|
|
|
18 |
from .CF_PlanReflect import CF_PlanReflect
|
19 |
from .CF_PlanReflect_Code import CF_PlanReflect_Code
|
20 |
|
@@ -26,6 +27,3 @@ from .CF_PlanCollab_Code import CF_PlanCollab_Code
|
|
26 |
# cf-code_debug
|
27 |
from .CF_CodeTesting import CF_CodeTesting
|
28 |
from .CF_CodeDebug import CF_CodeDebug
|
29 |
-
|
30 |
-
# from .CF_Debug import CF_Debug
|
31 |
-
# from .CF_CodeTestDebug import CF_CodeTestDebug
|
|
|
15 |
from .CF_Plan_Code import CF_Plan_Code
|
16 |
|
17 |
# cf-plan_reflect-code
|
18 |
+
from .FixedReply_PlanReflect import FixedReply_PlanReflect
|
19 |
from .CF_PlanReflect import CF_PlanReflect
|
20 |
from .CF_PlanReflect_Code import CF_PlanReflect_Code
|
21 |
|
|
|
27 |
# cf-code_debug
|
28 |
from .CF_CodeTesting import CF_CodeTesting
|
29 |
from .CF_CodeDebug import CF_CodeDebug
|
|
|
|
|
|
src/data_transformations/__init__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
from .correctness_flag import CorrectnessFlag
|
2 |
-
from .
|
|
|
1 |
from .correctness_flag import CorrectnessFlag
|
2 |
+
from .testing_results_summary_generation import TestingResultsSummaryGeneration
|
src/data_transformations/correctness_flag.py
CHANGED
@@ -9,7 +9,6 @@ class CorrectnessFlag(DataTransformation):
|
|
9 |
self.input_key = input_key
|
10 |
|
11 |
def __call__(self, data_dict: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
12 |
-
|
13 |
-
all_tests_passed = all([test_result["status"] for test_result in test_data[self.input_key]])
|
14 |
data_dict[self.output_key] = all_tests_passed
|
15 |
return data_dict
|
|
|
9 |
self.input_key = input_key
|
10 |
|
11 |
def __call__(self, data_dict: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
12 |
+
all_tests_passed = all([test_result["status"] for test_result in data_dict[self.input_key]])
|
|
|
13 |
data_dict[self.output_key] = all_tests_passed
|
14 |
return data_dict
|
src/data_transformations/{test_results_summary_generation.py → testing_results_summary_generation.py}
RENAMED
@@ -3,9 +3,10 @@ from typing import Dict, Any
|
|
3 |
import jinja2
|
4 |
|
5 |
from flows.data_transformations.abstract import DataTransformation
|
|
|
6 |
|
7 |
|
8 |
-
class
|
9 |
def __init__(self, output_key, **kwargs):
|
10 |
super().__init__(output_key)
|
11 |
self.params = kwargs
|
@@ -13,10 +14,10 @@ class TestResultsSummaryGeneration(DataTransformation):
|
|
13 |
def __call__(self, data_dict: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
14 |
if data_dict["all_tests_passed"]:
|
15 |
# the execution did not result in any errors
|
16 |
-
data_dict[
|
17 |
return data_dict
|
18 |
|
19 |
-
test_data = data_dict["raw_response"]
|
20 |
|
21 |
if not test_data["compilation_status"]:
|
22 |
# compilation error occurred
|
@@ -98,5 +99,5 @@ class TestResultsSummaryGeneration(DataTransformation):
|
|
98 |
)
|
99 |
|
100 |
message_content = self.params["tests_separator"].join(parts)
|
101 |
-
data_dict[
|
102 |
return data_dict
|
|
|
3 |
import jinja2
|
4 |
|
5 |
from flows.data_transformations.abstract import DataTransformation
|
6 |
+
from flows.utils.general_helpers import unflatten_dict
|
7 |
|
8 |
|
9 |
+
class TestingResultsSummaryGeneration(DataTransformation):
|
10 |
def __init__(self, output_key, **kwargs):
|
11 |
super().__init__(output_key)
|
12 |
self.params = kwargs
|
|
|
14 |
def __call__(self, data_dict: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
15 |
if data_dict["all_tests_passed"]:
|
16 |
# the execution did not result in any errors
|
17 |
+
data_dict[self.output_key] = self.params["no_error_template"]
|
18 |
return data_dict
|
19 |
|
20 |
+
test_data = unflatten_dict(data_dict)["raw_response"]
|
21 |
|
22 |
if not test_data["compilation_status"]:
|
23 |
# compilation error occurred
|
|
|
99 |
)
|
100 |
|
101 |
message_content = self.params["tests_separator"].join(parts)
|
102 |
+
data_dict[self.output_key] = message_content
|
103 |
return data_dict
|