yeeef commited on
Commit
28b05f5
1 Parent(s): d9ef54c

partially update CC_flows to be consistent with yeeef_dev

Browse files
CF_Code.py CHANGED
@@ -6,3 +6,5 @@ from flows.application_flows import OpenAIChatAtomicFlow
6
  class CF_Code(OpenAIChatAtomicFlow):
7
  def __init__(self, **kwargs):
8
  super().__init__(**kwargs)
 
 
 
6
  class CF_Code(OpenAIChatAtomicFlow):
7
  def __init__(self, **kwargs):
8
  super().__init__(**kwargs)
9
+
10
+
CF_Code.yaml CHANGED
@@ -81,4 +81,5 @@ output_data_transformations:
81
  assert_unique: True
82
 
83
  output_keys:
 
84
  - "code"
 
81
  assert_unique: True
82
 
83
  output_keys:
84
+ - "api_output"
85
  - "code"
CF_CodeCollab.yaml CHANGED
@@ -2,24 +2,20 @@ name: "CodeCollab_Flow"
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDO: To increase to 4
5
- early_exit_key: "end_of_interaction"
6
 
7
- input_data_transformations: []
8
  input_keys:
9
  - "problem_description"
10
  - "input_description"
11
  - "output_description"
12
  - "io_examples_and_explanation"
13
 
14
- output_data_transformations: []
15
  output_keys:
16
  - "code"
17
 
18
  subflows_config:
19
- - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config
 
20
  overrides:
21
- name: "CodeGenerator"
22
- model_name: "gpt-4"
23
  human_message_prompt_template:
24
  _target_: langchain.PromptTemplate
25
  template: |2-
@@ -38,33 +34,26 @@ subflows_config:
38
  partial_variables:
39
  code_placeholder: "{{python_code}}"
40
  template_format: jinja2
 
41
  input_keys:
42
  - "code_feedback"
43
- output_data_transformations:
44
- - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
45
- regex: '(?<=```python)([\s\S]*?)(?=```)'
46
- regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
47
- input_key: "api_output"
48
- output_key: "code"
49
- strip: True
50
- assert_unique: True
51
-
52
- - _target_: flows.data_transformations.EndOfInteraction
53
- end_of_interaction_string: "Final answer"
54
- input_key: "api_output"
55
- output_key: "end_of_interaction"
 
 
 
 
 
56
 
57
- output_keys:
58
- - "code"
59
- - "end_of_interaction"
60
- - _target_: martinjosifoski.CC_flows.CF_CodeCritic.instantiate_from_default_config
61
- overrides:
62
- name: CodeCritic
63
- output_data_transformations:
64
- - _target_: flows.data_transformations.KeyRename
65
- old_key2new_key:
66
- api_output: "code_feedback"
67
-
68
- reset_every_round:
69
- CodeGenerator: False # this is the name of the subflow, may be different for each config, needs to check !
70
- CodeCritic: True
 
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDO: To increase to 4
 
5
 
 
6
  input_keys:
7
  - "problem_description"
8
  - "input_description"
9
  - "output_description"
10
  - "io_examples_and_explanation"
11
 
 
12
  output_keys:
13
  - "code"
14
 
15
  subflows_config:
16
+ CodeGenerator:
17
+ _target_: .CF_Code.instantiate_from_default_config
18
  overrides:
 
 
19
  human_message_prompt_template:
20
  _target_: langchain.PromptTemplate
21
  template: |2-
 
34
  partial_variables:
35
  code_placeholder: "{{python_code}}"
36
  template_format: jinja2
37
+
38
  input_keys:
39
  - "code_feedback"
40
+ CodeCritic:
41
+ _target_: .CF_CodeCritic.instantiate_from_default_config
42
+
43
+ topology:
44
+ - flow: CodeGenerator
45
+ reset_every_round: false
46
+ output_transformations:
47
+ - _target_: flows.data_transformations.EndOfInteraction
48
+ end_of_interaction_string: "Final answer"
49
+ input_key: "api_output"
50
+ output_key: "end_of_interaction"
51
+
52
+ - flow: CodeCritic
53
+ reset_every_round: true
54
+ output_transformations:
55
+ - _target_: flows.data_transformations.KeyRename
56
+ old_key2new_key:
57
+ api_output: "code_feedback"
58
 
59
+ early_exit_key: "end_of_interaction"
 
 
 
 
 
 
 
 
 
 
 
 
 
CF_CodeCritic.yaml CHANGED
@@ -72,4 +72,4 @@ init_input_keys:
72
  - "output_description"
73
  - "io_examples_and_explanation"
74
  - "code"
75
- output_keys: []
 
72
  - "output_description"
73
  - "io_examples_and_explanation"
74
  - "code"
75
+ output_keys: ["api_output"]
CF_CodeCriticWrongAttempt.yaml CHANGED
@@ -70,7 +70,6 @@ init_human_message_prompt_template:
70
  - "testing_results_summary"
71
  template_format: jinja2
72
 
73
- input_data_transformations: []
74
  init_input_keys:
75
  - "problem_description"
76
  - "input_description"
 
70
  - "testing_results_summary"
71
  template_format: jinja2
72
 
 
73
  init_input_keys:
74
  - "problem_description"
75
  - "input_description"
CF_CodeDebug.yaml CHANGED
@@ -2,9 +2,7 @@ name: "CodeDebug_Flow"
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDo: To increase to 4
5
- early_exit_key: "end_of_interaction"
6
 
7
- input_data_transformations: []
8
  input_keys:
9
  - "problem_description"
10
  - "input_description"
@@ -12,15 +10,12 @@ input_keys:
12
  - "io_examples_and_explanation"
13
  - "public_tests_individual_io"
14
 
15
- output_data_transformations:
16
- - _target_: flows.data_transformations.KeyRename
17
- old_key2new_key:
18
- code: "code"
19
  output_keys:
20
  - "code"
21
 
22
  subflows_config:
23
- - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config
 
24
  overrides:
25
  name: "CodeGenerator"
26
  model_name: "gpt-4"
@@ -39,28 +34,20 @@ subflows_config:
39
  code_placeholder: "{{python_code}}"
40
  input_keys:
41
  - "testing_results_summary"
42
- - "all_tests_passed"
43
- output_data_transformations:
44
- - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
45
- regex: '(?<=```python)([\s\S]*?)(?=```)'
46
- regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
47
- input_key: "api_output"
48
- output_key: "code"
49
- strip: True
50
- assert_unique: True
51
 
52
- - _target_: flows.data_transformations.EndOfInteraction
53
- end_of_interaction_string: "Final answer"
54
- input_key: "api_output"
55
- output_key: "end_of_interaction"
56
 
57
- output_keys:
58
- - "code"
59
- - "end_of_interaction"
60
- - _target_: martinjosifoski.CC_flows.CF_CodeTesting.instantiate_from_default_config
61
- overrides:
62
- name: "CodeTestingCritic"
 
 
63
 
64
- reset_every_round:
65
- CodeGenerator: False # this is the name of the subflow, may be different for each config, needs to check !
66
- CodeTestingCritic: True
 
 
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDo: To increase to 4
 
5
 
 
6
  input_keys:
7
  - "problem_description"
8
  - "input_description"
 
10
  - "io_examples_and_explanation"
11
  - "public_tests_individual_io"
12
 
 
 
 
 
13
  output_keys:
14
  - "code"
15
 
16
  subflows_config:
17
+ CodeGenerator:
18
+ _target_: .CF_Code.instantiate_from_default_config
19
  overrides:
20
  name: "CodeGenerator"
21
  model_name: "gpt-4"
 
34
  code_placeholder: "{{python_code}}"
35
  input_keys:
36
  - "testing_results_summary"
 
 
 
 
 
 
 
 
 
37
 
38
+ CodeTestingCritic:
39
+ _target_: .CF_CodeTesting.instantiate_from_default_config
 
 
40
 
41
+ topology:
42
+ - flow: CodeGenerator
43
+ reset_every_round: false
44
+ output_transformations:
45
+ - _target_: flows.data_transformations.EndOfInteraction
46
+ end_of_interaction_string: "Final answer"
47
+ input_key: "api_output"
48
+ output_key: "end_of_interaction"
49
 
50
+ - flow: CodeTestingCritic
51
+ reset_every_round: true
52
+
53
+ early_exit_key: "end_of_interaction"
CF_CodeDebugCollab.yaml CHANGED
@@ -2,9 +2,7 @@ name: "CodeDebugCollab_Flow"
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDo: To increase to 4
5
- early_exit_key: "end_of_interaction"
6
 
7
- input_data_transformations: []
8
  input_keys:
9
  - "problem_description"
10
  - "input_description"
@@ -12,15 +10,12 @@ input_keys:
12
  - "io_examples_and_explanation"
13
  - "public_tests_individual_io"
14
 
15
- output_data_transformations:
16
- - _target_: flows.data_transformations.KeyRename
17
- old_key2new_key:
18
- code: "code"
19
  output_keys:
20
  - "code"
21
 
22
  subflows_config:
23
- - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config
 
24
  overrides:
25
  name: "CodeGenerator"
26
  model_name: "gpt-4"
@@ -42,29 +37,24 @@ subflows_config:
42
  partial_variables:
43
  code_placeholder: "{{python_code}}"
44
  template_format: jinja2
 
45
  input_keys:
46
  - "code_feedback"
47
  - "testing_results_summary"
48
- output_data_transformations:
49
- - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
50
- regex: '(?<=```python)([\s\S]*?)(?=```)'
51
- regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
52
- input_key: "api_output"
53
- output_key: "code"
54
- strip: True
55
- assert_unique: True
56
-
57
- - _target_: flows.data_transformations.EndOfInteraction
58
- end_of_interaction_string: "Final answer"
59
- input_key: "api_output"
60
- output_key: "end_of_interaction"
 
 
61
 
62
- output_keys:
63
- - "code"
64
- - "end_of_interaction"
65
- - _target_: martinjosifoski.CC_flows.CF_CodeDebugCritic.instantiate_from_default_config
66
-
67
-
68
- reset_every_round:
69
- CodeGenerator: False # this is the name of the subflow, may be different for each config, needs to check !
70
- CodeDebugCritic_Flow: True
 
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDo: To increase to 4
 
5
 
 
6
  input_keys:
7
  - "problem_description"
8
  - "input_description"
 
10
  - "io_examples_and_explanation"
11
  - "public_tests_individual_io"
12
 
 
 
 
 
13
  output_keys:
14
  - "code"
15
 
16
  subflows_config:
17
+ CodeGenerator:
18
+ _target_: .CF_Code.instantiate_from_default_config
19
  overrides:
20
  name: "CodeGenerator"
21
  model_name: "gpt-4"
 
37
  partial_variables:
38
  code_placeholder: "{{python_code}}"
39
  template_format: jinja2
40
+
41
  input_keys:
42
  - "code_feedback"
43
  - "testing_results_summary"
44
+
45
+ CodeDebugCritic:
46
+ _target_: .CF_CodeDebugCritic.instantiate_from_default_config
47
+
48
+ topology:
49
+ - flow: CodeGenerator
50
+ reset_every_round: false
51
+ output_transformations:
52
+ - _target_: flows.data_transformations.EndOfInteraction
53
+ end_of_interaction_string: "Final answer"
54
+ input_key: "api_output"
55
+ output_key: "end_of_interaction"
56
+
57
+ - flow: CodeDebugCritic
58
+ reset_every_round: true
59
 
60
+ early_exit_key: "end_of_interaction"
 
 
 
 
 
 
 
 
CF_CodeDebugCritic.yaml CHANGED
@@ -3,7 +3,6 @@ description: "ToDo: add description"
3
 
4
  early_exit_key: null
5
 
6
- input_data_transformations: []
7
  input_keys:
8
  - "problem_description"
9
  - "input_description"
@@ -12,19 +11,18 @@ input_keys:
12
  - "public_tests_individual_io"
13
  - "code"
14
 
15
- output_data_transformations:
16
- - _target_: flows.data_transformations.KeyRename
17
- old_key2new_key:
18
- testing_results_summary: "testing_results_summary"
19
- all_tests_passed: "all_tests_passed"
20
- code_feedback: "code_feedback"
21
  output_keys:
22
  - "testing_results_summary"
23
  - "all_tests_passed"
24
  - "code_feedback"
25
 
26
  subflows_config:
27
- - _target_: martinjosifoski.CC_flows.CF_CodeTesting.instantiate_from_default_config
28
- overrides:
29
- name: "CodeTestingCritic"
30
- - _target_: martinjosifoski.CC_flows.CF_CodeCriticWrongAttempt.instantiate_from_default_config
 
 
 
 
 
 
3
 
4
  early_exit_key: null
5
 
 
6
  input_keys:
7
  - "problem_description"
8
  - "input_description"
 
11
  - "public_tests_individual_io"
12
  - "code"
13
 
 
 
 
 
 
 
14
  output_keys:
15
  - "testing_results_summary"
16
  - "all_tests_passed"
17
  - "code_feedback"
18
 
19
  subflows_config:
20
+ CodeTestingCritic:
21
+ _target_: .CF_CodeTesting.instantiate_from_default_config
22
+ CodeCriticWrongAttempt:
23
+ _target_: .CF_CodeCriticWrongAttempt.instantiate_from_default_config
24
+
25
+ topology:
26
+ - flow: CodeTestingCritic
27
+ - flow: CodeCriticWrongAttempt
28
+
CF_CodeReflect.yaml CHANGED
@@ -2,52 +2,36 @@ name: "CodeReflect_Flow"
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDo: To increase to 4
5
- early_exit_key: "end_of_interaction"
6
 
7
- input_data_transformations: []
8
  input_keys:
9
  - "problem_description"
10
  - "input_description"
11
  - "output_description"
12
  - "io_examples_and_explanation"
13
 
14
- output_data_transformations:
15
- - _target_: flows.data_transformations.KeyRename
16
- old_key2new_key:
17
- code: "code"
18
  output_keys:
19
  - "code"
20
 
21
  subflows_config:
22
- - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config
23
- overrides:
24
- name: "CodeGenerator"
25
- model_name: "gpt-4"
26
- input_data_transformations:
27
- - _target_: flows.data_transformations.KeyRename
28
- old_key2new_key:
29
- code_reflect_message: "query"
30
- output_data_transformations:
31
- - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
32
- regex: '(?<=```python)([\s\S]*?)(?=```)'
33
- regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
34
- input_key: "api_output"
35
- output_key: "code"
36
- strip: True
37
- assert_unique: True
38
-
39
- - _target_: flows.data_transformations.EndOfInteraction
40
- end_of_interaction_string: "Final answer"
41
- input_key: "api_output"
42
- output_key: "end_of_interaction"
43
-
44
- output_keys:
45
- - "code"
46
- - "end_of_interaction"
47
 
48
- - _target_: martinjosifoski.CC_flows.FixedReply_CodeReflect.instantiate_from_default_config
49
-
50
-
51
- reset_every_round:
52
- CodeGenerator: False # this is the name of the subflow, may be different for each config, needs to check !
53
- CodeReflectCritic: True
 
2
  description: "ToDO: add description"
3
 
4
  max_rounds: 2 # ToDo: To increase to 4
 
5
 
 
6
  input_keys:
7
  - "problem_description"
8
  - "input_description"
9
  - "output_description"
10
  - "io_examples_and_explanation"
11
 
 
 
 
 
12
  output_keys:
13
  - "code"
14
 
15
  subflows_config:
16
+ CodeGenerator:
17
+ _target_: .CF_Code.instantiate_from_default_config
18
+ CodeReflectCritic:
19
+ _target_: .FixedReply_CodeReflect.instantiate_from_default_config
20
+
21
+ topology:
22
+ - flow: CodeGenerator
23
+ reset_every_round: false
24
+ output_transformations:
25
+ - _target_: flows.data_transformations.EndOfInteraction
26
+ end_of_interaction_string: "Final answer"
27
+ input_key: "api_output"
28
+ output_key: "end_of_interaction"
29
+
30
+ - flow: CodeReflectCritic
31
+ reset_every_round: true
32
+ output_transformations:
33
+ - _target_: flows.data_transformations.KeyRename
34
+ old_key2new_key:
35
+ code_reflect_message: "query"
 
 
 
 
 
36
 
37
+ early_exit_key: "end_of_interaction"
 
 
 
 
 
CF_CodeTesting.yaml CHANGED
@@ -1,3 +1,4 @@
 
1
  description: "ToDo: add description"
2
 
3
  input_data_transformations: []
@@ -10,7 +11,7 @@ output_keys:
10
  - "testing_results_summary"
11
  output_data_transformations:
12
  - _target_: martinjosifoski.CC_flows.src.data_transformations.CorrectnessFlag
13
- input_key: "raw_response.public_tests_results"
14
  output_key: "all_tests_passed"
15
  - _target_: martinjosifoski.CC_flows.src.data_transformations.TestingResultsSummaryGeneration
16
  output_key: "testing_results_summary"
 
1
+ name: "CF_CodeTesting"
2
  description: "ToDo: add description"
3
 
4
  input_data_transformations: []
 
11
  - "testing_results_summary"
12
  output_data_transformations:
13
  - _target_: martinjosifoski.CC_flows.src.data_transformations.CorrectnessFlag
14
+ input_key: "public_tests_results"
15
  output_key: "all_tests_passed"
16
  - _target_: martinjosifoski.CC_flows.src.data_transformations.TestingResultsSummaryGeneration
17
  output_key: "testing_results_summary"
CF_Plan_Code.yaml CHANGED
@@ -1,26 +1,25 @@
1
  name: "Plan_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
- code: "code"
17
  output_keys:
18
  - "code"
19
 
20
  subflows_config:
21
- - _target_: martinjosifoski.CC_flows.CF_Plan.instantiate_from_default_config
 
22
  overrides:
23
  model_name: "gpt-4"
24
- - _target_: martinjosifoski.CC_flows.CF_CodeWithPlan.instantiate_from_default_config
 
25
  overrides:
26
  model_name: "gpt-4"
 
 
 
 
 
1
  name: "Plan_Code_Flow"
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
 
13
  subflows_config:
14
+ CF_Plan:
15
+ _target_: martinjosifoski.CC_flows.CF_Plan.instantiate_from_default_config
16
  overrides:
17
  model_name: "gpt-4"
18
+ CF_CodeWithPlan:
19
+ _target_: martinjosifoski.CC_flows.CF_CodeWithPlan.instantiate_from_default_config
20
  overrides:
21
  model_name: "gpt-4"
22
+
23
+ topology:
24
+ - flow: CF_Plan
25
+ - flow: CF_CodeWithPlan
CodeTesting.py CHANGED
@@ -2,7 +2,7 @@ from copy import deepcopy
2
  from typing import Optional, Any, List, Dict
3
 
4
  from flows import logging
5
- from flows.base_flows.abstract import AtomicFlow
6
 
7
  log = logging.get_logger(__name__)
8
 
 
2
  from typing import Optional, Any, List, Dict
3
 
4
  from flows import logging
5
+ from flows.base_flows import AtomicFlow
6
 
7
  log = logging.get_logger(__name__)
8