MCPcopy Index your code
hub / github.com/evalplus/evalplus / post_process

Function post_process

evalplus/perf/sampling.py:58–73  ·  view source on GitHub ↗

Post-process the LLM generated text to make it valid.

(text: str)

Source from the content-addressed store, hash-verified

56
57
58def post_process(text: str) -> Optional[str]:
59 """Post-process the LLM generated text to make it valid."""
60 if "\n```" not in text:
61 return None
62
63 # split ```python3 or ```python
64 text = re.split(r"\n```python3?\n", text)[1]
65 text = text.split("\n```")[0].strip()
66
67 # perform syntax check
68 if not syntax_check(text):
69 print(colored("⚠️ Syntax check failed for the code below:", "red"))
70 print(text[:256], "..." if len(text) > 256 else "")
71 return None
72
73 return text
74
75
76# returns:

Callers 1

mainFunction · 0.85

Calls 1

syntax_checkFunction · 0.85

Tested by

no test coverage detected