Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
models.py
CHANGED
|
@@ -184,19 +184,55 @@ class RewardSummary(BaseModel):
|
|
| 184 |
class PythonReviewAction(Action):
|
| 185 |
"""Structured review action emitted by a model or trainer."""
|
| 186 |
|
| 187 |
-
# Primary UI Fields (7 benchmark + 3 template = 10 total)
|
| 188 |
operation: str = Field(default="ADD_COMMENT", description="The operation to perform.")
|
| 189 |
findings: List[ReviewFinding] = Field(default_factory=list, description="The findings list.")
|
| 190 |
patched_code: Optional[str] = Field(default=None, description="The fixed source code.")
|
| 191 |
|
| 192 |
-
action_type: ActionType =
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
suggestion: Optional[str] = None
|
| 198 |
question: Optional[str] = None
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
@model_validator(mode="after")
|
| 201 |
def validate_action_shape(self) -> "PythonReviewAction":
|
| 202 |
"""Require the right fields for each action type."""
|
|
|
|
| 184 |
class PythonReviewAction(Action):
|
| 185 |
"""Structured review action emitted by a model or trainer."""
|
| 186 |
|
|
|
|
| 187 |
operation: str = Field(default="ADD_COMMENT", description="The operation to perform.")
|
| 188 |
findings: List[ReviewFinding] = Field(default_factory=list, description="The findings list.")
|
| 189 |
patched_code: Optional[str] = Field(default=None, description="The fixed source code.")
|
| 190 |
|
| 191 |
+
action_type: ActionType = Field(
|
| 192 |
+
default=ActionType.ADD_COMMENT,
|
| 193 |
+
description="Choose the review action: comment on a line, skip a clean line, ask for context, approve, or request changes.",
|
| 194 |
+
)
|
| 195 |
+
line_number: Optional[int] = Field(
|
| 196 |
+
default=None,
|
| 197 |
+
ge=1,
|
| 198 |
+
description="Required for ADD_COMMENT and SKIP_LINE. Enter the code line number you are acting on.",
|
| 199 |
+
)
|
| 200 |
+
issue_type: Optional[IssueType] = Field(
|
| 201 |
+
default=None,
|
| 202 |
+
description="Required for ADD_COMMENT. Pick the issue category for the selected line.",
|
| 203 |
+
)
|
| 204 |
+
severity: Optional[Severity] = Field(
|
| 205 |
+
default=None,
|
| 206 |
+
description="Required for ADD_COMMENT. Pick how serious the issue is.",
|
| 207 |
+
)
|
| 208 |
+
comment: Optional[str] = Field(
|
| 209 |
+
default=None,
|
| 210 |
+
description="Required for ADD_COMMENT. Also used for ASK_CONTEXT if you want to ask a question in plain text.",
|
| 211 |
+
)
|
| 212 |
suggestion: Optional[str] = None
|
| 213 |
question: Optional[str] = None
|
| 214 |
|
| 215 |
+
@classmethod
|
| 216 |
+
def model_json_schema(cls, *args, **kwargs):
|
| 217 |
+
"""Trim legacy fields from the generated UI schema."""
|
| 218 |
+
|
| 219 |
+
schema = super().model_json_schema(*args, **kwargs)
|
| 220 |
+
properties = schema.get("properties", {})
|
| 221 |
+
visible_fields = {
|
| 222 |
+
"action_type",
|
| 223 |
+
"line_number",
|
| 224 |
+
"issue_type",
|
| 225 |
+
"severity",
|
| 226 |
+
"comment",
|
| 227 |
+
}
|
| 228 |
+
schema["properties"] = {
|
| 229 |
+
name: value for name, value in properties.items() if name in visible_fields
|
| 230 |
+
}
|
| 231 |
+
schema["required"] = [
|
| 232 |
+
name for name in schema.get("required", []) if name in visible_fields
|
| 233 |
+
]
|
| 234 |
+
return schema
|
| 235 |
+
|
| 236 |
@model_validator(mode="after")
|
| 237 |
def validate_action_shape(self) -> "PythonReviewAction":
|
| 238 |
"""Require the right fields for each action type."""
|