martinjosifoski
commited on
Commit
•
8a2a1c6
1
Parent(s):
8a7fcb3
Implement LC Flows.
Browse files- LC_Code.py +6 -0
- LC_Code.yaml +81 -0
- LC_CodeCollab.py +6 -0
- LC_CodeCollab.yaml +91 -0
- LC_CodeCritic.py +6 -0
- LC_CodeCritic.yaml +86 -0
- LC_CodeCriticWrongAttempt.py +6 -0
- LC_CodeCriticWrongAttempt.yaml +91 -0
- LC_CodeDebug.py +12 -0
- LC_CodeDebug.yaml +172 -0
- LC_CodeDebugCollab.py +12 -0
- LC_CodeDebugCollab.yaml +89 -0
- LC_CodeDebugCritic.py +13 -0
- LC_CodeDebugCritic.yaml +142 -0
- LC_CodeReflect.py +6 -0
- LC_CodeReflect.yaml +86 -0
- LC_CodeTesting.py +31 -0
- LC_CodeTesting.yaml +11 -0
- LC_CodeWithPlan.py +6 -0
- LC_CodeWithPlan.yaml +90 -0
- LC_Plan.py +6 -0
- LC_Plan.yaml +76 -0
- LC_PlanCollab.py +6 -0
- LC_PlanCollab.yaml +94 -0
- LC_PlanCollab_Code.py +6 -0
- LC_PlanCollab_Code.yaml +67 -0
- LC_PlanCritic.py +6 -0
- LC_PlanCritic.yaml +84 -0
- LC_PlanReflect.py +6 -0
- LC_PlanReflect.yaml +83 -0
- LC_PlanReflect_Code.py +6 -0
- LC_PlanReflect_Code.yaml +67 -0
- LC_Plan_Code.py +6 -0
- LC_Plan_Code.yaml +77 -0
- __init__.py +68 -1
LC_Code.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flow_modules.aiflows.OpenAIChatFlowModule import OpenAIChatAtomicFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_Code(OpenAIChatAtomicFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_Code.yaml
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "Code_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, generate code directly.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface_non_initialized: # Applied when constructing the first user message.
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
|
12 |
+
input_interface_initialized: # Applied when constructing all subsequent user messages.
|
13 |
+
- "query"
|
14 |
+
|
15 |
+
# ~~~ Output interface specification ~~~
|
16 |
+
output_interface:
|
17 |
+
- "api_output"
|
18 |
+
|
19 |
+
# ~~~ Flow specification ~~~
|
20 |
+
model_name: "gpt-4"
|
21 |
+
|
22 |
+
generation_parameters:
|
23 |
+
n: 1
|
24 |
+
max_tokens: 3000
|
25 |
+
temperature: 0.3
|
26 |
+
|
27 |
+
model_kwargs:
|
28 |
+
top_p: 0.2
|
29 |
+
frequency_penalty: 0
|
30 |
+
presence_penalty: 0
|
31 |
+
|
32 |
+
system_message_prompt_template:
|
33 |
+
_target_: langchain.PromptTemplate
|
34 |
+
template: |2-
|
35 |
+
Your goal is to provide executable Python code that solves a coding interview problem. The code should correctly handle all corner cases in order to pass the hidden test cases, which are used to evaluate the correctness of the solution.
|
36 |
+
|
37 |
+
The user will specify the problem by providing you with:
|
38 |
+
- the problem statement
|
39 |
+
- example test cases
|
40 |
+
- the constraints of the problem
|
41 |
+
|
42 |
+
The user will provide you with a task and an output format that you will strictly follow.
|
43 |
+
input_variables: []
|
44 |
+
template_format: jinja2
|
45 |
+
|
46 |
+
human_message_prompt_template:
|
47 |
+
_target_: langchain.PromptTemplate
|
48 |
+
template: "{{query}}"
|
49 |
+
input_variables:
|
50 |
+
- "query"
|
51 |
+
template_format: jinja2
|
52 |
+
|
53 |
+
init_human_message_prompt_template:
|
54 |
+
_target_: langchain.PromptTemplate
|
55 |
+
template: |2-
|
56 |
+
# Problem statement
|
57 |
+
{{problem_description}}
|
58 |
+
|
59 |
+
{{io_description}}
|
60 |
+
|
61 |
+
# Constraints
|
62 |
+
{{constraints}}
|
63 |
+
|
64 |
+
|
65 |
+
Return Python code that solves the problem. The code should extend the following stub:
|
66 |
+
```python
|
67 |
+
{{python_stub}}
|
68 |
+
```
|
69 |
+
without changing the method signatures.
|
70 |
+
Reply in the following format:
|
71 |
+
```python
|
72 |
+
{{code_placeholder}}
|
73 |
+
```
|
74 |
+
input_variables:
|
75 |
+
- "problem_description"
|
76 |
+
- "io_description"
|
77 |
+
- "constraints"
|
78 |
+
- "python_stub"
|
79 |
+
partial_variables:
|
80 |
+
code_placeholder: "{{python_code}}"
|
81 |
+
template_format: jinja2
|
LC_CodeCollab.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import CircularFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeCollab(CircularFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_CodeCollab.yaml
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeCollab_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, alternate between a step in which code is generated, and a step in which the produced code is evaluated and useful feedback is provided.
|
4 |
+
|
5 |
+
max_rounds: 4
|
6 |
+
early_exit_key: "end_of_interaction"
|
7 |
+
|
8 |
+
input_interface:
|
9 |
+
- "problem_description"
|
10 |
+
- "io_description"
|
11 |
+
- "constraints"
|
12 |
+
- "python_stub"
|
13 |
+
output_interface:
|
14 |
+
- "code"
|
15 |
+
|
16 |
+
subflows_config:
|
17 |
+
CodeGenerator:
|
18 |
+
_target_: .LC_Code.instantiate_from_default_config
|
19 |
+
name: "CodeGenerator"
|
20 |
+
human_message_prompt_template:
|
21 |
+
_target_: langchain.PromptTemplate
|
22 |
+
template: |2-
|
23 |
+
# Feedback on the last proposed solution
|
24 |
+
{{code_feedback}}
|
25 |
+
|
26 |
+
|
27 |
+
Consider the original problem statement, the last proposed solution and the provided feedback. Does the solution need to be updated? If so, provide the corrected version of the code in the following format:
|
28 |
+
```python
|
29 |
+
{{code_placeholder}}
|
30 |
+
```
|
31 |
+
otherwise, reply:
|
32 |
+
"Final answer."
|
33 |
+
input_variables:
|
34 |
+
- code_feedback
|
35 |
+
partial_variables:
|
36 |
+
code_placeholder: "{{python_code}}"
|
37 |
+
input_interface_initialized:
|
38 |
+
- "code_feedback"
|
39 |
+
CodeCritic:
|
40 |
+
_target_: .LC_CodeCritic.instantiate_from_default_config
|
41 |
+
|
42 |
+
topology:
|
43 |
+
# ~~~ Code Generator ~~~
|
44 |
+
- goal: "Generate/refine a solution."
|
45 |
+
|
46 |
+
### Input Interface
|
47 |
+
input_interface:
|
48 |
+
_target_: flows.interfaces.KeyInterface
|
49 |
+
additional_transformations:
|
50 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
51 |
+
|
52 |
+
### Flow Specification
|
53 |
+
flow: CodeGenerator
|
54 |
+
|
55 |
+
### Output Interface
|
56 |
+
output_interface:
|
57 |
+
_target_: flows.interfaces.KeyInterface
|
58 |
+
additional_transformations:
|
59 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
60 |
+
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
61 |
+
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
62 |
+
input_key: "api_output"
|
63 |
+
output_key: "code"
|
64 |
+
strip: True
|
65 |
+
assert_unique: True
|
66 |
+
- _target_: flows.data_transformations.EndOfInteraction
|
67 |
+
end_of_interaction_string: "Final answer"
|
68 |
+
input_key: "api_output"
|
69 |
+
output_key: "end_of_interaction"
|
70 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
71 |
+
reset: false
|
72 |
+
|
73 |
+
# ~~~ Code Critic ~~~
|
74 |
+
- goal: "Provide feedback for the candidate solution."
|
75 |
+
|
76 |
+
### Input Interface
|
77 |
+
input_interface:
|
78 |
+
_target_: flows.interfaces.KeyInterface
|
79 |
+
additional_transformations:
|
80 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
81 |
+
|
82 |
+
### Flow Specification
|
83 |
+
flow: CodeCritic
|
84 |
+
|
85 |
+
### Output Interface
|
86 |
+
output_interface:
|
87 |
+
_target_: flows.interfaces.KeyInterface
|
88 |
+
keys_to_rename:
|
89 |
+
api_output: "code_feedback"
|
90 |
+
|
91 |
+
reset: true
|
LC_CodeCritic.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flow_modules.aiflows.OpenAIChatFlowModule import OpenAIChatAtomicFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeCritic(OpenAIChatAtomicFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_CodeCritic.yaml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeCritic_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description and a solution candidate, provide useful feedback concerning the correctness of the solution candidate.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface_non_initialized:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
- "code"
|
12 |
+
|
13 |
+
input_interface_initialized:
|
14 |
+
- "query"
|
15 |
+
|
16 |
+
# ~~~ Output interface specification ~~~
|
17 |
+
output_interface:
|
18 |
+
- "api_output"
|
19 |
+
|
20 |
+
# ~~~ Flow specification ~~~
|
21 |
+
model_name: "gpt-4"
|
22 |
+
|
23 |
+
generation_parameters:
|
24 |
+
n: 1
|
25 |
+
max_tokens: 3000
|
26 |
+
temperature: 0.3
|
27 |
+
|
28 |
+
model_kwargs:
|
29 |
+
top_p: 0.2
|
30 |
+
frequency_penalty: 0
|
31 |
+
presence_penalty: 0
|
32 |
+
|
33 |
+
system_message_prompt_template:
|
34 |
+
_target_: langchain.PromptTemplate
|
35 |
+
template: |2-
|
36 |
+
Your goal is to identify potential issues with a competitive programming solution attempt.
|
37 |
+
|
38 |
+
The user will specify the problem by providing you with:
|
39 |
+
- the problem statement
|
40 |
+
- example test cases
|
41 |
+
- the constraints of the problem
|
42 |
+
- (optional) explanation of the test cases
|
43 |
+
- a Python solution attempt
|
44 |
+
|
45 |
+
Crucially, your goal is to correctly identify potential issues with the solution attempt, and not to provide the code implementation yourself.
|
46 |
+
The user will provide you with a task and an output format that you will strictly follow.
|
47 |
+
input_variables: []
|
48 |
+
template_format: jinja2
|
49 |
+
|
50 |
+
human_message_prompt_template:
|
51 |
+
_target_: langchain.PromptTemplate
|
52 |
+
template: "{{query}}"
|
53 |
+
input_variables:
|
54 |
+
- "query"
|
55 |
+
template_format: jinja2
|
56 |
+
|
57 |
+
init_human_message_prompt_template:
|
58 |
+
_target_: langchain.PromptTemplate
|
59 |
+
template: |2-
|
60 |
+
# Problem statement
|
61 |
+
{{problem_description}}
|
62 |
+
|
63 |
+
{{io_description}}
|
64 |
+
|
65 |
+
# Constraints
|
66 |
+
{{constraints}}
|
67 |
+
|
68 |
+
# code stub
|
69 |
+
```python
|
70 |
+
{{python_stub}}
|
71 |
+
```
|
72 |
+
|
73 |
+
# Python solution attempt
|
74 |
+
```python
|
75 |
+
{{code}}
|
76 |
+
```
|
77 |
+
|
78 |
+
|
79 |
+
Consider the problem statement and the solution attempt. Are there any issues with the proposed solution or it is correct? Explain your reasoning very concisely, and do not provide code.
|
80 |
+
input_variables:
|
81 |
+
- "problem_description"
|
82 |
+
- "io_description"
|
83 |
+
- "constraints"
|
84 |
+
- "python_stub"
|
85 |
+
- "code"
|
86 |
+
template_format: jinja2
|
LC_CodeCriticWrongAttempt.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flow_modules.aiflows.OpenAIChatFlowModule import OpenAIChatAtomicFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeCriticWrongAttempt(OpenAIChatAtomicFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_CodeCriticWrongAttempt.yaml
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeCriticWrongAttempt_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description and an incorrect solution candidate, provide useful feedback for correcting the mistakes in the solution.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface_non_initialized:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
- "testing_results_summary"
|
12 |
+
- "code"
|
13 |
+
|
14 |
+
input_interface_initialized:
|
15 |
+
- "query"
|
16 |
+
|
17 |
+
# ~~~ Output interface specification ~~~
|
18 |
+
output_interface:
|
19 |
+
- "api_output"
|
20 |
+
|
21 |
+
# ~~~ Flow specification ~~~
|
22 |
+
model_name: "gpt-4"
|
23 |
+
|
24 |
+
generation_parameters:
|
25 |
+
n: 1
|
26 |
+
max_tokens: 3000
|
27 |
+
temperature: 0.3
|
28 |
+
|
29 |
+
model_kwargs:
|
30 |
+
top_p: 0.2
|
31 |
+
frequency_penalty: 0
|
32 |
+
presence_penalty: 0
|
33 |
+
|
34 |
+
system_message_prompt_template:
|
35 |
+
_target_: langchain.PromptTemplate
|
36 |
+
template: |2-
|
37 |
+
Your goal is to identify the issues with an incorrect competitive programming solution attempt.
|
38 |
+
|
39 |
+
The user will specify the problem by providing you with:
|
40 |
+
- the problem statement
|
41 |
+
- example test cases
|
42 |
+
- the constraints of the problem
|
43 |
+
- python stub code
|
44 |
+
- an incorrect Python solution attempt and a description of its issue
|
45 |
+
|
46 |
+
Crucially, your goal is to consider all aspects of the problem and pinpoint the issues with the solution attempt, and not to provide the code implementation yourself.
|
47 |
+
Some aspects to consider: Is the input correctly parsed? Is the output correctly formatted? Are the corner cases correctly handled? Is there a logical mistake with the algorithm itself?
|
48 |
+
Use the code execution results provided in the issue description to guide your reasoning/debugging.
|
49 |
+
input_variables: []
|
50 |
+
template_format: jinja2
|
51 |
+
|
52 |
+
human_message_prompt_template:
|
53 |
+
_target_: langchain.PromptTemplate
|
54 |
+
template: "{{query}}"
|
55 |
+
input_variables:
|
56 |
+
- "query"
|
57 |
+
template_format: jinja2
|
58 |
+
|
59 |
+
init_human_message_prompt_template:
|
60 |
+
_target_: langchain.PromptTemplate
|
61 |
+
template: |2-
|
62 |
+
# Problem statement
|
63 |
+
{{problem_description}}
|
64 |
+
|
65 |
+
{{io_description}}
|
66 |
+
|
67 |
+
# Constraints
|
68 |
+
{{constraints}}
|
69 |
+
|
70 |
+
The code should extend the following stub:
|
71 |
+
```python
|
72 |
+
{{python_stub}}
|
73 |
+
```
|
74 |
+
|
75 |
+
# Solution attempt to be fixed
|
76 |
+
```python
|
77 |
+
{{code}}
|
78 |
+
```
|
79 |
+
|
80 |
+
{{testing_results_summary}}
|
81 |
+
|
82 |
+
|
83 |
+
Consider the problem statement, the solution attempt and the issue. Why is the solution attempt incorrect? How should it be fixed? Explain your reasoning very concisely, and do not provide code.
|
84 |
+
input_variables:
|
85 |
+
- "problem_description"
|
86 |
+
- "io_description"
|
87 |
+
- "constraints"
|
88 |
+
- "python_stub"
|
89 |
+
- "code"
|
90 |
+
- "testing_results_summary"
|
91 |
+
template_format: jinja2
|
LC_CodeDebug.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import CircularFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeDebug(CircularFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
7 |
+
|
8 |
+
def _early_exit(self):
|
9 |
+
if self.flow_state.get("all_tests_passed", False):
|
10 |
+
return True
|
11 |
+
|
12 |
+
return super()._early_exit()
|
LC_CodeDebug.yaml
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeDebug_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, generate code, test and refine it until all tests pass or a maximum number of rounds is reached.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
- "public_tests_individual_io"
|
12 |
+
|
13 |
+
# ~~~ Output interface specification ~~~
|
14 |
+
output_interface:
|
15 |
+
- "code"
|
16 |
+
|
17 |
+
# ~~~ Flow specification ~~~
|
18 |
+
max_rounds: 4
|
19 |
+
|
20 |
+
### Subflows specification
|
21 |
+
subflows_config:
|
22 |
+
CodeGenerator:
|
23 |
+
_target_: .LC_Code.instantiate_from_default_config
|
24 |
+
name: "CodeGenerator"
|
25 |
+
model_name: "gpt-4"
|
26 |
+
human_message_prompt_template:
|
27 |
+
template: |2-
|
28 |
+
{{testing_results_summary}}
|
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:
|
32 |
+
```python
|
33 |
+
{{code_placeholder}}
|
34 |
+
```
|
35 |
+
input_variables:
|
36 |
+
- testing_results_summary
|
37 |
+
partial_variables:
|
38 |
+
code_placeholder: "{{python_code}}"
|
39 |
+
|
40 |
+
input_interface_initialized:
|
41 |
+
- "testing_results_summary"
|
42 |
+
CodeTestingCritic:
|
43 |
+
_target_: .LC_CodeTesting.instantiate_from_default_config
|
44 |
+
|
45 |
+
### Topology specification (specifies how the sequence of messages will flow from one of the subflows to another)
|
46 |
+
topology:
|
47 |
+
# ~~~ Code Generator ~~~
|
48 |
+
- goal: "Generate/refine a solution."
|
49 |
+
|
50 |
+
### Input Interface
|
51 |
+
input_interface:
|
52 |
+
_target_: flows.interfaces.KeyInterface
|
53 |
+
additional_transformations:
|
54 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
55 |
+
|
56 |
+
### Flow Specification
|
57 |
+
flow: CodeGenerator
|
58 |
+
|
59 |
+
### Output Interface
|
60 |
+
output_interface:
|
61 |
+
_target_: flows.interfaces.KeyInterface
|
62 |
+
additional_transformations:
|
63 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
64 |
+
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
65 |
+
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
66 |
+
input_key: "api_output"
|
67 |
+
output_key: "code"
|
68 |
+
strip: True
|
69 |
+
assert_unique: True
|
70 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
71 |
+
keys_to_select:
|
72 |
+
- "code"
|
73 |
+
|
74 |
+
### Reset flag
|
75 |
+
reset: false
|
76 |
+
|
77 |
+
# ~~~ Code Testing Critic ~~~
|
78 |
+
- goal: "Test the code on the public tests and provide a results summary."
|
79 |
+
|
80 |
+
### Input Interface
|
81 |
+
input_interface:
|
82 |
+
_target_: flows.interfaces.KeyInterface
|
83 |
+
additional_transformations:
|
84 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
85 |
+
|
86 |
+
### Flow Specification
|
87 |
+
flow: CodeTestingCritic
|
88 |
+
|
89 |
+
### Output Interface
|
90 |
+
output_interface:
|
91 |
+
_target_: flows.interfaces.KeyInterface
|
92 |
+
additional_transformations:
|
93 |
+
- _target_: .src.data_transformations.CorrectnessFlag
|
94 |
+
input_key: "public_tests_results"
|
95 |
+
output_key: "all_tests_passed"
|
96 |
+
- _target_: .src.data_transformations.TestingResultsSummaryGeneration
|
97 |
+
output_key: "testing_results_summary"
|
98 |
+
|
99 |
+
single_test_error_message: True
|
100 |
+
|
101 |
+
no_error_template: |2-
|
102 |
+
${.issue_title}
|
103 |
+
All of the executed tests passed.
|
104 |
+
|
105 |
+
compilation_error_template: |2-
|
106 |
+
${.issue_title}
|
107 |
+
The execution resulted in a compilation error.
|
108 |
+
## Compilation error message:
|
109 |
+
{{error_message}}
|
110 |
+
timeout_error_template: |2-
|
111 |
+
${.issue_title}
|
112 |
+
The execution timed out, the solution is not efficient enough.
|
113 |
+
runtime_error_template: |2-
|
114 |
+
${.issue_title}
|
115 |
+
The execution resulted in a runtime error on the following test.
|
116 |
+
## [Failed test] Input
|
117 |
+
```
|
118 |
+
{{test_input}}
|
119 |
+
```
|
120 |
+
## [Failed test] Runtime error message
|
121 |
+
{{error_message}}
|
122 |
+
single_test_error_template: |2-
|
123 |
+
${.issue_title}
|
124 |
+
The Python code does not solve the problem in the problem description due to logical errors. It fails the following test:
|
125 |
+
## [Failed test] Input
|
126 |
+
```
|
127 |
+
{{test_input}}
|
128 |
+
```
|
129 |
+
## [Failed test] Expected output
|
130 |
+
```
|
131 |
+
{{expected_output}}
|
132 |
+
```
|
133 |
+
## [Failed test] Generated output
|
134 |
+
```
|
135 |
+
{{generated_output}}
|
136 |
+
```
|
137 |
+
all_tests_header: |2-
|
138 |
+
${.issue_title}
|
139 |
+
The Python code does not solve the problem in the problem description due to logical errors. It fails on the following tests.
|
140 |
+
test_error_template: |2-
|
141 |
+
## [Failed test {{idx}}]
|
142 |
+
### [Failed test {{idx}}] Input
|
143 |
+
```
|
144 |
+
{{test_input}}
|
145 |
+
```
|
146 |
+
### [Failed test {{idx}}] Expected output
|
147 |
+
```
|
148 |
+
{{expected_output}}
|
149 |
+
```
|
150 |
+
### [Failed test {{idx}}] Generated output
|
151 |
+
```
|
152 |
+
{{generated_output}}
|
153 |
+
```
|
154 |
+
tests_separator: "\n\n"
|
155 |
+
|
156 |
+
issue_title: "# Issue with the last proposed solution"
|
157 |
+
|
158 |
+
feedback_title: "# Feedback on the last proposed solution"
|
159 |
+
|
160 |
+
no_code_template: |2-
|
161 |
+
${.feedback_title}
|
162 |
+
The code was not provided in the correct output format specified in the request or it was not provided at all.
|
163 |
+
feedback_only_template: |2-
|
164 |
+
${.feedback_title}
|
165 |
+
{{feedback_content}}
|
166 |
+
feedback_and_issue_template: |2-
|
167 |
+
{{issue_description}}
|
168 |
+
|
169 |
+
{{feedback_content}}
|
170 |
+
|
171 |
+
### Reset flag
|
172 |
+
reset: true
|
LC_CodeDebugCollab.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import CircularFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeDebugCollab(CircularFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
7 |
+
|
8 |
+
def _early_exit(self):
|
9 |
+
if self.flow_state.get("all_tests_passed", False):
|
10 |
+
return True
|
11 |
+
|
12 |
+
return super()._early_exit()
|
LC_CodeDebugCollab.yaml
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeDebugCollab_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, alternate between a step in which code is generated, and a step in which the produced code is evaluated and useful feedback is provided.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
- "public_tests_individual_io"
|
12 |
+
|
13 |
+
# ~~~ Output interface specification ~~~
|
14 |
+
output_interface:
|
15 |
+
- "code"
|
16 |
+
|
17 |
+
# ~~~ Flow specification ~~~
|
18 |
+
max_rounds: 4
|
19 |
+
|
20 |
+
subflows_config:
|
21 |
+
CodeGenerator:
|
22 |
+
_target_: .LC_Code.instantiate_from_default_config
|
23 |
+
name: "CodeGenerator"
|
24 |
+
model_name: "gpt-4"
|
25 |
+
human_message_prompt_template:
|
26 |
+
_target_: langchain.PromptTemplate
|
27 |
+
template: |2-
|
28 |
+
{{testing_results_summary}}
|
29 |
+
|
30 |
+
{{code_feedback}}
|
31 |
+
|
32 |
+
|
33 |
+
Consider the problem statement, the last proposed solution, its issue and the provided feedback. Return a corrected version of the code that solves the original problem and resolves the issue, without any explanation, in the following format:
|
34 |
+
```python
|
35 |
+
{{code_placeholder}}
|
36 |
+
```
|
37 |
+
input_variables:
|
38 |
+
- code_feedback
|
39 |
+
- testing_results_summary
|
40 |
+
partial_variables:
|
41 |
+
code_placeholder: "{{python_code}}"
|
42 |
+
input_interface_initialized:
|
43 |
+
- "code_feedback"
|
44 |
+
- "testing_results_summary"
|
45 |
+
CodeDebugCritic:
|
46 |
+
_target_: .LC_CodeDebugCritic.instantiate_from_default_config
|
47 |
+
|
48 |
+
topology:
|
49 |
+
# ~~~ Code Generator ~~~
|
50 |
+
- goal: "Generate/refine a solution."
|
51 |
+
|
52 |
+
### Input Interface
|
53 |
+
input_interface:
|
54 |
+
_target_: flows.interfaces.KeyInterface
|
55 |
+
additional_transformations:
|
56 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
57 |
+
|
58 |
+
### Flow Specification
|
59 |
+
flow: CodeGenerator
|
60 |
+
|
61 |
+
### Output Interface
|
62 |
+
output_interface:
|
63 |
+
_target_: flows.interfaces.KeyInterface
|
64 |
+
additional_transformations:
|
65 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
66 |
+
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
67 |
+
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
68 |
+
input_key: "api_output"
|
69 |
+
output_key: "code"
|
70 |
+
strip: True
|
71 |
+
assert_unique: True
|
72 |
+
keys_to_select:
|
73 |
+
- "code"
|
74 |
+
|
75 |
+
reset: false
|
76 |
+
|
77 |
+
# ~~~ Code Critic Grounded in Tests ~~~
|
78 |
+
- goal: "Provide feedback for the candidate solution that is grounded in test results."
|
79 |
+
|
80 |
+
### Input Interface
|
81 |
+
input_interface:
|
82 |
+
_target_: flows.interfaces.KeyInterface
|
83 |
+
additional_transformations:
|
84 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
85 |
+
|
86 |
+
### Flow Specification
|
87 |
+
flow: CodeDebugCritic
|
88 |
+
|
89 |
+
reset: true
|
LC_CodeDebugCritic.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import SequentialFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeDebugCritic(SequentialFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
7 |
+
|
8 |
+
def _early_exit(self):
|
9 |
+
if self.flow_state.get("all_tests_passed", False):
|
10 |
+
self.flow_state["code_feedback"] = None
|
11 |
+
return True
|
12 |
+
|
13 |
+
return super()._early_exit()
|
LC_CodeDebugCritic.yaml
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeDebugCritic_Flow"
|
2 |
+
description: |-2
|
3 |
+
Given a problem description and a candidate solution, test the code and provide useful feedback concerning the correctness of the solution and the potential mistakes.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
- "public_tests_individual_io"
|
12 |
+
- "code"
|
13 |
+
|
14 |
+
# ~~~ Output interface specification ~~~
|
15 |
+
output_interface:
|
16 |
+
- "testing_results_summary"
|
17 |
+
- "all_tests_passed"
|
18 |
+
- "code_feedback"
|
19 |
+
|
20 |
+
# ~~~ Flow specification ~~~
|
21 |
+
subflows_config:
|
22 |
+
CodeTestingCritic:
|
23 |
+
_target_: .LC_CodeTesting.instantiate_from_default_config
|
24 |
+
CodeCriticWrongAttempt:
|
25 |
+
_target_: .LC_CodeCriticWrongAttempt.instantiate_from_default_config
|
26 |
+
|
27 |
+
topology:
|
28 |
+
# ~~~ Code Testing Critic ~~~
|
29 |
+
- goal: "Test the code on the public tests and provide a results summary."
|
30 |
+
|
31 |
+
### Input Interface
|
32 |
+
input_interface:
|
33 |
+
_target_: flows.interfaces.KeyInterface
|
34 |
+
additional_transformations:
|
35 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
36 |
+
|
37 |
+
### Flow Specification
|
38 |
+
flow: CodeTestingCritic
|
39 |
+
|
40 |
+
### Output Interface
|
41 |
+
output_interface:
|
42 |
+
_target_: flows.interfaces.KeyInterface
|
43 |
+
additional_transformations:
|
44 |
+
- _target_: .src.data_transformations.CorrectnessFlag
|
45 |
+
input_key: "public_tests_results"
|
46 |
+
output_key: "all_tests_passed"
|
47 |
+
- _target_: .src.data_transformations.TestingResultsSummaryGeneration
|
48 |
+
output_key: "testing_results_summary"
|
49 |
+
|
50 |
+
single_test_error_message: True
|
51 |
+
|
52 |
+
no_error_template: |2-
|
53 |
+
${.issue_title}
|
54 |
+
All of the executed tests passed.
|
55 |
+
|
56 |
+
compilation_error_template: |2-
|
57 |
+
${.issue_title}
|
58 |
+
The execution resulted in a compilation error.
|
59 |
+
## Compilation error message:
|
60 |
+
{{error_message}}
|
61 |
+
timeout_error_template: |2-
|
62 |
+
${.issue_title}
|
63 |
+
The execution timed out, the solution is not efficient enough.
|
64 |
+
runtime_error_template: |2-
|
65 |
+
${.issue_title}
|
66 |
+
The execution resulted in a runtime error on the following test.
|
67 |
+
## [Failed test] Input
|
68 |
+
```
|
69 |
+
{{test_input}}
|
70 |
+
```
|
71 |
+
## [Failed test] Runtime error message
|
72 |
+
{{error_message}}
|
73 |
+
single_test_error_template: |2-
|
74 |
+
${.issue_title}
|
75 |
+
The Python code does not solve the problem in the problem description due to logical errors. It fails the following test:
|
76 |
+
## [Failed test] Input
|
77 |
+
```
|
78 |
+
{{test_input}}
|
79 |
+
```
|
80 |
+
## [Failed test] Expected output
|
81 |
+
```
|
82 |
+
{{expected_output}}
|
83 |
+
```
|
84 |
+
## [Failed test] Generated output
|
85 |
+
```
|
86 |
+
{{generated_output}}
|
87 |
+
```
|
88 |
+
all_tests_header: |2-
|
89 |
+
${.issue_title}
|
90 |
+
The Python code does not solve the problem in the problem description due to logical errors. It fails on the following tests.
|
91 |
+
test_error_template: |2-
|
92 |
+
## [Failed test {{idx}}]
|
93 |
+
### [Failed test {{idx}}] Input
|
94 |
+
```
|
95 |
+
{{test_input}}
|
96 |
+
```
|
97 |
+
### [Failed test {{idx}}] Expected output
|
98 |
+
```
|
99 |
+
{{expected_output}}
|
100 |
+
```
|
101 |
+
### [Failed test {{idx}}] Generated output
|
102 |
+
```
|
103 |
+
{{generated_output}}
|
104 |
+
```
|
105 |
+
tests_separator: "\n\n"
|
106 |
+
|
107 |
+
issue_title: "# Issue with the last proposed solution"
|
108 |
+
|
109 |
+
feedback_title: "# Feedback on the last proposed solution"
|
110 |
+
|
111 |
+
no_code_template: |2-
|
112 |
+
${.feedback_title}
|
113 |
+
The code was not provided in the correct output format specified in the request or it was not provided at all.
|
114 |
+
feedback_only_template: |2-
|
115 |
+
${.feedback_title}
|
116 |
+
{{feedback_content}}
|
117 |
+
feedback_and_issue_template: |2-
|
118 |
+
{{issue_description}}
|
119 |
+
|
120 |
+
{{feedback_content}}
|
121 |
+
|
122 |
+
# ~~~ Feedback Generator ~~~
|
123 |
+
- goal: "Generate feedback grounded in the test results summary."
|
124 |
+
|
125 |
+
### Input Interface
|
126 |
+
input_interface:
|
127 |
+
_target_: flows.interfaces.KeyInterface
|
128 |
+
additional_transformations:
|
129 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
130 |
+
|
131 |
+
### Flow Specification
|
132 |
+
flow: CodeCriticWrongAttempt
|
133 |
+
|
134 |
+
### Output Interface
|
135 |
+
output_interface:
|
136 |
+
_target_: flows.interfaces.KeyInterface
|
137 |
+
additional_transformations:
|
138 |
+
- _target_: flows.data_transformations.KeyRename
|
139 |
+
old_key2new_key:
|
140 |
+
api_output: "code_feedback"
|
141 |
+
|
142 |
+
reset: true
|
LC_CodeReflect.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import CircularFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeReflect(CircularFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_CodeReflect.yaml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeReflect_Flow"
|
2 |
+
description: |-2
|
3 |
+
Given a problem description, generate code, reflecting on it and improving it until a message suggesting that the code seems correct or a maximum number of rounds is reached."
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
|
12 |
+
# ~~~ Output interface specification ~~~
|
13 |
+
output_interface:
|
14 |
+
- "code"
|
15 |
+
|
16 |
+
# ~~~ Flow specification ~~~
|
17 |
+
max_rounds: 4
|
18 |
+
|
19 |
+
### Subflows specification
|
20 |
+
subflows_config:
|
21 |
+
CodeGenerator:
|
22 |
+
_target_: .LC_Code.instantiate_from_default_config
|
23 |
+
CodeReflectCritic:
|
24 |
+
_target_: .FixedReply_CodeReflect.instantiate_from_default_config
|
25 |
+
|
26 |
+
### Topology specification (specifies how the sequence of messages will flow from one of the subflows to another)
|
27 |
+
topology:
|
28 |
+
# ~~~ Code Generator ~~~
|
29 |
+
- goal: "Generate/refine a solution."
|
30 |
+
|
31 |
+
### Input Interface
|
32 |
+
input_interface:
|
33 |
+
_target_: flows.interfaces.KeyInterface
|
34 |
+
additional_transformations:
|
35 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
36 |
+
keys_to_rename:
|
37 |
+
code_reflect_message: "query"
|
38 |
+
|
39 |
+
### Flow Specification
|
40 |
+
flow: CodeGenerator
|
41 |
+
|
42 |
+
### Output Interface
|
43 |
+
output_interface:
|
44 |
+
_target_: flows.interfaces.KeyInterface
|
45 |
+
additional_transformations:
|
46 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
47 |
+
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
48 |
+
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
49 |
+
input_key: "api_output"
|
50 |
+
output_key: "code"
|
51 |
+
strip: True
|
52 |
+
assert_unique: True
|
53 |
+
- _target_: flows.data_transformations.EndOfInteraction
|
54 |
+
end_of_interaction_string: "Final answer"
|
55 |
+
input_key: "api_output"
|
56 |
+
output_key: "end_of_interaction"
|
57 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
58 |
+
keys_to_select:
|
59 |
+
- "code"
|
60 |
+
- "end_of_interaction"
|
61 |
+
|
62 |
+
### Reset flag
|
63 |
+
reset: false
|
64 |
+
|
65 |
+
- goal: "Generate a message that encourages reflection."
|
66 |
+
|
67 |
+
### Input Interface
|
68 |
+
input_interface:
|
69 |
+
_target_: flows.interfaces.KeyInterface
|
70 |
+
additional_transformations:
|
71 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
72 |
+
|
73 |
+
|
74 |
+
### Flow Specification
|
75 |
+
flow: CodeReflectCritic
|
76 |
+
|
77 |
+
### Output Interface
|
78 |
+
output_interface:
|
79 |
+
_target_: flows.interfaces.KeyInterface
|
80 |
+
keys_to_rename:
|
81 |
+
fixed_reply: "code_reflect_message"
|
82 |
+
|
83 |
+
### Reset flag
|
84 |
+
reset: true
|
85 |
+
|
86 |
+
early_exit_key: "end_of_interaction"
|
LC_CodeTesting.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any, Dict
|
2 |
+
|
3 |
+
from flows.utils import logging
|
4 |
+
from .src.evaluation import testing_utils_leetcode
|
5 |
+
from .CodeTesting import CodeTesting
|
6 |
+
|
7 |
+
log = logging.get_logger(__name__)
|
8 |
+
|
9 |
+
|
10 |
+
class LC_CodeTesting(CodeTesting):
|
11 |
+
REQUIRED_KEYS_CONFIG = []
|
12 |
+
REQUIRED_KEYS_KWARGS = []
|
13 |
+
|
14 |
+
def __init__(self, **kwargs):
|
15 |
+
super().__init__(**kwargs)
|
16 |
+
|
17 |
+
def _get_test_data(self, input_data: Dict):
|
18 |
+
"""This function retrieves (or generates) input-output pairs that will be used to test the implementation."""
|
19 |
+
return input_data["public_tests_individual_io"]
|
20 |
+
|
21 |
+
def _run_tests(self, input_data: Dict, test_data: Dict) -> Dict[str, Any]:
|
22 |
+
testing_results = testing_utils_leetcode.evaluate_solution_for_problem(
|
23 |
+
candidate_solution=input_data["code"],
|
24 |
+
python_stub=input_data["python_stub"],
|
25 |
+
public_tests_io=test_data
|
26 |
+
)
|
27 |
+
|
28 |
+
for test_output in testing_results["public_tests_results"]:
|
29 |
+
test_output["input"] = "\n".join(test_output["input"])
|
30 |
+
|
31 |
+
return testing_results
|
LC_CodeTesting.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeTesting_Flow"
|
2 |
+
description: "ToDo: add description"
|
3 |
+
|
4 |
+
input_interface:
|
5 |
+
- "code"
|
6 |
+
- "python_stub"
|
7 |
+
- "public_tests_individual_io"
|
8 |
+
|
9 |
+
output_interface:
|
10 |
+
- "all_tests_passed"
|
11 |
+
- "testing_results_summary"
|
LC_CodeWithPlan.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flow_modules.aiflows.OpenAIChatFlowModule import OpenAIChatAtomicFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_CodeWithPlan(OpenAIChatAtomicFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_CodeWithPlan.yaml
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "Code_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, generate code directly.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface_non_initialized: # Applied when constructing the first user message.
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
- "plan"
|
12 |
+
|
13 |
+
input_interface_initialized: # Applied when constructing all subsequent user messages.
|
14 |
+
- "query"
|
15 |
+
|
16 |
+
# ~~~ Output interface specification ~~~
|
17 |
+
output_interface:
|
18 |
+
- "api_output"
|
19 |
+
|
20 |
+
# ~~~ Flow specification ~~~
|
21 |
+
model_name: "gpt-4"
|
22 |
+
|
23 |
+
generation_parameters:
|
24 |
+
n: 1
|
25 |
+
max_tokens: 3000
|
26 |
+
temperature: 0.3
|
27 |
+
|
28 |
+
model_kwargs:
|
29 |
+
top_p: 0.2
|
30 |
+
frequency_penalty: 0
|
31 |
+
presence_penalty: 0
|
32 |
+
|
33 |
+
system_message_prompt_template:
|
34 |
+
_target_: langchain.PromptTemplate
|
35 |
+
template: |2-
|
36 |
+
Your goal is to provide executable Python code that solves a coding interview problem. The code should correctly handle all corner cases in order to pass the hidden test cases, which are used to evaluate the correctness of the solution.
|
37 |
+
|
38 |
+
The user will specify the problem by providing you with:
|
39 |
+
- the problem statement
|
40 |
+
- example test cases
|
41 |
+
- the constraints of the problem
|
42 |
+
|
43 |
+
Additionally, the user will provide you with a conceptual solution to the problem which should guide your reasoning and the code implementation.
|
44 |
+
|
45 |
+
The user will provide you with a task and an output format that you will strictly follow.
|
46 |
+
input_variables: []
|
47 |
+
template_format: jinja2
|
48 |
+
|
49 |
+
human_message_prompt_template:
|
50 |
+
_target_: langchain.PromptTemplate
|
51 |
+
template: "{{query}}"
|
52 |
+
input_variables:
|
53 |
+
- "query"
|
54 |
+
template_format: jinja2
|
55 |
+
|
56 |
+
init_human_message_prompt_template:
|
57 |
+
_target_: langchain.PromptTemplate
|
58 |
+
template: |2-
|
59 |
+
# Problem statement
|
60 |
+
{{problem_description}}
|
61 |
+
|
62 |
+
{{io_description}}
|
63 |
+
|
64 |
+
# Constraints
|
65 |
+
{{constraints}}
|
66 |
+
|
67 |
+
# Conceptual solution
|
68 |
+
{{plan}}
|
69 |
+
|
70 |
+
|
71 |
+
Return Python code that solves the problem. The code should extend the following stub:
|
72 |
+
```python
|
73 |
+
{{python_stub}}
|
74 |
+
```
|
75 |
+
|
76 |
+
without changing the method signatures.
|
77 |
+
Reply in the following format:
|
78 |
+
```python
|
79 |
+
{{code_placeholder}}
|
80 |
+
```
|
81 |
+
```
|
82 |
+
input_variables:
|
83 |
+
- "problem_description"
|
84 |
+
- "io_description"
|
85 |
+
- "constraints"
|
86 |
+
- "python_stub"
|
87 |
+
- "plan"
|
88 |
+
partial_variables:
|
89 |
+
code_placeholder: "{{python_code}}"
|
90 |
+
template_format: jinja2
|
LC_Plan.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flow_modules.aiflows.OpenAIChatFlowModule import OpenAIChatAtomicFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_Plan(OpenAIChatAtomicFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_Plan.yaml
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "Plan_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, generate a high-level solution strategy.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface_non_initialized: # Applied when constructing the first user message.
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
|
11 |
+
input_interface_initialized: # Applied when constructing all subsequent user messages.
|
12 |
+
- "query"
|
13 |
+
|
14 |
+
# ~~~ Output interface specification ~~~
|
15 |
+
output_interface:
|
16 |
+
- "api_output"
|
17 |
+
|
18 |
+
# ~~~ Flow specification ~~~
|
19 |
+
model_name: "gpt-4"
|
20 |
+
generation_parameters:
|
21 |
+
n: 1
|
22 |
+
max_tokens: 3000
|
23 |
+
temperature: 0.3
|
24 |
+
|
25 |
+
model_kwargs:
|
26 |
+
top_p: 0.2
|
27 |
+
frequency_penalty: 0
|
28 |
+
presence_penalty: 0
|
29 |
+
|
30 |
+
system_message_prompt_template:
|
31 |
+
_target_: langchain.PromptTemplate
|
32 |
+
template: |2-
|
33 |
+
Your goal is to provide a high-level conceptual solution that, if implemented, will solve a given coding interview problem.
|
34 |
+
|
35 |
+
The user will specify the problem by providing you with:
|
36 |
+
- the problem statement
|
37 |
+
- example test cases
|
38 |
+
- the constraints of the problem
|
39 |
+
|
40 |
+
The proposed algorithm should be computationally efficient, logically correct and handle all corner cases.
|
41 |
+
|
42 |
+
The user will provide you with a task and an output format that you will strictly follow.
|
43 |
+
input_variables: []
|
44 |
+
template_format: jinja2
|
45 |
+
|
46 |
+
human_message_prompt_template:
|
47 |
+
_target_: langchain.PromptTemplate
|
48 |
+
template: "{{query}}"
|
49 |
+
input_variables:
|
50 |
+
- "query"
|
51 |
+
template_format: jinja2
|
52 |
+
|
53 |
+
init_human_message_prompt_template:
|
54 |
+
_target_: langchain.PromptTemplate
|
55 |
+
template: |2-
|
56 |
+
# Problem statement
|
57 |
+
{{problem_description}}
|
58 |
+
|
59 |
+
{{io_description}}
|
60 |
+
|
61 |
+
# Constraints
|
62 |
+
{{constraints}}
|
63 |
+
|
64 |
+
|
65 |
+
Return a high-level conceptual solution that would solve the problem. Be very concise, and do not provide code.
|
66 |
+
Reply in the following format:
|
67 |
+
# Conceptual solution
|
68 |
+
{{plan_placeholder}}
|
69 |
+
input_variables:
|
70 |
+
- "problem_description"
|
71 |
+
- "io_description"
|
72 |
+
- "constraints"
|
73 |
+
partial_variables:
|
74 |
+
plan_placeholder: "{{conceptual_solution}}"
|
75 |
+
template_format: jinja2
|
76 |
+
|
LC_PlanCollab.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import CircularFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_PlanCollab(CircularFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_PlanCollab.yaml
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "PlanCollab_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, alternate between a step in which a solution strategy is generated, and a step in which the solution strategy is evaluated and useful feedback is provided.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
|
12 |
+
# ~~~ Output interface specification ~~~
|
13 |
+
output_interface:
|
14 |
+
- "plan"
|
15 |
+
|
16 |
+
# ~~~ Flow specification ~~~
|
17 |
+
max_rounds: 4
|
18 |
+
early_exit_key: "end_of_interaction"
|
19 |
+
|
20 |
+
subflows_config:
|
21 |
+
PlanGenerator:
|
22 |
+
_target_: .LC_Plan.instantiate_from_default_config
|
23 |
+
human_message_prompt_template:
|
24 |
+
_target_: langchain.PromptTemplate
|
25 |
+
template: |2-
|
26 |
+
# Feedback on the last proposed conceptual solution
|
27 |
+
{{plan_feedback}}
|
28 |
+
|
29 |
+
|
30 |
+
Consider the original problem statement, the last proposed solution and the provided feedback. Does the solution need to be updated? If so, provide the corrected version of the conceptual solution in the following format:
|
31 |
+
# Conceptual solution
|
32 |
+
{{plan_placeholder}}
|
33 |
+
otherwise, reply:
|
34 |
+
"Final answer."
|
35 |
+
input_variables:
|
36 |
+
- plan_feedback
|
37 |
+
partial_variables:
|
38 |
+
plan_placeholder: "{{conceptual_solution}}"
|
39 |
+
template_format: jinja2
|
40 |
+
input_interface_initialized:
|
41 |
+
- "plan_feedback"
|
42 |
+
PlanCritic:
|
43 |
+
_target_: .LC_PlanCritic.instantiate_from_default_config
|
44 |
+
|
45 |
+
topology:
|
46 |
+
# ~~~ Plan Generator ~~~
|
47 |
+
- goal: "Generate/refine a solution."
|
48 |
+
|
49 |
+
### Input Interface
|
50 |
+
input_interface:
|
51 |
+
_target_: flows.interfaces.KeyInterface
|
52 |
+
additional_transformations:
|
53 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
54 |
+
|
55 |
+
### Flow Specification
|
56 |
+
flow: PlanGenerator
|
57 |
+
|
58 |
+
### Output Interface
|
59 |
+
output_interface:
|
60 |
+
_target_: flows.interfaces.KeyInterface
|
61 |
+
additional_transformations:
|
62 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
63 |
+
regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
64 |
+
regex_fallback:
|
65 |
+
- '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
66 |
+
input_key: "api_output"
|
67 |
+
output_key: "plan"
|
68 |
+
strip: True
|
69 |
+
assert_unique: True
|
70 |
+
- _target_: flows.data_transformations.EndOfInteraction
|
71 |
+
end_of_interaction_string: "Final answer"
|
72 |
+
input_key: "api_output"
|
73 |
+
output_key: "end_of_interaction"
|
74 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
75 |
+
reset: false
|
76 |
+
# ~~~ Plan Critic ~~~
|
77 |
+
- goal: "Provide feedback for the candidate solution."
|
78 |
+
|
79 |
+
### Input Interface
|
80 |
+
input_interface:
|
81 |
+
_target_: flows.interfaces.KeyInterface
|
82 |
+
additional_transformations:
|
83 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
84 |
+
|
85 |
+
### Flow Specification
|
86 |
+
flow: PlanCritic
|
87 |
+
|
88 |
+
### Output Interface
|
89 |
+
output_interface:
|
90 |
+
_target_: flows.interfaces.KeyInterface
|
91 |
+
keys_to_rename:
|
92 |
+
api_output: "plan_feedback"
|
93 |
+
|
94 |
+
reset: true
|
LC_PlanCollab_Code.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import SequentialFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_PlanCollab_Code(SequentialFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_PlanCollab_Code.yaml
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "PlanCollab_Code_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, first generate a solution strategy in collaboration with at critic, and then implement the code.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
|
12 |
+
# ~~~ Output interface specification ~~~
|
13 |
+
output_interface:
|
14 |
+
- "code"
|
15 |
+
|
16 |
+
subflows_config:
|
17 |
+
PlanGenerator:
|
18 |
+
_target_: .LC_PlanCollab.instantiate_from_default_config
|
19 |
+
CodeGenerator:
|
20 |
+
_target_: .LC_CodeWithPlan.instantiate_from_default_config
|
21 |
+
|
22 |
+
### Topology specification (specifies how the sequence of messages will flow from one of the subflows to another)
|
23 |
+
topology:
|
24 |
+
# ~~~ Plan Generator ~~~
|
25 |
+
- goal: "Generate a plan and reflect on it."
|
26 |
+
|
27 |
+
### Input Interface
|
28 |
+
input_interface:
|
29 |
+
_target_: flows.interfaces.KeyInterface
|
30 |
+
additional_transformations:
|
31 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
32 |
+
|
33 |
+
### Flow Specification
|
34 |
+
flow: PlanGenerator
|
35 |
+
|
36 |
+
### Output Interface
|
37 |
+
output_interface:
|
38 |
+
_target_: flows.interfaces.KeyInterface
|
39 |
+
keys_to_select:
|
40 |
+
- "plan"
|
41 |
+
|
42 |
+
# ~~~ Code Generator ~~~
|
43 |
+
- goal: "Generate/refine a solution."
|
44 |
+
|
45 |
+
### Input Interface
|
46 |
+
input_interface:
|
47 |
+
_target_: flows.interfaces.KeyInterface
|
48 |
+
additional_transformations:
|
49 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
50 |
+
|
51 |
+
### Flow Specification
|
52 |
+
flow: CodeGenerator
|
53 |
+
|
54 |
+
### Output Interface
|
55 |
+
output_interface:
|
56 |
+
_target_: flows.interfaces.KeyInterface
|
57 |
+
additional_transformations:
|
58 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
59 |
+
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
60 |
+
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
61 |
+
input_key: "api_output"
|
62 |
+
output_key: "code"
|
63 |
+
strip: True
|
64 |
+
assert_unique: True
|
65 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
66 |
+
keys_to_select:
|
67 |
+
- "code"
|
LC_PlanCritic.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flow_modules.aiflows.OpenAIChatFlowModule import OpenAIChatAtomicFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_PlanCritic(OpenAIChatAtomicFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_PlanCritic.yaml
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "PlanCritic_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description and a solution strategy candidate, provide useful feedback concerning its correctness.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface_non_initialized:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
- "plan"
|
12 |
+
|
13 |
+
input_interface_initialized:
|
14 |
+
- "query"
|
15 |
+
|
16 |
+
# ~~~ Output interface specification ~~~
|
17 |
+
output_interface:
|
18 |
+
- "api_output"
|
19 |
+
|
20 |
+
# ~~~ Flow specification ~~~
|
21 |
+
model_name: "gpt-4"
|
22 |
+
|
23 |
+
generation_parameters:
|
24 |
+
n: 1
|
25 |
+
max_tokens: 3000
|
26 |
+
temperature: 0.3
|
27 |
+
|
28 |
+
model_kwargs:
|
29 |
+
top_p: 0.2
|
30 |
+
frequency_penalty: 0
|
31 |
+
presence_penalty: 0
|
32 |
+
|
33 |
+
system_message_prompt_template:
|
34 |
+
_target_: langchain.PromptTemplate
|
35 |
+
template: |2-
|
36 |
+
Your goal is to identify potential issues with a conceptual solution to a given competitive programming problem.
|
37 |
+
|
38 |
+
The user will specify the problem by providing you with:
|
39 |
+
- the problem statement
|
40 |
+
- example test cases
|
41 |
+
- the constraints of the problem
|
42 |
+
- a conceptual solution attempt
|
43 |
+
|
44 |
+
Crucially, your goal is to consider all aspects of the problem and pinpoint potential issues with the conceptual solution attempt (if any), and not to provide the conceptual solution or the code implementation yourself.
|
45 |
+
Some aspects to consider: Are there any logical mistakes with the proposed algorithm? Are the corner cases correctly handled?
|
46 |
+
The user will provide you with a task and an output format that you will strictly follow.
|
47 |
+
input_variables: []
|
48 |
+
template_format: jinja2
|
49 |
+
|
50 |
+
human_message_prompt_template:
|
51 |
+
_target_: langchain.PromptTemplate
|
52 |
+
template: "{{query}}"
|
53 |
+
input_variables:
|
54 |
+
- "query"
|
55 |
+
template_format: jinja2
|
56 |
+
|
57 |
+
init_human_message_prompt_template:
|
58 |
+
_target_: langchain.PromptTemplate
|
59 |
+
template: |2-
|
60 |
+
# Problem statement
|
61 |
+
{{problem_description}}
|
62 |
+
|
63 |
+
{{io_description}}
|
64 |
+
|
65 |
+
# Constraints
|
66 |
+
{{constraints}}
|
67 |
+
|
68 |
+
# code stub
|
69 |
+
```python
|
70 |
+
{{python_stub}}
|
71 |
+
```
|
72 |
+
|
73 |
+
# Conceptual solution attempt
|
74 |
+
{{plan}}
|
75 |
+
|
76 |
+
|
77 |
+
Consider the problem statement and the solution attempt. Are there any issues with the proposed conceptual solution or it is correct? Explain your reasoning very concisely.
|
78 |
+
input_variables:
|
79 |
+
- "problem_description"
|
80 |
+
- "io_description"
|
81 |
+
- "constraints"
|
82 |
+
- "python_stub"
|
83 |
+
- "plan"
|
84 |
+
template_format: jinja2
|
LC_PlanReflect.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import CircularFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_PlanReflect(CircularFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_PlanReflect.yaml
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "CodeReflect_Flow"
|
2 |
+
description: |-2
|
3 |
+
Given a problem description, generate code, reflect on it and improve it until a message suggesting that the code seems correct or a maximum number of rounds is reached.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
|
11 |
+
# ~~~ Output interface specification ~~~
|
12 |
+
output_interface:
|
13 |
+
- "plan"
|
14 |
+
|
15 |
+
# ~~~ Flow specification ~~~
|
16 |
+
max_rounds: 4
|
17 |
+
early_exit_key: "end_of_interaction"
|
18 |
+
|
19 |
+
subflows_config:
|
20 |
+
PlanGenerator:
|
21 |
+
_target_: .LC_Plan.instantiate_from_default_config
|
22 |
+
PlanReflectCritic:
|
23 |
+
_target_: .FixedReply_PlanReflect.instantiate_from_default_config
|
24 |
+
|
25 |
+
### Topology specification (specifies how the sequence of messages will flow from one of the subflows to another)
|
26 |
+
topology:
|
27 |
+
# ~~~ Plan Generator ~~~
|
28 |
+
- goal: "Generate/refine a plan."
|
29 |
+
|
30 |
+
### Input Interface
|
31 |
+
input_interface:
|
32 |
+
_target_: flows.interfaces.KeyInterface
|
33 |
+
additional_transformations:
|
34 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
35 |
+
keys_to_rename:
|
36 |
+
plan_reflect_message: "query"
|
37 |
+
|
38 |
+
### Flow Specification
|
39 |
+
flow: PlanGenerator
|
40 |
+
|
41 |
+
### Output Interface
|
42 |
+
output_interface:
|
43 |
+
_target_: flows.interfaces.KeyInterface
|
44 |
+
additional_transformations:
|
45 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
46 |
+
regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
47 |
+
regex_fallback:
|
48 |
+
- '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
49 |
+
input_key: "api_output"
|
50 |
+
output_key: "plan"
|
51 |
+
strip: True
|
52 |
+
assert_unique: True
|
53 |
+
- _target_: flows.data_transformations.EndOfInteraction
|
54 |
+
end_of_interaction_string: "Final answer"
|
55 |
+
input_key: "api_output"
|
56 |
+
output_key: "end_of_interaction"
|
57 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
58 |
+
keys_to_select:
|
59 |
+
- "plan"
|
60 |
+
- "end_of_interaction"
|
61 |
+
|
62 |
+
### Reset flag
|
63 |
+
reset: false
|
64 |
+
|
65 |
+
- goal: "Generate a message that encourages reflection."
|
66 |
+
|
67 |
+
### Input Interface
|
68 |
+
input_interface:
|
69 |
+
_target_: flows.interfaces.KeyInterface
|
70 |
+
additional_transformations:
|
71 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
72 |
+
|
73 |
+
### Flow Specification
|
74 |
+
flow: PlanReflectCritic
|
75 |
+
|
76 |
+
### Output Interface
|
77 |
+
output_interface:
|
78 |
+
_target_: flows.interfaces.KeyInterface
|
79 |
+
keys_to_rename:
|
80 |
+
fixed_reply: "plan_reflect_message"
|
81 |
+
|
82 |
+
### Reset flag
|
83 |
+
reset: true
|
LC_PlanReflect_Code.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import SequentialFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_PlanReflect_Code(SequentialFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_PlanReflect_Code.yaml
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "Plan_Code_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, first generate a solution strategy, reflect on it, and then implement the code.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
|
12 |
+
# ~~~ Output interface specification ~~~
|
13 |
+
output_interface:
|
14 |
+
- "code"
|
15 |
+
|
16 |
+
subflows_config:
|
17 |
+
PlanGenerator:
|
18 |
+
_target_: .LC_PlanReflect.instantiate_from_default_config
|
19 |
+
CodeGenerator:
|
20 |
+
_target_: .LC_CodeWithPlan.instantiate_from_default_config
|
21 |
+
|
22 |
+
### Topology specification (specifies how the sequence of messages will flow from one of the subflows to another)
|
23 |
+
topology:
|
24 |
+
# ~~~ Plan Generator ~~~
|
25 |
+
- goal: "Generate a plan and reflect on it."
|
26 |
+
|
27 |
+
### Input Interface
|
28 |
+
input_interface:
|
29 |
+
_target_: flows.interfaces.KeyInterface
|
30 |
+
additional_transformations:
|
31 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
32 |
+
|
33 |
+
### Flow Specification
|
34 |
+
flow: PlanGenerator
|
35 |
+
|
36 |
+
### Output Interface
|
37 |
+
output_interface:
|
38 |
+
_target_: flows.interfaces.KeyInterface
|
39 |
+
keys_to_select:
|
40 |
+
- "plan"
|
41 |
+
|
42 |
+
# ~~~ Code Generator ~~~
|
43 |
+
- goal: "Generate/refine a solution."
|
44 |
+
|
45 |
+
### Input Interface
|
46 |
+
input_interface:
|
47 |
+
_target_: flows.interfaces.KeyInterface
|
48 |
+
additional_transformations:
|
49 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
50 |
+
|
51 |
+
### Flow Specification
|
52 |
+
flow: CodeGenerator
|
53 |
+
|
54 |
+
### Output Interface
|
55 |
+
output_interface:
|
56 |
+
_target_: flows.interfaces.KeyInterface
|
57 |
+
additional_transformations:
|
58 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
59 |
+
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
60 |
+
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
61 |
+
input_key: "api_output"
|
62 |
+
output_key: "code"
|
63 |
+
strip: True
|
64 |
+
assert_unique: True
|
65 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
66 |
+
keys_to_select:
|
67 |
+
- "code"
|
LC_Plan_Code.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flows.base_flows import SequentialFlow
|
2 |
+
|
3 |
+
|
4 |
+
class LC_Plan_Code(SequentialFlow):
|
5 |
+
def __init__(self, **kwargs):
|
6 |
+
super().__init__(**kwargs)
|
LC_Plan_Code.yaml
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: "Plan_Code_Flow"
|
2 |
+
description: |2-
|
3 |
+
Given a problem description, first generate a solution strategy and then implement the code.
|
4 |
+
|
5 |
+
# ~~~ Input interface specification ~~~
|
6 |
+
input_interface:
|
7 |
+
- "problem_description"
|
8 |
+
- "io_description"
|
9 |
+
- "constraints"
|
10 |
+
- "python_stub"
|
11 |
+
|
12 |
+
# ~~~ Output interface specification ~~~
|
13 |
+
output_interface:
|
14 |
+
- "code"
|
15 |
+
|
16 |
+
subflows_config:
|
17 |
+
PlanGenerator:
|
18 |
+
_target_: .LC_Plan.instantiate_from_default_config
|
19 |
+
CodeGenerator:
|
20 |
+
_target_: .LC_CodeWithPlan.instantiate_from_default_config
|
21 |
+
|
22 |
+
### Topology specification (specifies how the sequence of messages will flow from one of the subflows to another)
|
23 |
+
topology:
|
24 |
+
# ~~~ Code Testing Critic ~~~
|
25 |
+
- goal: "Test the code on the public tests and provide a results summary."
|
26 |
+
|
27 |
+
### Input Interface
|
28 |
+
input_interface:
|
29 |
+
_target_: flows.interfaces.KeyInterface
|
30 |
+
additional_transformations:
|
31 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
32 |
+
|
33 |
+
### Flow Specification
|
34 |
+
flow: PlanGenerator
|
35 |
+
|
36 |
+
### Output Interface
|
37 |
+
output_interface:
|
38 |
+
_target_: flows.interfaces.KeyInterface
|
39 |
+
additional_transformations:
|
40 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
41 |
+
regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
42 |
+
regex_fallback:
|
43 |
+
- '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)'
|
44 |
+
input_key: "api_output"
|
45 |
+
output_key: "plan"
|
46 |
+
strip: True
|
47 |
+
assert_unique: True
|
48 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
49 |
+
keys_to_select:
|
50 |
+
- "plan"
|
51 |
+
|
52 |
+
# ~~~ Code Generator ~~~
|
53 |
+
- goal: "Generate/refine a solution."
|
54 |
+
|
55 |
+
### Input Interface
|
56 |
+
input_interface:
|
57 |
+
_target_: flows.interfaces.KeyInterface
|
58 |
+
additional_transformations:
|
59 |
+
- _target_: flows.data_transformations.KeyMatchInput
|
60 |
+
|
61 |
+
### Flow Specification
|
62 |
+
flow: CodeGenerator
|
63 |
+
|
64 |
+
### Output Interface
|
65 |
+
output_interface:
|
66 |
+
_target_: flows.interfaces.KeyInterface
|
67 |
+
additional_transformations:
|
68 |
+
- _target_: flows.data_transformations.RegexFirstOccurrenceExtractor
|
69 |
+
regex: '(?<=```python)([\s\S]*?)(?=```)'
|
70 |
+
regex_fallback: '(?<=```)([\s\S]*?)(?=```)'
|
71 |
+
input_key: "api_output"
|
72 |
+
output_key: "code"
|
73 |
+
strip: True
|
74 |
+
assert_unique: True
|
75 |
+
- _target_: flows.data_transformations.PrintPreviousMessages
|
76 |
+
keys_to_select:
|
77 |
+
- "code"
|
__init__.py
CHANGED
@@ -1,3 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# ~~~ Codeforces ~~~
|
2 |
# code
|
3 |
from .CF_Code import CF_Code
|
@@ -14,7 +25,63 @@ from .CF_CodeCollab import CF_CodeCollab
|
|
14 |
from .CF_CodeTesting import CF_CodeTesting
|
15 |
from .CF_CodeDebug import CF_CodeDebug
|
16 |
|
17 |
-
#
|
18 |
from .CF_CodeCriticWrongAttempt import CF_CodeCriticWrongAttempt
|
19 |
from .CF_CodeDebugCritic import CF_CodeDebugCritic
|
20 |
from .CF_CodeDebugCollab import CF_CodeDebugCollab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ~~~ Specify the dependencies ~~~
|
2 |
+
dependencies = [
|
3 |
+
{"url": "aiflows/OpenAIChatFlowModule", "revision": "6a1e351a915f00193f18f3da3b61c497df1d31a3"},
|
4 |
+
{"url": "aiflows/FixedReplyFlowModule", "revision": "65fbdbe19f5a8fdc48810810812552c5674d35a5"},
|
5 |
+
]
|
6 |
+
|
7 |
+
from flows import flow_verse
|
8 |
+
|
9 |
+
flow_verse.sync_dependencies(dependencies)
|
10 |
+
# ~~~
|
11 |
+
|
12 |
# ~~~ Codeforces ~~~
|
13 |
# code
|
14 |
from .CF_Code import CF_Code
|
|
|
25 |
from .CF_CodeTesting import CF_CodeTesting
|
26 |
from .CF_CodeDebug import CF_CodeDebug
|
27 |
|
28 |
+
# code_debug_collab
|
29 |
from .CF_CodeCriticWrongAttempt import CF_CodeCriticWrongAttempt
|
30 |
from .CF_CodeDebugCritic import CF_CodeDebugCritic
|
31 |
from .CF_CodeDebugCollab import CF_CodeDebugCollab
|
32 |
+
|
33 |
+
# plan-code (and plan_oracle-code)
|
34 |
+
from .CF_Plan import CF_Plan
|
35 |
+
from .CF_CodeWithPlan import CF_CodeWithPlan
|
36 |
+
from .CF_Plan_Code import CF_Plan_Code
|
37 |
+
|
38 |
+
# plan_reflect-code
|
39 |
+
from .FixedReply_PlanReflect import FixedReply_PlanReflect
|
40 |
+
from .CF_PlanReflect import CF_PlanReflect
|
41 |
+
from .CF_PlanReflect_Code import CF_PlanReflect_Code
|
42 |
+
|
43 |
+
# plan_collab-code
|
44 |
+
from .CF_PlanCritic import CF_PlanCritic
|
45 |
+
from .CF_PlanCollab import CF_PlanCollab
|
46 |
+
from .CF_PlanCollab_Code import CF_PlanCollab_Code
|
47 |
+
|
48 |
+
# plan_oracle-code_debug_collab
|
49 |
+
from .CF_CodeCriticWrongAttemptWithPlan import CF_CodeCriticWrongAttemptWithPlan
|
50 |
+
from .CF_CodeDebugCriticWithPlan import CF_CodeDebugCriticWithPlan
|
51 |
+
from .CF_CodeDebugCollabWithPlan import CF_CodeDebugCollabWithPlan
|
52 |
+
# ~~~
|
53 |
+
|
54 |
+
# ~~~ LeetCode ~~~
|
55 |
+
# code
|
56 |
+
from .LC_Code import LC_Code
|
57 |
+
|
58 |
+
# code_reflect
|
59 |
+
from .LC_CodeReflect import LC_CodeReflect
|
60 |
+
|
61 |
+
# code_collab
|
62 |
+
from .LC_CodeCritic import LC_CodeCritic
|
63 |
+
from .LC_CodeCollab import LC_CodeCollab
|
64 |
+
|
65 |
+
# code_debug
|
66 |
+
from .LC_CodeTesting import LC_CodeTesting
|
67 |
+
from .LC_CodeDebug import LC_CodeDebug
|
68 |
+
|
69 |
+
# code_debug_collab
|
70 |
+
from .LC_CodeCriticWrongAttempt import LC_CodeCriticWrongAttempt
|
71 |
+
from .LC_CodeDebugCritic import LC_CodeDebugCritic
|
72 |
+
from .LC_CodeDebugCollab import LC_CodeDebugCollab
|
73 |
+
|
74 |
+
# plan-code
|
75 |
+
from .LC_Plan import LC_Plan
|
76 |
+
from .LC_CodeWithPlan import LC_CodeWithPlan
|
77 |
+
from .LC_Plan_Code import LC_Plan_Code
|
78 |
+
|
79 |
+
# plan_reflect-code
|
80 |
+
from .LC_PlanReflect import LC_PlanReflect
|
81 |
+
from .LC_PlanReflect_Code import LC_PlanReflect_Code
|
82 |
+
|
83 |
+
# plan_collab-code
|
84 |
+
from .LC_PlanCritic import LC_PlanCritic
|
85 |
+
from .LC_PlanCollab import LC_PlanCollab
|
86 |
+
from .LC_PlanCollab_Code import LC_PlanCollab_Code
|
87 |
+
# ~~~
|