MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / match_response

Function match_response

utils/wei_utils.py:199–215  ·  view source on GitHub ↗
(response)

Source from the content-addressed store, hash-verified

197
198
199def 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
217def run_code_with_utils(code, utils_functions):
218 return run_code(utils_functions + '\n' + code)

Callers 5

run_code_from_agentFunction · 0.85
edit_modularFunction · 0.85
fill_contentFunction · 0.85
gen_layoutFunction · 0.85
gen_layout_parallelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected