nip.code_validation.dataset_generation._extract_code_and_input#
- nip.code_validation.dataset_generation._extract_code_and_input(model_output: str) tuple[str | None, list[str], bool] [source]#
Extract the modified solution and problematic inputs from the model output.
This function uses regular expressions to parse the model output and extract:
Problematic inputs.
The modified solution.
A safety check to ensure the modified solution does not contain dangerous functions.
- Parameters:
model_output (str) – The output from the model containing problematic inputs and the modified solution.
- Returns:
modified_solution (str | None) – The modified solution extracted from the model output, or None if not found.
problematic_inputs (list[str]) – A list of problematic inputs extracted from the model output.
flag_unsafe (bool) – A flag indicating if the modified solution contains dangerous functions, and is therefore unsafe.