-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
The entire code is not being used for the previous code which causes a cascading issue in the next steps.
if self.previous_llm_code[prev_step] is None:
if (
(prob_id == "13" and prev_step == 5) or
(prob_id == "62" and prev_step == 0) or
(prob_id == "76" and prev_step == 2)
):
prev_file_path = Path(
"../data",
f"{prob_id}.{prev_step+1}.txt"
)
else:
prev_file_path = Path(
self.output_dir,
self._get_background_dir(),
f"{prob_id}.{prev_step + 1}.py"
)
if prev_file_path.is_file():
prev_file_content = prev_file_path.read_text(encoding='utf-8')
func_name = extract_function_name(
prob_data["sub_steps"][prev_step]["function_header"]
)
function_code = get_function_from_code(
prev_file_content, func_name
)
self.previous_llm_code[prev_step] = function_code
else:
raise Exception(f'Generating problem {prob_id} step {num_steps} ahead of step {prev_step + 1}.')
A simple fix to this is to not do any extraction from the .txt files and use the entire code as it is:
if self.previous_llm_code[prev_step] is None:
if (
(prob_id == "13" and prev_step == 5) or
(prob_id == "62" and prev_step == 0) or
(prob_id == "76" and prev_step == 2)
):
prev_file_path = Path(
"../data",
f"{prob_id}.{prev_step+1}.txt"
)
else:
prev_file_path = Path(
self.output_dir,
self._get_background_dir(),
f"{prob_id}.{prev_step + 1}.py"
)
if prev_file_path.is_file():
prev_file_content = prev_file_path.read_text(encoding='utf-8')
if (
(prob_id == "13" and prev_step == 5) or
(prob_id == "62" and prev_step == 0) or
(prob_id == "76" and prev_step == 2)
):
# Use the entire .txt content for these special cases
self.previous_llm_code[prev_step] = prev_file_content
else:
# Extract the function code for all other cases
func_name = extract_function_name(
prob_data["sub_steps"][prev_step]["function_header"]
)
function_code = get_function_from_code(
prev_file_content, func_name
)
self.previous_llm_code[prev_step] = function_code
else:
raise Exception(f'Generating problem {prob_id} step {num_steps} ahead of step {prev_step + 1}.')
Metadata
Metadata
Assignees
Labels
No labels