# 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 Ask Answer Env Environment. A slot-filling environment where agents must decide between asking clarifying questions or answering early. """ from typing import Literal, Optional from pydantic import BaseModel, Field from openenv.core.env_server.types import Action, Observation class AskAnswerAction(Action): """ Action for the Ask Answer Env environment. Two action types: - "ask": Ask about a specific slot (city, date, budget, or style) - "answer": Provide final answer with slot values """ type: Literal["ask", "answer"] = Field(..., description="Action type: 'ask' or 'answer'") slot: Optional[Literal["city", "date", "budget", "style"]] = Field( default=None, description="Slot to ask about (only for 'ask' type)" ) city: Optional[str] = Field(default=None, description="City answer (only for 'answer' type)") date: Optional[str] = Field(default=None, description="Date answer (only for 'answer' type)") budget: Optional[str] = Field(default=None, description="Budget answer (only for 'answer' type)") style: Optional[str] = Field(default=None, description="Style answer (only for 'answer' type)") class KnownSlots(BaseModel): """Slots that have been revealed to the agent.""" city: Optional[str] = Field(default=None, description="Known city value") date: Optional[str] = Field(default=None, description="Known date value") budget: Optional[str] = Field(default=None, description="Known budget value") style: Optional[str] = Field(default=None, description="Known style value") class AskAnswerObservation(Observation): """Observation from the Ask Answer Env environment.""" prompt: str = Field(default="Plan a short trip for me.", description="The user prompt") known: KnownSlots = Field(default_factory=KnownSlots, description="Currently known slot values") steps_left: int = Field(default=3, description="Number of steps remaining") # Correctness info (populated when done=True after ANSWER action) core_correct_count: Optional[int] = Field( default=None, description="Number of core slots correct (0-3), None if not answered yet" )