Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion openadapt_evals/training/trl_rollout.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
import logging
import re
import time
from typing import Any, Callable
from typing import Any, Callable, Optional

from pydantic import BaseModel

from openadapt_evals.adapters.base import BenchmarkAction, BenchmarkObservation
from openadapt_evals.adapters.rl_env import RLEnvironment, ResetConfig
Expand Down Expand Up @@ -99,6 +101,28 @@
ACTION_REGEX = r"Thought: [^\n]+\nAction: (" + _ACTION_RE + r")"


# ---------------------------------------------------------------------------
# JSON schema for future Outlines JSON-mode constrained decoding
# ---------------------------------------------------------------------------
# When the model is SFT'd on JSON format (not DSL), switch constrained
# decoding to: outlines.json(model, _AgentOutput) instead of regex.
# This is NOT the default — the default uses DSL regex (ACTION_REGEX).
class _AgentOutput(BaseModel):
"""Pydantic schema for Outlines JSON-mode constrained decoding.

Use with: ``outlines.json(model, _AgentOutput)`` once the model has
been SFT'd on JSON action format. Currently unused — default is DSL
regex via ACTION_REGEX.
"""

reasoning: str
type: str # click, type, key, scroll, wait, done
x: Optional[float] = None
y: Optional[float] = None
text: Optional[str] = None
key: Optional[str] = None


def _build_outlines_generator(model: Any, processor: Any) -> Any | None:
"""Build an Outlines Generator for constrained generation.

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies = [
"pyyaml>=6.0",
"openadapt-consilium>=0.3.2",
"openadapt-telemetry>=0.2.0",
"openadapt-types>=0.1.0",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -148,6 +149,7 @@ Documentation = "https://github.com/OpenAdaptAI/openadapt-evals#readme"
[tool.uv.sources]
openadapt-consilium = { git = "https://github.com/OpenAdaptAI/openadapt-consilium.git" }
openadapt-ml = { path = "../openadapt-ml", editable = true }
openadapt-types = { path = "../openadapt-types", editable = true }

[tool.hatch.build.targets.wheel]
packages = ["openadapt_evals", "scripts"]
Expand Down
16 changes: 15 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading