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"
)
| 76 | |
| 77 | |
| 78 | def 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 | |
| 95 | def parse_full_rewrite(llm_response: str, language: str = "python") -> Optional[str]: |
no outgoing calls