diff --git a/CF_Code.py b/CF_Code.py index 06c8eb7559af04d44c80c90a3fc844b941c4e136..e4b2bf46114beaa5ac420109289d655c721509a4 100644 --- a/CF_Code.py +++ b/CF_Code.py @@ -1,12 +1,10 @@ import importlib import os -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - -# flow_module = importlib.import_module(os.getenv("OpenAIChatAtomicFlow_module")) -# OpenAIChatAtomicFlow = getattr(flow_module, "OpenAIChatAtomicFlow") - +from flows.application_flows import OpenAIChatAtomicFlow class CF_Code(OpenAIChatAtomicFlow): def __init__(self, **kwargs): super().__init__(**kwargs) + + diff --git a/CF_Code.yaml b/CF_Code.yaml index 47f63da579f777176541b17aa82fe2190c59f012..b0d974739ce7dc9a8fd1ba3ab420b21a0ffea9f1 100644 --- a/CF_Code.yaml +++ b/CF_Code.yaml @@ -35,7 +35,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -65,7 +65,7 @@ query_message_prompt_template: template_format: jinja2 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "input_description" - "output_description" @@ -75,10 +75,11 @@ output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" + input_key: "api_output" output_key: "code" strip: True assert_unique: True output_keys: + - "api_output" - "code" diff --git a/CF_CodeCollab.yaml b/CF_CodeCollab.yaml index 88e3712eaf4b2553f0de278ac4d42ef5c00cb833..89525100eef484d57186da15dbc97e407939600e 100644 --- a/CF_CodeCollab.yaml +++ b/CF_CodeCollab.yaml @@ -1,30 +1,21 @@ name: "CodeCollab_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDO: To increase to 4 -early_exit_key: "end_of_interaction" -input_data_transformations: [] input_keys: - "problem_description" - "input_description" - "output_description" - "io_examples_and_explanation" -output_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - raw_response.code: "code" output_keys: - "code" subflows_config: - - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config + CodeGenerator: + _target_: .CF_Code.instantiate_from_default_config overrides: - name: "CodeGenerator" - model_name: "gpt-4" human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- @@ -43,28 +34,26 @@ subflows_config: partial_variables: code_placeholder: "{{python_code}}" template_format: jinja2 - default_human_input_keys: + + input_keys: - "code_feedback" - output_data_transformations: - - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor - regex: '(?<=```python)([\s\S]*?)(?=```)' - regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" - output_key: "code" - strip: True - assert_unique: True - - - _target_: flows.data_transformations.EndOfInteraction - end_of_interaction_string: "Final answer" - output_key: "end_of_interaction" + CodeCritic: + _target_: .CF_CodeCritic.instantiate_from_default_config + +topology: + - flow: CodeGenerator + reset_every_round: false + output_transformations: + - _target_: flows.data_transformations.EndOfInteraction + end_of_interaction_string: "Final answer" + input_key: "api_output" + output_key: "end_of_interaction" + + - flow: CodeCritic + reset_every_round: true + output_transformations: + - _target_: flows.data_transformations.KeyRename + old_key2new_key: + api_output: "code_feedback" - output_keys: - - "code" - - "end_of_interaction" - - _target_: martinjosifoski.CC_flows.CF_CodeCritic.instantiate_from_default_config - overrides: - name: CodeCritic - output_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - raw_response: "code_feedback" +early_exit_key: "end_of_interaction" diff --git a/CF_CodeCritic.py b/CF_CodeCritic.py index 285b78f5505c854207da002984f21c3b4c273929..b66374a03cf526d7f31c5e4ab31d85247bef314e 100644 --- a/CF_CodeCritic.py +++ b/CF_CodeCritic.py @@ -1,7 +1,4 @@ -import os -import importlib - -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow +from flows.application_flows import OpenAIChatAtomicFlow class CF_CodeCritic(OpenAIChatAtomicFlow): diff --git a/CF_CodeCritic.yaml b/CF_CodeCritic.yaml index 3c80c60ea3f9ef9fd51b0d3bdef3b4e0cdc70e5b..a35eae7bb5ca737ca494a4576dd8d7fa3b7a7b4d 100644 --- a/CF_CodeCritic.yaml +++ b/CF_CodeCritic.yaml @@ -37,7 +37,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -66,10 +66,10 @@ query_message_prompt_template: - "code" template_format: jinja2 -input_keys: +init_input_keys: - "problem_description" - "input_description" - "output_description" - "io_examples_and_explanation" - "code" -output_keys: [] +output_keys: ["api_output"] diff --git a/CF_CodeCriticWrongAttempt.py b/CF_CodeCriticWrongAttempt.py index cf0c36be940d11f804d86edaa38ce99ea51e432c..997d886e5859270b6993c02d6e92e8217f49a5bf 100644 --- a/CF_CodeCriticWrongAttempt.py +++ b/CF_CodeCriticWrongAttempt.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class CF_CodeCriticWrongAttempt(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/CF_CodeCriticWrongAttempt.yaml b/CF_CodeCriticWrongAttempt.yaml index ff83ca0dfb9d4a28440f669ffc5817a96c5bccc4..e2b39e05e4eaaceb223a9a83bfaae99194926dd0 100644 --- a/CF_CodeCriticWrongAttempt.yaml +++ b/CF_CodeCriticWrongAttempt.yaml @@ -38,7 +38,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -70,8 +70,7 @@ query_message_prompt_template: - "testing_results_summary" template_format: jinja2 -input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "input_description" - "output_description" @@ -82,6 +81,6 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "code_feedback" + api_output: "code_feedback" output_keys: - "code_feedback" diff --git a/CF_CodeCriticWrongAttemptWithPlan.py b/CF_CodeCriticWrongAttemptWithPlan.py index cb57875a30cac308e6e8d2d0a1893d4a950fbc12..f77bab105af2c0ebf06129aee76a5be32985fe53 100644 --- a/CF_CodeCriticWrongAttemptWithPlan.py +++ b/CF_CodeCriticWrongAttemptWithPlan.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class CF_CodeCriticWrongAttemptWithPlan(OpenAIChatAtomicFlow): diff --git a/CF_CodeCriticWrongAttemptWithPlan.yaml b/CF_CodeCriticWrongAttemptWithPlan.yaml index 1b3e0ea767cd40d2aa8e4dc7ef7a06cd026b05bb..2dc284c55ed5577b8aa28ef6482c870947cc0b64 100644 --- a/CF_CodeCriticWrongAttemptWithPlan.yaml +++ b/CF_CodeCriticWrongAttemptWithPlan.yaml @@ -40,7 +40,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -77,7 +77,7 @@ query_message_prompt_template: template_format: jinja2 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "input_description" - "output_description" @@ -89,6 +89,6 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "code_feedback" + api_output: "code_feedback" output_keys: - "code_feedback" diff --git a/CF_CodeDebug.yaml b/CF_CodeDebug.yaml index 643c0c190f0724a1e0d9bdae3a216cb6e895d01e..4681eed58dc12054bbe6789c72babef3c4bb58f4 100644 --- a/CF_CodeDebug.yaml +++ b/CF_CodeDebug.yaml @@ -1,12 +1,8 @@ name: "CodeDebug_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 -early_exit_key: "end_of_interaction" -input_data_transformations: [] input_keys: - "problem_description" - "input_description" @@ -14,15 +10,12 @@ input_keys: - "io_examples_and_explanation" - "public_tests_individual_io" -output_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - raw_response.code: "code" output_keys: - "code" subflows_config: - - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config + CodeGenerator: + _target_: .CF_Code.instantiate_from_default_config overrides: name: "CodeGenerator" model_name: "gpt-4" @@ -39,25 +32,22 @@ subflows_config: - testing_results_summary partial_variables: code_placeholder: "{{python_code}}" - default_human_input_keys: + input_keys: - "testing_results_summary" - - "all_tests_passed" - output_data_transformations: - - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor - regex: '(?<=```python)([\s\S]*?)(?=```)' - regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" - output_key: "code" - strip: True - assert_unique: True - - - _target_: flows.data_transformations.EndOfInteraction - end_of_interaction_string: "Final answer" - output_key: "end_of_interaction" - - output_keys: - - "code" - - "end_of_interaction" - - _target_: martinjosifoski.CC_flows.CF_CodeTesting.instantiate_from_default_config - overrides: - name: "CodeTestingCritic" + + CodeTestingCritic: + _target_: .CF_CodeTesting.instantiate_from_default_config + +topology: + - flow: CodeGenerator + reset_every_round: false + output_transformations: + - _target_: flows.data_transformations.EndOfInteraction + end_of_interaction_string: "Final answer" + input_key: "api_output" + output_key: "end_of_interaction" + + - flow: CodeTestingCritic + reset_every_round: true + +early_exit_key: "end_of_interaction" diff --git a/CF_CodeDebugCollab.yaml b/CF_CodeDebugCollab.yaml index 4f6cf88ae84429e6447292ca08a0341c09d72bdf..95a674437c6942d8a1c538b32a63013e685d3a7d 100644 --- a/CF_CodeDebugCollab.yaml +++ b/CF_CodeDebugCollab.yaml @@ -1,12 +1,8 @@ name: "CodeDebugCollab_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 -early_exit_key: "end_of_interaction" -input_data_transformations: [] input_keys: - "problem_description" - "input_description" @@ -14,15 +10,12 @@ input_keys: - "io_examples_and_explanation" - "public_tests_individual_io" -output_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - raw_response.code: "code" output_keys: - "code" subflows_config: - - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config + CodeGenerator: + _target_: .CF_Code.instantiate_from_default_config overrides: name: "CodeGenerator" model_name: "gpt-4" @@ -44,23 +37,24 @@ subflows_config: partial_variables: code_placeholder: "{{python_code}}" template_format: jinja2 - default_human_input_keys: + + input_keys: - "code_feedback" - "testing_results_summary" - output_data_transformations: - - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor - regex: '(?<=```python)([\s\S]*?)(?=```)' - regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" - output_key: "code" - strip: True - assert_unique: True + + CodeDebugCritic: + _target_: .CF_CodeDebugCritic.instantiate_from_default_config + +topology: + - flow: CodeGenerator + reset_every_round: false + output_transformations: + - _target_: flows.data_transformations.EndOfInteraction + end_of_interaction_string: "Final answer" + input_key: "api_output" + output_key: "end_of_interaction" + + - flow: CodeDebugCritic + reset_every_round: true - - _target_: flows.data_transformations.EndOfInteraction - end_of_interaction_string: "Final answer" - output_key: "end_of_interaction" - - output_keys: - - "code" - - "end_of_interaction" - - _target_: martinjosifoski.CC_flows.CF_CodeDebugCritic.instantiate_from_default_config +early_exit_key: "end_of_interaction" diff --git a/CF_CodeDebugCollabWithPlan.yaml b/CF_CodeDebugCollabWithPlan.yaml index 7c6bd21b858da2e9c10094b13e0de86b9be104be..7843edccadd38f53827090ba7adf706bfd98012c 100644 --- a/CF_CodeDebugCollabWithPlan.yaml +++ b/CF_CodeDebugCollabWithPlan.yaml @@ -1,8 +1,7 @@ name: "CodeDebugCollabWithPlan_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True + max_rounds: 2 # ToDo: To increase to 4 early_exit_key: "end_of_interaction" @@ -18,7 +17,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" @@ -45,23 +44,28 @@ subflows_config: partial_variables: code_placeholder: "{{python_code}}" template_format: jinja2 - default_human_input_keys: + input_keys: - "code_feedback" - "testing_results_summary" output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" + input_key: "api_output" output_key: "code" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: - "code" - "end_of_interaction" - _target_: martinjosifoski.CC_flows.CF_CodeDebugCriticWithPlan.instantiate_from_default_config + +reset_every_round: + CodeGenerator: False + CodeDebugCriticWithPlan_Flow: True diff --git a/CF_CodeDebugCritic.yaml b/CF_CodeDebugCritic.yaml index e562fdf2f245152ff85d4fac10a1f43b274ef4a9..ba3bf0e15563113d82f4cbb45f495ea06f2950f3 100644 --- a/CF_CodeDebugCritic.yaml +++ b/CF_CodeDebugCritic.yaml @@ -3,7 +3,6 @@ description: "ToDo: add description" early_exit_key: null -input_data_transformations: [] input_keys: - "problem_description" - "input_description" @@ -12,19 +11,18 @@ input_keys: - "public_tests_individual_io" - "code" -output_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - raw_response.testing_results_summary: "testing_results_summary" - raw_response.all_tests_passed: "all_tests_passed" - raw_response.code_feedback: "code_feedback" output_keys: - "testing_results_summary" - "all_tests_passed" - "code_feedback" subflows_config: - - _target_: martinjosifoski.CC_flows.CF_CodeTesting.instantiate_from_default_config - overrides: - name: "CodeTestingCritic" - - _target_: martinjosifoski.CC_flows.CF_CodeCriticWrongAttempt.instantiate_from_default_config + CodeTestingCritic: + _target_: .CF_CodeTesting.instantiate_from_default_config + CodeCriticWrongAttempt: + _target_: .CF_CodeCriticWrongAttempt.instantiate_from_default_config + +topology: + - flow: CodeTestingCritic + - flow: CodeCriticWrongAttempt + diff --git a/CF_CodeDebugCriticWithPlan.yaml b/CF_CodeDebugCriticWithPlan.yaml index 865361cab83cb2c97bfdae075f664edc53ebe629..2f0a2a8f90db92db6d8d973db17db12388a2b3e8 100644 --- a/CF_CodeDebugCriticWithPlan.yaml +++ b/CF_CodeDebugCriticWithPlan.yaml @@ -16,9 +16,9 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.testing_results_summary: "testing_results_summary" - raw_response.all_tests_passed: "all_tests_passed" - raw_response.code_feedback: "code_feedback" + testing_results_summary: "testing_results_summary" + all_tests_passed: "all_tests_passed" + code_feedback: "code_feedback" output_keys: - "testing_results_summary" - "all_tests_passed" diff --git a/CF_CodeReflect.yaml b/CF_CodeReflect.yaml index b7b0742eca83a20a1cf775b20300343c990a4fc5..c115495657cfa699b1943bca6ab7e11172fe6c82 100644 --- a/CF_CodeReflect.yaml +++ b/CF_CodeReflect.yaml @@ -1,48 +1,37 @@ name: "CodeReflect_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 -early_exit_key: "end_of_interaction" -input_data_transformations: [] input_keys: - "problem_description" - "input_description" - "output_description" - "io_examples_and_explanation" -output_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - raw_response.code: "code" output_keys: - "code" subflows_config: - - _target_: martinjosifoski.CC_flows.CF_Code.instantiate_from_default_config - overrides: - name: "CodeGenerator" - model_name: "gpt-4" - input_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - code_reflect_message: "query" - output_data_transformations: - - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor - regex: '(?<=```python)([\s\S]*?)(?=```)' - regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - output_key: "code" - strip: True - assert_unique: True + CodeGenerator: + _target_: .CF_Code.instantiate_from_default_config + CodeReflectCritic: + _target_: .FixedReply_CodeReflect.instantiate_from_default_config - - _target_: flows.data_transformations.EndOfInteraction - end_of_interaction_string: "Final answer" - output_key: "end_of_interaction" +topology: + - flow: CodeGenerator + reset_every_round: false + output_transformations: + - _target_: flows.data_transformations.EndOfInteraction + end_of_interaction_string: "Final answer" + input_key: "api_output" + output_key: "end_of_interaction" - output_keys: - - "code" - - "end_of_interaction" + - flow: CodeReflectCritic + reset_every_round: true + output_transformations: + - _target_: flows.data_transformations.KeyRename + old_key2new_key: + code_reflect_message: "query" - - _target_: martinjosifoski.CC_flows.FixedReply_CodeReflect.instantiate_from_default_config +early_exit_key: "end_of_interaction" diff --git a/CF_CodeTesting.yaml b/CF_CodeTesting.yaml index eaf5e2ca6d907d0fa275299276588e880ac3d582..1fcec0dc451733aa27869fada1f50abced932f10 100644 --- a/CF_CodeTesting.yaml +++ b/CF_CodeTesting.yaml @@ -1,3 +1,4 @@ +name: "CF_CodeTesting" description: "ToDo: add description" input_data_transformations: [] @@ -10,7 +11,7 @@ output_keys: - "testing_results_summary" output_data_transformations: - _target_: martinjosifoski.CC_flows.src.data_transformations.CorrectnessFlag - input_key: "raw_response.public_tests_results" + input_key: "public_tests_results" output_key: "all_tests_passed" - _target_: martinjosifoski.CC_flows.src.data_transformations.TestingResultsSummaryGeneration output_key: "testing_results_summary" diff --git a/CF_CodeWithPlan.py b/CF_CodeWithPlan.py index eedd61463ccf34a3d774312c3a52277d83ba98ac..f9ec25d6bfec131c8fd9cc237266130cc54415e9 100644 --- a/CF_CodeWithPlan.py +++ b/CF_CodeWithPlan.py @@ -1,6 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - - +from flows.application_flows import OpenAIChatAtomicFlow class CF_CodeWithPlan(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/CF_CodeWithPlan.yaml b/CF_CodeWithPlan.yaml index e2be700c8adfde686eb63d0399da09d75f0f4253..d860aa40f76a6f2cbbeed34485c9e96224b6296f 100644 --- a/CF_CodeWithPlan.yaml +++ b/CF_CodeWithPlan.yaml @@ -37,7 +37,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -71,7 +71,7 @@ query_message_prompt_template: template_format: jinja2 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "input_description" - "output_description" @@ -82,6 +82,7 @@ output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' + input_key: "api_output" output_key: "code" strip: True assert_unique: True diff --git a/CF_Plan.py b/CF_Plan.py index a9f7e0a455a61082421c1112329eb5a5f234cca6..8d77d0cf25dcbe410823d26aeba4a39eeef0c508 100644 --- a/CF_Plan.py +++ b/CF_Plan.py @@ -1,4 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow +from flows.application_flows import OpenAIChatAtomicFlow class CF_Plan(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/CF_Plan.yaml b/CF_Plan.yaml index 55418723f68a37759b413ecb60760cc4a6dd4008..9d32a0799b312d90e7de4cd075a68daa7ff7afb1 100644 --- a/CF_Plan.yaml +++ b/CF_Plan.yaml @@ -13,7 +13,7 @@ generation_parameters: presence_penalty: 0 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "input_description" - "output_description" @@ -24,6 +24,7 @@ output_data_transformations: regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' regex_fallback: - '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' + input_key: "api_output" output_key: "plan" strip: True assert_unique: True @@ -56,7 +57,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement diff --git a/CF_PlanCollab.yaml b/CF_PlanCollab.yaml index a29649b42771b58321d986b9c221e4d54c94a4c3..7f541091903f9974c01c6825d34672857c338f23 100644 --- a/CF_PlanCollab.yaml +++ b/CF_PlanCollab.yaml @@ -1,8 +1,6 @@ name: "PlanCollab_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 early_exit_key: "end_of_interaction" @@ -16,7 +14,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.plan: "plan" + plan: "plan" output_keys: - "plan" @@ -41,19 +39,21 @@ subflows_config: partial_variables: plan_placeholder: "{{conceptual_solution}}" template_format: jinja2 - default_human_input_keys: + input_keys: - "plan_feedback" output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' regex_fallback: - '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' + input_key: "api_output" output_key: "plan" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -65,4 +65,8 @@ subflows_config: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "plan_feedback" + api_output: "plan_feedback" + +reset_every_round: + PlanGenerator: false + PlanCritic: true diff --git a/CF_PlanCollab_Code.yaml b/CF_PlanCollab_Code.yaml index 0a32c9028e3ed46abb320f9f1f6e344a5fb2f81c..3037ae1702731c3fb3ed02f7a385c1bf7568e450 100644 --- a/CF_PlanCollab_Code.yaml +++ b/CF_PlanCollab_Code.yaml @@ -13,7 +13,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" diff --git a/CF_PlanCritic.py b/CF_PlanCritic.py index 66adfab3d38155869587517bf34ac3f8c83341d8..27e0e20550757fbfa8640a4a9c522e9495449576 100644 --- a/CF_PlanCritic.py +++ b/CF_PlanCritic.py @@ -1,4 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow +from flows.application_flows import OpenAIChatAtomicFlow class CF_PlanCritic(OpenAIChatAtomicFlow): diff --git a/CF_PlanCritic.yaml b/CF_PlanCritic.yaml index 91e06541c721554dd7b45fe879a7f7edba3a9115..5fbc249e7b7c73a357fd41fadd362a2e267f2af4 100644 --- a/CF_PlanCritic.yaml +++ b/CF_PlanCritic.yaml @@ -38,7 +38,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -65,7 +65,7 @@ query_message_prompt_template: - "plan" template_format: jinja2 -input_keys: +init_input_keys: - "problem_description" - "input_description" - "output_description" diff --git a/CF_PlanReflect.yaml b/CF_PlanReflect.yaml index 7b53cb6a0af12193de9a374bb5ec1dabadc7869b..fe3cf6bf2596703ff3d60340132248364c5d845d 100644 --- a/CF_PlanReflect.yaml +++ b/CF_PlanReflect.yaml @@ -1,8 +1,6 @@ name: "PlanReflect_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: increase to 4 early_exit_key: "end_of_interaction" @@ -16,7 +14,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.plan: "plan" + plan: "plan" output_keys: - "plan" @@ -34,12 +32,14 @@ subflows_config: regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' regex_fallback: - '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' + input_key: "api_output" output_key: "plan" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -48,3 +48,7 @@ subflows_config: - _target_: martinjosifoski.CC_flows.FixedReply_PlanReflect.instantiate_from_default_config + +reset_every_round: + PlanGenerator_Flow: False # this is the name of the subflow, may be different for each config, needs to check ! + PlanReflectCritic: True \ No newline at end of file diff --git a/CF_PlanReflect_Code.yaml b/CF_PlanReflect_Code.yaml index 58d6147ef88ec662215a0d3c26ce697fb4c50f3d..7287b2ac4e8d2b76aafd7f38063618d8b54faff4 100644 --- a/CF_PlanReflect_Code.yaml +++ b/CF_PlanReflect_Code.yaml @@ -13,7 +13,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" diff --git a/CF_Plan_Code.yaml b/CF_Plan_Code.yaml index 8824f9b0abf066bd57030a76d7fabe4358a76d7b..095c2a334c867443af360d715870d182cc8f4029 100644 --- a/CF_Plan_Code.yaml +++ b/CF_Plan_Code.yaml @@ -1,26 +1,25 @@ name: "Plan_Code_Flow" description: "ToDO: add description" -early_exit_key: null - -input_data_transformations: [] input_keys: - "problem_description" - "input_description" - "output_description" - "io_examples_and_explanation" -output_data_transformations: - - _target_: flows.data_transformations.KeyRename - old_key2new_key: - raw_response.code: "code" output_keys: - "code" subflows_config: - - _target_: martinjosifoski.CC_flows.CF_Plan.instantiate_from_default_config + CF_Plan: + _target_: martinjosifoski.CC_flows.CF_Plan.instantiate_from_default_config overrides: model_name: "gpt-4" - - _target_: martinjosifoski.CC_flows.CF_CodeWithPlan.instantiate_from_default_config + CF_CodeWithPlan: + _target_: martinjosifoski.CC_flows.CF_CodeWithPlan.instantiate_from_default_config overrides: model_name: "gpt-4" + +topology: + - flow: CF_Plan + - flow: CF_CodeWithPlan diff --git a/CodeTesting.py b/CodeTesting.py index 408b5e9fe1295cfbf108824d2590cf9589e477ff..6eb4b98ddfcdd77633f0a43b0e251ef35efa8d0c 100644 --- a/CodeTesting.py +++ b/CodeTesting.py @@ -2,7 +2,7 @@ from copy import deepcopy from typing import Optional, Any, List, Dict from flows import logging -from flows.base_flows.abstract import AtomicFlow +from flows.base_flows import AtomicFlow log = logging.get_logger(__name__) @@ -33,14 +33,12 @@ class CodeTesting(AtomicFlow): return cls(**kwargs) def run(self, - input_data: Dict[str, Any], - private_keys: Optional[List[str]] = [], - keys_to_ignore_for_hash: Optional[List[str]] = []) -> Dict[str, Any]: + input_data: Dict[str, Any]) -> Dict[str, Any]: # ~~~ Retrieve the test data ~~~ test_data = self._get_test_data(input_data) # ~~~ Run tests ~~~ - response = self._run_tests(input_data, test_data) + response: Dict[str, Any] = self._run_tests(input_data, test_data) return response diff --git a/FixedReply_CodeReflect.yaml b/FixedReply_CodeReflect.yaml index 21f5710bbfaf3b408dfd0c06db9c6f9a5568381b..7c892fea06a6c208c67a4c1084436fcb32f976d5 100644 --- a/FixedReply_CodeReflect.yaml +++ b/FixedReply_CodeReflect.yaml @@ -8,7 +8,7 @@ input_keys: [] output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "code_reflect_message" + fixed_reply: "code_reflect_message" output_keys: - "code_reflect_message" diff --git a/FixedReply_PlanReflect.yaml b/FixedReply_PlanReflect.yaml index 10a6d876b8b5bbdf6c8bf68b3b4ba84d07b2f23d..9416cb540df80828eac635320444f02b3e4c1591 100644 --- a/FixedReply_PlanReflect.yaml +++ b/FixedReply_PlanReflect.yaml @@ -8,7 +8,7 @@ input_keys: [] output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "plan_reflect_message" + fixed_reply: "plan_reflect_message" output_keys: - "plan_reflect_message" diff --git a/LC_Code.py b/LC_Code.py index 171f99cf3881d42d3ed7cc165b00b174b83bff43..0e306138455b3b9705514ca41330f00dae36dec8 100644 --- a/LC_Code.py +++ b/LC_Code.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class LC_Code(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/LC_Code.yaml b/LC_Code.yaml index ac90f81eb0e80c3bb1f743c3ccc779f226d1429f..cb758a8d32862e4cc933e5b5d28ad280c77fd9cf 100644 --- a/LC_Code.yaml +++ b/LC_Code.yaml @@ -33,7 +33,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -64,7 +64,7 @@ query_message_prompt_template: template_format: jinja2 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "io_description" - "constraints" @@ -74,7 +74,7 @@ output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" + input_key: "api_output" output_key: "code" strip: True assert_unique: True diff --git a/LC_CodeCollab.yaml b/LC_CodeCollab.yaml index b84bce1e3ee9ddaa26a6efe89ec3a9ed770f3a39..85d5a5800ec49e288e2915676ae387e9e555142e 100644 --- a/LC_CodeCollab.yaml +++ b/LC_CodeCollab.yaml @@ -1,8 +1,6 @@ name: "CodeCollab_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDO: To increase to 4 early_exit_key: "end_of_interaction" @@ -16,7 +14,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" @@ -43,19 +41,20 @@ subflows_config: partial_variables: code_placeholder: "{{python_code}}" template_format: jinja2 - default_human_input_keys: + input_keys: - "code_feedback" output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" + input_key: "api_output" output_key: "code" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -67,4 +66,8 @@ subflows_config: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "code_feedback" + api_output: "code_feedback" + +reset_every_round: + CodeGenerator: False + CodeCritic: True diff --git a/LC_CodeCritic.py b/LC_CodeCritic.py index 070ce152fc8d9d1782389c8f15c4f670c7a4b37f..5d647383c0aea9762e5e78f4aa3494a24dc4e554 100644 --- a/LC_CodeCritic.py +++ b/LC_CodeCritic.py @@ -1,6 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - - +from flows.application_flows import OpenAIChatAtomicFlow class LC_CodeCritic(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/LC_CodeCritic.yaml b/LC_CodeCritic.yaml index ef0b1e97246ac1a585954315a82ea55cdfb3128e..1a1fe08d04d6ae0bb8a7dfdf1c112b5625e7a0f0 100644 --- a/LC_CodeCritic.yaml +++ b/LC_CodeCritic.yaml @@ -36,7 +36,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -67,7 +67,7 @@ query_message_prompt_template: - "code" template_format: jinja2 -input_keys: +init_input_keys: - "problem_description" - "io_description" - "constraints" diff --git a/LC_CodeCriticWrongAttempt.py b/LC_CodeCriticWrongAttempt.py index 97fc5b39da849e9d09eab2757208f36466cb2a30..ffc8aa46937c18dd80ae13cb4123c1757d572dcb 100644 --- a/LC_CodeCriticWrongAttempt.py +++ b/LC_CodeCriticWrongAttempt.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class LC_CodeCriticWrongAttempt(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/LC_CodeCriticWrongAttempt.yaml b/LC_CodeCriticWrongAttempt.yaml index 5d00d910d4503b4a3eee8f69f30a7a45f317a7fb..5c08e2225f86473c397ca968f93e58c0403d91b1 100644 --- a/LC_CodeCriticWrongAttempt.yaml +++ b/LC_CodeCriticWrongAttempt.yaml @@ -37,7 +37,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -72,7 +72,7 @@ query_message_prompt_template: template_format: jinja2 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "io_description" - "constraints" @@ -83,6 +83,6 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "code_feedback" + api_output: "code_feedback" output_keys: - "code_feedback" diff --git a/LC_CodeCriticWrongAttemptWithPlan.py b/LC_CodeCriticWrongAttemptWithPlan.py index 95590f7dd7894492ed30e81e9ddb4a011eb1a58a..d80dbad40d7da4144446b06cbbb1d9c7bcf9d8ba 100644 --- a/LC_CodeCriticWrongAttemptWithPlan.py +++ b/LC_CodeCriticWrongAttemptWithPlan.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class LC_CodeCriticWrongAttemptWithPlan(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/LC_CodeCriticWrongAttemptWithPlan.yaml b/LC_CodeCriticWrongAttemptWithPlan.yaml index dd9229c334bdf0d8b79a5b4a76e8cfd50b767407..25558d2a345a1b21274b96714bd36242d60f9e18 100644 --- a/LC_CodeCriticWrongAttemptWithPlan.yaml +++ b/LC_CodeCriticWrongAttemptWithPlan.yaml @@ -39,7 +39,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -79,7 +79,7 @@ query_message_prompt_template: template_format: jinja2 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "io_description" - "constraints" @@ -91,6 +91,6 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "code_feedback" + api_output: "code_feedback" output_keys: - "code_feedback" diff --git a/LC_CodeDebug.yaml b/LC_CodeDebug.yaml index c61382cd62c9bdbf71f8faf5b25a335861f8e0b9..7f01c93fbf350fb6a66d7b505787575dc6eb375d 100644 --- a/LC_CodeDebug.yaml +++ b/LC_CodeDebug.yaml @@ -1,8 +1,6 @@ name: "CodeDebug_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 early_exit_key: "end_of_interaction" @@ -17,7 +15,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" @@ -39,20 +37,21 @@ subflows_config: - testing_results_summary partial_variables: code_placeholder: "{{python_code}}" - default_human_input_keys: + input_keys: - "testing_results_summary" - "all_tests_passed" output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" + input_key: "api_output" output_key: "code" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -61,3 +60,7 @@ subflows_config: - _target_: martinjosifoski.CC_flows.LC_CodeTesting.instantiate_from_default_config overrides: name: "CodeTestingCritic" + +reset_every_round: + CodeGenerator: False + CodeTestingCritic: True diff --git a/LC_CodeDebugCollab.yaml b/LC_CodeDebugCollab.yaml index 4a408a47ae400c5e327826b55d6e5a4ceed1b1ed..4f589aab1d0159f84c620bf1e44abbcba754d96a 100644 --- a/LC_CodeDebugCollab.yaml +++ b/LC_CodeDebugCollab.yaml @@ -1,8 +1,6 @@ name: "CodeDebugCollab_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 early_exit_key: "end_of_interaction" @@ -17,7 +15,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" @@ -44,20 +42,21 @@ subflows_config: partial_variables: code_placeholder: "{{python_code}}" template_format: jinja2 - default_human_input_keys: + input_keys: - "code_feedback" - "testing_results_summary" output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" + input_key: "api_output" output_key: "code" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -65,3 +64,7 @@ subflows_config: - "end_of_interaction" - _target_: martinjosifoski.CC_flows.LC_CodeDebugCritic.instantiate_from_default_config + +reset_every_round: + CodeGenerator: False + CodeDebugCritic_Flow: True diff --git a/LC_CodeDebugCollabWithPlan.yaml b/LC_CodeDebugCollabWithPlan.yaml index 02ba2979361199a092284fa9732f2684f79d38e1..46760591f0a8e38eab991f05d91ca60343bdcf07 100644 --- a/LC_CodeDebugCollabWithPlan.yaml +++ b/LC_CodeDebugCollabWithPlan.yaml @@ -1,8 +1,6 @@ name: "CodeDebugCollabWithPlan_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 early_exit_key: "end_of_interaction" @@ -18,7 +16,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" @@ -45,23 +43,29 @@ subflows_config: partial_variables: code_placeholder: "{{python_code}}" template_format: jinja2 - default_human_input_keys: + input_keys: - "code_feedback" - "testing_results_summary" output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' - input_key: "raw_response" + input_key: "api_output" output_key: "code" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: - "code" - "end_of_interaction" - _target_: martinjosifoski.CC_flows.LC_CodeDebugCriticWithPlan.instantiate_from_default_config + + +reset_every_round: + CodeGenerator: False + CodeDebugCriticWithPlan_Flow: True diff --git a/LC_CodeDebugCritic.yaml b/LC_CodeDebugCritic.yaml index 8147a9b06b1bb1e1c443870e5159620e2dda1587..5c347793ee35a6fe221cad138e205093d7aa8a92 100644 --- a/LC_CodeDebugCritic.yaml +++ b/LC_CodeDebugCritic.yaml @@ -15,9 +15,9 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.testing_results_summary: "testing_results_summary" - raw_response.all_tests_passed: "all_tests_passed" - raw_response.code_feedback: "code_feedback" + testing_results_summary: "testing_results_summary" + all_tests_passed: "all_tests_passed" + code_feedback: "code_feedback" output_keys: - "testing_results_summary" - "all_tests_passed" diff --git a/LC_CodeDebugCriticWithPlan.yaml b/LC_CodeDebugCriticWithPlan.yaml index 18142fd6aaadf2ec11f0302d75e20c32dd6cc66a..02c29f83e7954579578cacab80ff742b0de1b619 100644 --- a/LC_CodeDebugCriticWithPlan.yaml +++ b/LC_CodeDebugCriticWithPlan.yaml @@ -16,9 +16,9 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.testing_results_summary: "testing_results_summary" - raw_response.all_tests_passed: "all_tests_passed" - raw_response.code_feedback: "code_feedback" + testing_results_summary: "testing_results_summary" + all_tests_passed: "all_tests_passed" + code_feedback: "code_feedback" output_keys: - "testing_results_summary" - "all_tests_passed" diff --git a/LC_CodeReflect.yaml b/LC_CodeReflect.yaml index 8b09eab6969c33c61dcef37ab8ff939493ad21b4..951432e5f24a3322d1caf4f5e8971b0594e1e77e 100644 --- a/LC_CodeReflect.yaml +++ b/LC_CodeReflect.yaml @@ -1,8 +1,6 @@ name: "CodeReflect_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 early_exit_key: "end_of_interaction" @@ -16,7 +14,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" @@ -33,12 +31,14 @@ subflows_config: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' + input_key: "api_output" output_key: "code" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -46,3 +46,7 @@ subflows_config: - "end_of_interaction" - _target_: martinjosifoski.CC_flows.FixedReply_CodeReflect.instantiate_from_default_config + +reset_every_round: + CodeGenerator: False + CodeReflectCritic: True diff --git a/LC_CodeTesting.yaml b/LC_CodeTesting.yaml index dd8725b2061450429a0efdb07c89a7f3dfdc52a8..33ec6809ca77189924dff47fd139c32577c98d82 100644 --- a/LC_CodeTesting.yaml +++ b/LC_CodeTesting.yaml @@ -12,7 +12,7 @@ output_keys: - "testing_results_summary" output_data_transformations: - _target_: .src.data_transformations.CorrectnessFlag - input_key: "raw_response.public_tests_results" + input_key: "public_tests_results" output_key: "all_tests_passed" - _target_: .src.data_transformations.TestingResultsSummaryGeneration output_key: "testing_results_summary" diff --git a/LC_CodeWithPlan.py b/LC_CodeWithPlan.py index 903994d2b2439430370d986015cabacc6ae538a1..85d561328346f824004b3cbfc22ba0bedbbd2119 100644 --- a/LC_CodeWithPlan.py +++ b/LC_CodeWithPlan.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class LC_CodeWithPlan(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/LC_CodeWithPlan.yaml b/LC_CodeWithPlan.yaml index f4ee3ff042d2ebcae0eff19c0b7dda96518e2d8e..d0c46ea67f51db4dd8a35e0ebedae460fe70e0b4 100644 --- a/LC_CodeWithPlan.yaml +++ b/LC_CodeWithPlan.yaml @@ -35,7 +35,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -72,7 +72,7 @@ query_message_prompt_template: template_format: jinja2 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "io_description" - "constraints" @@ -83,6 +83,7 @@ output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=```python)([\s\S]*?)(?=```)' regex_fallback: '(?<=```)([\s\S]*?)(?=```)' + input_key: "api_output" output_key: "code" strip: True assert_unique: True diff --git a/LC_Plan.py b/LC_Plan.py index 602c1e17bcd722568e95c2e112c3e121df4298f6..97d747eed690234017008b1429ca427d56cc3c0e 100644 --- a/LC_Plan.py +++ b/LC_Plan.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class LC_Plan(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/LC_Plan.yaml b/LC_Plan.yaml index 256a0274529789be7ff01372155ffd6979f2fc5b..13331b466508196b043e5c6d8a4b01017360259d 100644 --- a/LC_Plan.yaml +++ b/LC_Plan.yaml @@ -13,7 +13,7 @@ generation_parameters: presence_penalty: 0 input_data_transformations: [] -input_keys: +init_input_keys: - "problem_description" - "io_description" - "constraints" @@ -23,6 +23,7 @@ output_data_transformations: regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' regex_fallback: - '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' + input_key: "api_output" output_key: "plan" strip: True assert_unique: True @@ -53,7 +54,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement diff --git a/LC_PlanCollab.yaml b/LC_PlanCollab.yaml index 42c638fa3993a7dadfd95f779cfc1e41a5ee2ab3..7b927c59af95b30a45b73f19208fc71f5cf9b67d 100644 --- a/LC_PlanCollab.yaml +++ b/LC_PlanCollab.yaml @@ -1,8 +1,6 @@ name: "PlanCollab_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: To increase to 4 early_exit_key: "end_of_interaction" @@ -16,7 +14,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.plan: "plan" + plan: "plan" output_keys: - "plan" @@ -41,19 +39,21 @@ subflows_config: partial_variables: plan_placeholder: "{{conceptual_solution}}" template_format: jinja2 - default_human_input_keys: + input_keys: - "plan_feedback" output_data_transformations: - _target_: flows.data_transformations.RegexFirstOccurrenceExtractor regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' regex_fallback: - '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' + input_key: "api_output" output_key: "plan" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -65,4 +65,8 @@ subflows_config: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response: "plan_feedback" + api_output: "plan_feedback" + +reset_every_round: + PlanGenerator: False + PlanCritic: True diff --git a/LC_PlanCollab_Code.yaml b/LC_PlanCollab_Code.yaml index 0b2feef559b41b3e187ee54ea4ada370e54ed9ab..b3b09c6e68067925f74cdf35bf71e00d22edd605 100644 --- a/LC_PlanCollab_Code.yaml +++ b/LC_PlanCollab_Code.yaml @@ -13,7 +13,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" diff --git a/LC_PlanCritic.py b/LC_PlanCritic.py index 70b669da1b6559ed90a39a6de30451d35ce3dfda..65b626754533125ab14b65a811bc75f8b5cde975 100644 --- a/LC_PlanCritic.py +++ b/LC_PlanCritic.py @@ -1,5 +1,4 @@ -from martinjosifoski.OpenAIChatAtomicFlow import OpenAIChatAtomicFlow - +from flows.application_flows import OpenAIChatAtomicFlow class LC_PlanCritic(OpenAIChatAtomicFlow): def __init__(self, **kwargs): diff --git a/LC_PlanCritic.yaml b/LC_PlanCritic.yaml index dd85b8a8837df1a6cebf2b44faa0b8190b24bc0a..7e329157c18dace3864b98203b9c9f80946b4815 100644 --- a/LC_PlanCritic.yaml +++ b/LC_PlanCritic.yaml @@ -36,7 +36,7 @@ human_message_prompt_template: - "query" template_format: jinja2 -query_message_prompt_template: +init_human_message_prompt_template: _target_: langchain.PromptTemplate template: |2- # Problem statement @@ -65,7 +65,7 @@ query_message_prompt_template: - "plan" template_format: jinja2 -input_keys: +init_input_keys: - "problem_description" - "io_description" - "constraints" diff --git a/LC_PlanReflect.yaml b/LC_PlanReflect.yaml index 2c3bbdf38b9537ba0b7d9cc20f1e7cb4130f344f..219268c3e81fbf14a08d4b2908f51b6ff5a70970 100644 --- a/LC_PlanReflect.yaml +++ b/LC_PlanReflect.yaml @@ -1,8 +1,6 @@ name: "PlanReflect_Flow" description: "ToDO: add description" -reset_generator_every_round: False -reset_critic_every_round: True max_rounds: 2 # ToDo: increase to 4 early_exit_key: "end_of_interaction" @@ -15,7 +13,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.plan: "plan" + plan: "plan" output_keys: - "plan" @@ -33,12 +31,14 @@ subflows_config: regex: '(?<=Conceptual solution)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' regex_fallback: - '(?<=Conceptual solution:)([\s\S]*?)(?=\n\n# [A-Z]|\Z)' + input_key: "api_output" output_key: "plan" strip: True assert_unique: True - _target_: flows.data_transformations.EndOfInteraction end_of_interaction_string: "Final answer" + input_key: "api_output" output_key: "end_of_interaction" output_keys: @@ -60,3 +60,7 @@ subflows_config: {{conceptual_solution}} otherwise, reply: "Final answer." + +reset_every_round: + PlanGenerator_Flow: False + PlanFixedReplyCritic: True diff --git a/LC_Plan_Code.yaml b/LC_Plan_Code.yaml index 685a3ac2acb7f829b8b27221e4897db25ecff028..dec67b1665d75f5c31c36382330c50ad99e7be28 100644 --- a/LC_Plan_Code.yaml +++ b/LC_Plan_Code.yaml @@ -13,7 +13,7 @@ input_keys: output_data_transformations: - _target_: flows.data_transformations.KeyRename old_key2new_key: - raw_response.code: "code" + code: "code" output_keys: - "code" diff --git a/__init__.py b/__init__.py index e5b3a43f1918a5461d91219bd02d1a6704f9b850..6602b0b2673a68f5abf7081d9a6b6c6c0325af24 100644 --- a/__init__.py +++ b/__init__.py @@ -1,11 +1,6 @@ import os from flows import flow_verse -dependencies = [ - {"url": "martinjosifoski/OpenAIChatAtomicFlow", "revision": "main"}, -] -flow_verse.sync_dependencies(dependencies) - # cf-code from .CF_Code import CF_Code # lc-code diff --git a/src/data_transformations/testing_results_summary_generation.py b/src/data_transformations/testing_results_summary_generation.py index 832f006353be910a118f46509d4da83ccb346c4d..74071dac7885af0a610ff6f5bf2a2a09c9ee4561 100644 --- a/src/data_transformations/testing_results_summary_generation.py +++ b/src/data_transformations/testing_results_summary_generation.py @@ -17,7 +17,7 @@ class TestingResultsSummaryGeneration(DataTransformation): data_dict[self.output_key] = self.params["no_error_template"] return data_dict - test_data = unflatten_dict(data_dict)["raw_response"] + test_data = unflatten_dict(data_dict) if not test_data["compilation_status"]: # compilation error occurred