MCPcopy Create free account
hub / github.com/InternScience/SciReason / wizardcoder_postprocess

Function wizardcoder_postprocess

tools/collect_code_preds.py:73–88  ·  view source on GitHub ↗

Postprocess for WizardCoder Models.

(text: str)

Source from the content-addressed store, hash-verified

71
72
73def wizardcoder_postprocess(text: str) -> str:
74 """Postprocess for WizardCoder Models."""
75 if '```' in text:
76 blocks = re.findall(r'```(.*?)```', text, re.DOTALL)
77 if len(blocks) == 0:
78 text = text.split('```')[1] # fall back to default strategy
79 else:
80 text = blocks[0] # fetch the first code block
81 if not text.startswith('\n'): # in case starting with ```python
82 text = text[max(text.find('\n') + 1, 0):]
83 else:
84 match = re.search(r'Here(.*?)\n', text)
85 if match:
86 text = re.sub('Here(.*?)\n', '', text, count=1)
87
88 return text
89
90
91def collect_preds(filename: str):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected