Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse filesFiles changed (3)
- models.py+4-3
- server/app.py+4-4
- server/python_env_environment.py+26-50
184 unmodified lines1851861871881891901919 unmodified lines201202203204205206207208209184 unmodified lines"""Structured review action emitted by a model or trainer."""# Primary UI Fields (7 benchmark + 3 template = 10 total)operation: str = Field(default="submit_findings", description="The operation to perform.")findings: List[ReviewFinding] = Field(default_factory=list, description="The findings list.")patched_code: Optional[str] = Field(default=None, description="The fixed source code.")9 unmodified linesdef validate_action_shape(self) -> "PythonReviewAction":"""Require the right fields for each action type."""# Bypass benchmark validation if using the template 'operation' style (e.g. submit_findings)if self.operation != "ADD_COMMENT":return selfif self.action_type == ActionType.ADD_COMMENT:missing = []184 unmodified lines1851861871881891901919 unmodified lines201202203204205206207208209210184 unmodified lines"""Structured review action emitted by a model or trainer."""# Primary UI Fields (7 benchmark + 3 template = 10 total)operation: str = Field(default="ADD_COMMENT", description="The operation to perform.")findings: List[ReviewFinding] = Field(default_factory=list, description="The findings list.")patched_code: Optional[str] = Field(default=None, description="The fixed source code.")9 unmodified linesdef validate_action_shape(self) -> "PythonReviewAction":"""Require the right fields for each action type."""# Legacy template actions still use string operations like `submit_findings`.# Benchmark actions should validate against `action_type`.if self.operation != "ADD_COMMENT":return selfif self.action_type == ActionType.ADD_COMMENT:missing = []
46 unmodified lines474849505152539 unmodified lines636465666768693 unmodified lines737475767778798081828346 unmodified linesTaskListResponse,)from .python_env_environment import (PythonEnvironment,get_current_state,get_health_response,get_metrics_response,9 unmodified linesTaskListResponse,)from server.python_env_environment import ( # type: ignorePythonEnvironment,get_current_state,get_health_response,get_metrics_response,3 unmodified lines# Create the app with web interface and README integrationapp = create_app(PythonEnvironment,PythonAction,PythonObservation,env_name="python_env",max_concurrent_envs=1, # increase this number to allow more concurrent WebSocket sessions)46 unmodified lines474849505152539 unmodified lines636465666768693 unmodified lines737475767778798081828346 unmodified linesTaskListResponse,)from .python_env_environment import (get_environment,get_current_state,get_health_response,get_metrics_response,9 unmodified linesTaskListResponse,)from server.python_env_environment import ( # type: ignoreget_environment,get_current_state,get_health_response,get_metrics_response,3 unmodified lines# Create the app with web interface and README integrationapp = create_app(get_environment,PythonAction,PythonObservation,env_name="python_env",max_concurrent_envs=1, # the shared environment is intended for one active session)
439 unmodified lines440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500439 unmodified linesreturn self._state# try:# from .review_runtime import ( # type: ignore...# )# --- App Interface Shims ---_GLOBAL_ENV: Optional[PythonEnvironment] = Nonedef _get_env() -> PythonEnvironment:global _GLOBAL_ENVif _GLOBAL_ENV is None:_GLOBAL_ENV = PythonEnvironment()return _GLOBAL_ENVdef get_current_state() -> PythonState:env = _get_env()obs = env._build_observation(feedback="State request", reward=0.0, done=False)# Convert PythonObservation to PythonState if neededreturn PythonState(episode_id=env.state.episode_id,current_step=env.state.step_count,task_id=obs.task.task_id if obs.task else None,difficulty=Difficulty(obs.task.difficulty) if obs.task else None,done=False,last_feedback=obs.feedback,)def get_health_response() -> HealthResponse:return HealthResponse(status="ok",environment="python_env",task_count=len(TASK_BANK),)def get_metrics_response() -> MetricsResponse:return MetricsResponse()def get_tasks_response() -> TaskListResponse:from .task_bank import load_task_catalogtry:tasks = load_task_catalog()except Exception:tasks = []# If using local TASK_BANK, convert themif not tasks:tasks = [TaskMetadata(task_id=tid,name=t.descriptor.title,difficulty=Difficulty(t.descriptor.difficulty),description=t.descriptor.objective,snippet_count=1,max_steps=t.descriptor.max_steps,)for tid, t in TASK_BANK.items()]return TaskListResponse(tasks=tasks)439 unmodified lines440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476439 unmodified linesreturn self._state# Compatibility bridge:# keep the old module path, but route the actual app/runtime through the# dataset-backed dense-reward benchmark implementation.try:from .review_runtime import (PythonReviewRuntime as _BenchmarkPythonEnvironment,get_current_state,get_health_response,get_metrics_response,get_tasks_response,)except ImportError:from server.review_runtime import ( # type: ignorePythonReviewRuntime as _BenchmarkPythonEnvironment,get_current_state,get_health_response,get_metrics_response,get_tasks_response,)_GLOBAL_ENV: Optional[_BenchmarkPythonEnvironment] = Nonedef get_environment() -> _BenchmarkPythonEnvironment:"""Return the shared benchmark environment used by the HTTP app."""global _GLOBAL_ENVif _GLOBAL_ENV is None:_GLOBAL_ENV = _BenchmarkPythonEnvironment()return _GLOBAL_ENVPythonEnvironment = _BenchmarkPythonEnvironment
models.py+4-3
server/app.py+4-4
server/python_env_environment.py+26-50