Spaces:
Sleeping
Sleeping
Commit ·
0d0be12
1
Parent(s): ee6d0b2
fix: clamp all scores to strictly open interval (0.01, 0.99) to satisfy OpenEnv task validation
Browse files- app/models.py +2 -2
- app/reward.py +4 -11
app/models.py
CHANGED
|
@@ -32,8 +32,8 @@ class Reward(BaseModel):
|
|
| 32 |
@field_validator("score")
|
| 33 |
@classmethod
|
| 34 |
def validate_score(cls, v: float) -> float:
|
| 35 |
-
if not (0.0 <
|
| 36 |
-
raise ValueError("Score must be between 0.0 and 1.0")
|
| 37 |
return v
|
| 38 |
|
| 39 |
class StepResponse(BaseModel):
|
|
|
|
| 32 |
@field_validator("score")
|
| 33 |
@classmethod
|
| 34 |
def validate_score(cls, v: float) -> float:
|
| 35 |
+
if not (0.0 < v < 1.0):
|
| 36 |
+
raise ValueError("Score must be strictly between 0.0 and 1.0 (exclusive)")
|
| 37 |
return v
|
| 38 |
|
| 39 |
class StepResponse(BaseModel):
|
app/reward.py
CHANGED
|
@@ -42,12 +42,8 @@ class RewardEngine:
|
|
| 42 |
|
| 43 |
def _compute_score(self, st: Dict[str, Any]) -> float:
|
| 44 |
total = float(sum(st["awarded"].values()))
|
| 45 |
-
#
|
| 46 |
-
|
| 47 |
-
total = 0.0
|
| 48 |
-
if total > 1.0:
|
| 49 |
-
total = 1.0
|
| 50 |
-
return total
|
| 51 |
|
| 52 |
def compute_reward(
|
| 53 |
self,
|
|
@@ -158,11 +154,8 @@ class RewardEngine:
|
|
| 158 |
else:
|
| 159 |
total_score = self._compute_score(st)
|
| 160 |
|
| 161 |
-
# Clamp final score to
|
| 162 |
-
|
| 163 |
-
total_score = 0.0
|
| 164 |
-
if total_score > 1.0:
|
| 165 |
-
total_score = 1.0
|
| 166 |
|
| 167 |
# Prepare message and cumulative partials
|
| 168 |
message = ", ".join(msg_parts) if msg_parts else "no reward"
|
|
|
|
| 42 |
|
| 43 |
def _compute_score(self, st: Dict[str, Any]) -> float:
|
| 44 |
total = float(sum(st["awarded"].values()))
|
| 45 |
+
# Clamp to strictly open interval (0.01, 0.99)
|
| 46 |
+
return max(0.01, min(0.99, total))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
def compute_reward(
|
| 49 |
self,
|
|
|
|
| 154 |
else:
|
| 155 |
total_score = self._compute_score(st)
|
| 156 |
|
| 157 |
+
# Clamp final score to strictly open interval (0.01, 0.99)
|
| 158 |
+
total_score = max(0.01, min(0.99, total_score))
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
# Prepare message and cumulative partials
|
| 161 |
message = ", ".join(msg_parts) if msg_parts else "no reward"
|