MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/openevolve / extract_diffs

Function extract_diffs

openevolve/utils/code_utils.py:78–92  ·  view source on GitHub ↗

Extract diff blocks from the diff text Args: diff_text: Diff in the SEARCH/REPLACE format diff_pattern: Regex pattern for the SEARCH/REPLACE format Returns: List of tuples (search_text, replace_text)

(
    diff_text: str, diff_pattern: str = r"<<<<<<< SEARCH\n(.*?)=======\n(.*?)>>>>>>> REPLACE"
)

Source from the content-addressed store, hash-verified

76
77
78def extract_diffs(
79 diff_text: str, diff_pattern: str = r"<<<<<<< SEARCH\n(.*?)=======\n(.*?)>>>>>>> REPLACE"
80) -> List[Tuple[str, str]]:
81 """
82 Extract diff blocks from the diff text
83
84 Args:
85 diff_text: Diff in the SEARCH/REPLACE format
86 diff_pattern: Regex pattern for the SEARCH/REPLACE format
87
88 Returns:
89 List of tuples (search_text, replace_text)
90 """
91 diff_blocks = re.findall(diff_pattern, diff_text, re.DOTALL)
92 return [(match[0].rstrip(), match[1].rstrip()) for match in diff_blocks]
93
94
95def parse_full_rewrite(llm_response: str, language: str = "python") -> Optional[str]:

Callers 4

test_extract_diffsMethod · 0.90
_run_iteration_workerFunction · 0.90
apply_diffFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_extract_diffsMethod · 0.72