Skip to content

Commit 065adbd

Browse files
Benny ChenBenny Chen
authored andcommitted
fix tests
1 parent d94b2e4 commit 065adbd

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

eval_protocol/rewards/code_execution.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,15 @@ def fractional_code_reward(
10981098
},
10991099
)
11001100

1101-
code_blocks = extract_code_blocks(response_content, language)
1101+
# Normalize content to string; Message.content may be str or list of content parts
1102+
_last_content = response_content
1103+
response_content_str = (
1104+
_last_content
1105+
if isinstance(_last_content, str)
1106+
else "".join([getattr(p, "text", "") for p in (_last_content or [])])
1107+
)
1108+
1109+
code_blocks = extract_code_blocks(response_content_str, language)
11021110

11031111
if not code_blocks:
11041112
return EvaluateResult(
@@ -1617,7 +1625,7 @@ class Capturing(list):
16171625
def __enter__(self):
16181626
self._stdout = sys.stdout
16191627
sys.stdout = self._stringio = StringIO()
1620-
self._stringio.close = lambda x: None
1628+
self._stringio.close = lambda: None
16211629
return self
16221630

16231631
def __exit__(self, *args):

eval_protocol/rewards/deepcoder_reward.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ def deepcoder_code_reward(
7373
is_score_valid=False,
7474
)
7575

76-
assistant_content = messages[-1].content
76+
assistant_content_raw = messages[-1].content
77+
assistant_content = (
78+
assistant_content_raw
79+
if isinstance(assistant_content_raw, str)
80+
else "".join([getattr(p, "text", "") for p in (assistant_content_raw or [])])
81+
)
7782
test_cases = ground_truth
7883

7984
code_blocks = extract_code_blocks(assistant_content, language)

eval_protocol/rewards/list_comparison_math_reward.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ def list_comparison_math_reward(
127127
},
128128
)
129129

130-
gen_content = messages[-1].content
130+
gen_content_raw = messages[-1].content
131+
gen_content = (
132+
gen_content_raw
133+
if isinstance(gen_content_raw, str)
134+
else "".join([getattr(p, "text", "") for p in (gen_content_raw or [])])
135+
)
131136
orig_content = ground_truth
132137

133138
if not gen_content:

eval_protocol/rewards/multiple_choice_math_reward.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ def multiple_choice_math_reward(
134134
if messages and len(messages) > 0:
135135
gen_response_message = messages[-1]
136136
if gen_response_message.role == "assistant":
137-
gen_content = gen_response_message.content or ""
137+
raw_gen_content = gen_response_message.content
138+
gen_content = (
139+
raw_gen_content
140+
if isinstance(raw_gen_content, str)
141+
else "".join([getattr(p, "text", "") for p in (raw_gen_content or [])])
142+
)
138143

139144
if not gen_content:
140145
metrics["error_generated_message"] = MetricResult(
@@ -152,7 +157,12 @@ def multiple_choice_math_reward(
152157
if ground_truth and len(ground_truth) > 0:
153158
orig_response_message = ground_truth[0]
154159
if orig_response_message.role == "assistant":
155-
orig_content = orig_response_message.content or ""
160+
raw_orig_content = orig_response_message.content
161+
orig_content = (
162+
raw_orig_content
163+
if isinstance(raw_orig_content, str)
164+
else "".join([getattr(p, "text", "") for p in (raw_orig_content or [])])
165+
)
156166

157167
if not orig_content:
158168
metrics["error_original_message"] = MetricResult(

eval_protocol/typed_interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def decorator(func: F) -> F:
8181
has_var_keyword = any(param.kind == inspect.Parameter.VAR_KEYWORD for param in params.values())
8282

8383
if not has_var_keyword:
84-
# Return a wrapper that preserves the original signature, but adds **kwargs dynamically
85-
# instead of raising at decoration time.
86-
pass
84+
raise ValueError(
85+
f"Function '{func.__name__}' must accept **kwargs parameter. Please add '**kwargs' to the function signature."
86+
)
8787

8888
# Setup resources once when the decorator is applied
8989
resource_managers = {}

0 commit comments

Comments
 (0)