(response)
| 197 | |
| 198 | |
| 199 | def match_response(response): |
| 200 | response_text = response.msgs[0].content |
| 201 | |
| 202 | # This regular expression looks for text between ```python ... ``` |
| 203 | pattern = r'```python(.*?)```' |
| 204 | match = re.search(pattern, response_text, flags=re.DOTALL) |
| 205 | |
| 206 | if not match: |
| 207 | pattern = r'```(.*?)```' |
| 208 | match = re.search(pattern, response_text, flags=re.DOTALL) |
| 209 | |
| 210 | if match: |
| 211 | code_snippet = match.group(1).strip() |
| 212 | else: |
| 213 | # If there's no fenced code block, fallback to entire response or handle error |
| 214 | code_snippet = response_text |
| 215 | return code_snippet |
| 216 | |
| 217 | def run_code_with_utils(code, utils_functions): |
| 218 | return run_code(utils_functions + '\n' + code) |
no outgoing calls
no test coverage detected