Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- models.py +5 -5
- server/safe_code_env_environment.py +3 -3
models.py
CHANGED
|
@@ -60,13 +60,13 @@ class SafeCodeObservation(Observation):
|
|
| 60 |
error: str = Field(default="", description="Error details if the tool failed")
|
| 61 |
error_code: str = Field(default="", description="Structured error category for failures")
|
| 62 |
exit_code: int = Field(default=0, description="Exit code for command execution")
|
| 63 |
-
reward: float = Field(default=0.
|
| 64 |
done: bool = Field(default=False, description="Whether the episode is complete")
|
| 65 |
passed_tests: int = Field(default=0, description="Tests passed in current workspace")
|
| 66 |
failed_tests: int = Field(default=0, description="Tests failed/errors in current workspace")
|
| 67 |
feedback: str = Field(default="", description="Environment/grader feedback")
|
| 68 |
-
safety_score: float = Field(default=
|
| 69 |
-
completion_score: float = Field(default=0.
|
| 70 |
task_id: str = Field(default="", description="Current task identifier")
|
| 71 |
task_description: str = Field(default="", description="Task instructions")
|
| 72 |
workspace_path: str = Field(default="", description="Absolute seeded workspace path")
|
|
@@ -87,5 +87,5 @@ class SafeCodeState(State):
|
|
| 87 |
available_tools: List[str] = Field(default_factory=list, description="Exposed tools")
|
| 88 |
last_command: str = Field(default="", description="Last executed command")
|
| 89 |
last_exit_code: int = Field(default=0, description="Last command exit code")
|
| 90 |
-
last_safety_score: float = Field(default=
|
| 91 |
-
last_completion_score: float = Field(default=0.
|
|
|
|
| 60 |
error: str = Field(default="", description="Error details if the tool failed")
|
| 61 |
error_code: str = Field(default="", description="Structured error category for failures")
|
| 62 |
exit_code: int = Field(default=0, description="Exit code for command execution")
|
| 63 |
+
reward: float = Field(default=0.0, description="Reward for this step")
|
| 64 |
done: bool = Field(default=False, description="Whether the episode is complete")
|
| 65 |
passed_tests: int = Field(default=0, description="Tests passed in current workspace")
|
| 66 |
failed_tests: int = Field(default=0, description="Tests failed/errors in current workspace")
|
| 67 |
feedback: str = Field(default="", description="Environment/grader feedback")
|
| 68 |
+
safety_score: float = Field(default=1.0, description="Safety score from rules + BGE")
|
| 69 |
+
completion_score: float = Field(default=0.0, description="Completion score from tests")
|
| 70 |
task_id: str = Field(default="", description="Current task identifier")
|
| 71 |
task_description: str = Field(default="", description="Task instructions")
|
| 72 |
workspace_path: str = Field(default="", description="Absolute seeded workspace path")
|
|
|
|
| 87 |
available_tools: List[str] = Field(default_factory=list, description="Exposed tools")
|
| 88 |
last_command: str = Field(default="", description="Last executed command")
|
| 89 |
last_exit_code: int = Field(default=0, description="Last command exit code")
|
| 90 |
+
last_safety_score: float = Field(default=1.0, description="Last safety score")
|
| 91 |
+
last_completion_score: float = Field(default=0.0, description="Last completion score")
|
server/safe_code_env_environment.py
CHANGED
|
@@ -427,7 +427,7 @@ class SafeCodeEnvironment(Environment):
|
|
| 427 |
|
| 428 |
self._state.last_command = command
|
| 429 |
|
| 430 |
-
reward = 0.
|
| 431 |
feedback = f"Command exited with code {result.returncode}."
|
| 432 |
passed_tests = 0
|
| 433 |
failed_tests = 0
|
|
@@ -760,14 +760,14 @@ class SafeCodeEnvironment(Environment):
|
|
| 760 |
self._last_test_progress = progress
|
| 761 |
dense = 0.04 + (0.50 * progress) + (0.35 * max(delta, 0.0)) - (0.20 * max(-delta, 0.0))
|
| 762 |
blended = (0.60 * base_reward) + (0.40 * dense)
|
| 763 |
-
return round(max(0.
|
| 764 |
|
| 765 |
def _apply_final_reward_adjustments(self, reward: float) -> float:
|
| 766 |
extra_steps = max(0, self._state.step_count - 6)
|
| 767 |
step_penalty = min(0.12, extra_steps * 0.01)
|
| 768 |
error_penalty = min(0.15, self._tool_error_count * 0.02)
|
| 769 |
adjusted = reward - step_penalty - error_penalty
|
| 770 |
-
return round(max(0.
|
| 771 |
|
| 772 |
def _ensure_workspace(self) -> None:
|
| 773 |
if self._workspace_path is None:
|
|
|
|
| 427 |
|
| 428 |
self._state.last_command = command
|
| 429 |
|
| 430 |
+
reward = 0.0
|
| 431 |
feedback = f"Command exited with code {result.returncode}."
|
| 432 |
passed_tests = 0
|
| 433 |
failed_tests = 0
|
|
|
|
| 760 |
self._last_test_progress = progress
|
| 761 |
dense = 0.04 + (0.50 * progress) + (0.35 * max(delta, 0.0)) - (0.20 * max(-delta, 0.0))
|
| 762 |
blended = (0.60 * base_reward) + (0.40 * dense)
|
| 763 |
+
return round(max(0.0, min(0.95, blended)), 3)
|
| 764 |
|
| 765 |
def _apply_final_reward_adjustments(self, reward: float) -> float:
|
| 766 |
extra_steps = max(0, self._state.step_count - 6)
|
| 767 |
step_penalty = min(0.12, extra_steps * 0.01)
|
| 768 |
error_penalty = min(0.15, self._tool_error_count * 0.02)
|
| 769 |
adjusted = reward - step_penalty - error_penalty
|
| 770 |
+
return round(max(0.0, min(1.0, adjusted)), 3)
|
| 771 |
|
| 772 |
def _ensure_workspace(self) -> None:
|
| 773 |
if self._workspace_path is None:
|