MCPcopy Create free account
hub / github.com/bruno686/VisPlay / extract_answer

Function extract_answer

train_examples/reward_function/validation.py:93–102  ·  view source on GitHub ↗

Extracts the content of the … block from `predict`. Returns the inner text (with leading/trailing whitespace stripped), or None if no tag is found.

(predict: str)

Source from the content-addressed store, hash-verified

91 return match.group(1).strip()
92
93def extract_answer(predict: str) -> Optional[str]:
94 """
95 Extracts the content of the <answer>…</answer> block from `predict`.
96 Returns the inner text (with leading/trailing whitespace stripped),
97 or None if no <answer> tag is found.
98 """
99 match = re.search(r"<answer>([\s\S]*?)</answer>", predict, re.DOTALL)
100 if not match:
101 return predict
102 return match.group(1).strip()
103
104def accuracy_reward(predict: str, ground_truth: str) -> float:
105 answer = extract_boxed_content(predict)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected