File size: 1,527 Bytes
0f67fc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc25e97
0f67fc2
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# source tree.

"""
Data models for the Prompt & Response Token Optimization Environment.
"""

from openenv.core.env_server.types import Action, Observation, State
from pydantic import Field


class TokenOptimiserAction(Action):
    """Action for the Token Optimiser environment - the optimized prompt."""

    optimized_prompt: str = Field(..., description="The optimized prompt sent to the LLM")


class TokenOptimiserObservation(Observation):
    """Observation from the Token Optimiser environment - LLM response and token metrics."""

    llm_response: str = Field(default="", description="The response from the LLM")
    input_tokens: int = Field(default=0, description="Number of tokens in the optimized prompt")
    output_tokens: int = Field(default=0, description="Number of tokens in the LLM response")
    reward: float = Field(default=0.0, description="Reward score for this step (0.0-1.0)")
    done_reason: str = Field(default="", description="Why the episode terminated (if done=true)")


class TokenOptimiserState(State):
    """State for the Token Optimiser environment."""

    original_prompt: str = Field(default="", description="The original user prompt/task")
    task_difficulty: str = Field(default="easy", description="Current task difficulty: easy/medium/hard")
    task_index: int = Field(default=0, description="Index of current task in task bank")