rust_coder / models.py
Parthiban007's picture
Upload folder using huggingface_hub
090dc69 verified
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""
Data models for the Rust Coder Environment.
"""
from typing import Any, Dict, List
from openenv.core.env_server.types import Action, Observation
from pydantic import BaseModel, Field
class RustCoderAction(Action):
"""Action for the Rust Coder environment - contains the Rust code to evaluate."""
code: str = Field(default="", description="Rust source code to compile and run")
class RustCoderObservation(Observation):
"""Observation space for the Rust Coder environment."""
problem_description: str = Field(default="", description="The text description of the current coding task, including requirements.")
header_section: str = Field(default="", description="LeetCode-style header/scaffold (imports + signatures/types) for deterministic evaluation.")
compilation_success: bool = Field(default=False, description="Binary flag indicating if the last submission compiled.")
compilation_output: str = Field(default="", description="Raw stdout/stderr from the rustc compiler.")
test_results: List[Dict] = Field(default_factory=list, description="A list of results from automated test assertions.")
reward_breakdown: Dict = Field(default_factory=dict, description="Detailed components of the 0.0-1.0 reward.")
class TaskInfo(BaseModel):
"""Metadata for a single task exposed via GET /tasks."""
task_id: str
difficulty: str
description: str
action_schema: Dict[str, Any] = Field(default_factory=dict)