hydra953/invoice-processing-env
0
1"""Pydantic models for the Invoice Processing OpenEnv environment."""2 3from typing import Optional4from pydantic import BaseModel, Field5 6 7class InvoiceAction(BaseModel):8 """Action submitted by the agent — a JSON answer string and optional explanation."""9 answer: str = Field(..., description="JSON string with extracted/processed invoice data")10 explanation: str = Field(default="", description="Optional reasoning text")11 12 13class InvoiceObservation(BaseModel):14 """Observation returned to the agent after each step or reset."""15 invoice_text: str = Field(default="", description="The raw invoice content to process")16 context: str = Field(default="", description="Additional context (PO data, exchange rates, historical invoices)")17 task_description: str = Field(default="", description="What the agent must accomplish")18 task_id: str = Field(default="", description="easy | medium | hard")19 difficulty: str = Field(default="", description="Difficulty level")20 attempt_number: int = Field(default=0, description="Current attempt count")21 max_attempts: int = Field(default=5, description="Maximum allowed attempts")22 feedback: str = Field(default="", description="Grader feedback from prior attempt")23 hint: str = Field(default="", description="Hint revealed after 2 failed attempts")24 error_message: str = Field(default="", description="Error message if agent JSON was malformed")25 done: bool = Field(default=False, description="Whether the episode is over")26 reward: float = Field(default=0.0, description="Score 0.0-1.0")27 28 29class InvoiceState(BaseModel):30 """Internal environment state tracked across steps."""31 episode_id: str = Field(default="")32 step_count: int = Field(default=0)33 task_id: str = Field(default="")34 difficulty: str = Field(default="")35 max_attempts: int = Field(default=5)36 last_score: float = Field(default=0.0)37 completed: bool = Field(default=False)38 