Spaces:
Sleeping
Sleeping
Upload models.py with huggingface_hub
Browse files
models.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
Data models for the Code Refactor Gym Environment.
|
| 9 |
+
|
| 10 |
+
The code_refactor_gym environment teaches agents to refactor legacy code into modern,
|
| 11 |
+
maintainable code with improved quality metrics.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from pydantic import Field
|
| 15 |
+
|
| 16 |
+
from openenv.core.env_server.types import Action, Observation
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class CodeRefactorGymAction(Action):
|
| 20 |
+
"""Action for the Code Refactor Gym environment - refactored code submission."""
|
| 21 |
+
|
| 22 |
+
refactored_code: str = Field(..., description="The refactored version of the legacy code")
|
| 23 |
+
reasoning: str = Field(default="", description="Explanation of refactoring changes made")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class CodeRefactorGymObservation(Observation):
|
| 27 |
+
"""Observation from the Code Refactor Gym environment - feedback on refactoring."""
|
| 28 |
+
|
| 29 |
+
legacy_code: str = Field(default="", description="The original legacy code to refactor")
|
| 30 |
+
test_results: dict = Field(default_factory=dict, description="Test execution results")
|
| 31 |
+
quality_metrics: dict = Field(default_factory=dict, description="Code quality metrics")
|
| 32 |
+
syntax_valid: bool = Field(default=True, description="Whether the refactored code has valid syntax")
|
| 33 |
+
error_message: str = Field(default="", description="Error message if syntax is invalid")
|
| 34 |
+
improvement_score: float = Field(default=0.0, description="Overall improvement score (0-100)")
|