Skip to main content

A Python framework for building RL environments with objective and subjective evaluation

Project description

Hyperbolic

A Python framework for building RL environments that generate training-grade trajectories across any domain -- browser tasks, text tasks, coding tasks, and beyond.

Installation

pip install htc-env

For browser environments, run the one-time setup after install:

htc setup

Quick Start

import hyperbolic as htc

dataset = htc.Dataset.from_list([
    {"question": "What is 2+2?", "answer": "4"},
    {"question": "What is 3*5?", "answer": "15"},
])

def correct_answer(completion, answer):
    response = completion[-1]["content"]
    return 1.0 if answer in response else 0.0

rubric = htc.Rubric(funcs=[correct_answer])
env = htc.SingleTurnEnv(dataset=dataset, rubric=rubric, system_prompt="Answer concisely.")
agent = htc.OpenAIAgent(model="gpt-4o-mini")
trajectories = env.run(agent)

for t in trajectories:
    print(f"Task: {t.task['question']}, Reward: {t.scalar_reward:.1f}")

Browser Environment

import hyperbolic as htc

dataset = htc.Dataset.from_list([{
    "task": "Find the headphones product and add it to the cart.",
    "start_url": "http://localhost:5001",
    "reset_url": "http://localhost:5001/api/reset",
}])

rubric = htc.Rubric()
rubric.add(htc.URLMatch(pattern=r"/cart"), weight=0.5, dimension="reached_cart")

env = htc.BrowserEnv(
    dataset=dataset,
    rubric=rubric,
    max_turns=10,
    browser_config=htc.BrowserConfig(headless=False),
)

agent = htc.OpenAIAgent(model="gpt-4o", tool_choice="required")
trajectories = env.run(agent)

CLI

htc run examples/simple_math.py -m gpt-4o-mini
htc run examples/browser_task.py -m gpt-4o
htc --version

Environment Types

  • TextEnv -- single-turn or multi-turn text interactions with optional tool calling
  • BrowserEnv -- browser automation via Playwright with screenshot observations

Key Features

  • Multi-dimensional evaluation (accuracy, tone, helpfulness as separate scoring axes)
  • Judge panels with disagreement tracking
  • Pluggable model interface (OpenAI, Anthropic, custom)
  • Deterministic browser environment resets
  • Standardized trajectory output format

API Keys

Create a .env file in your project root:

OPENAI_API_KEY=sk-...

Keys are resolved in order: explicit parameter > .env file > system env var.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htc_env-0.1.2.tar.gz (290.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

htc_env-0.1.2-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file htc_env-0.1.2.tar.gz.

File metadata

  • Download URL: htc_env-0.1.2.tar.gz
  • Upload date:
  • Size: 290.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for htc_env-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5aefad3efa39e131e5d2989199df8ce74497ca576235820e13fda582717e6c1b
MD5 80a49f5534449bce28f2616782c07320
BLAKE2b-256 5c32aa0219419cd86f8f32ad0ab2f6045d4a2f727e7212a10b9fad504e5f29ac

See more details on using hashes here.

File details

Details for the file htc_env-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: htc_env-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for htc_env-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 81c7bad6adac76d20df618dbc7dcbf64a9ea3a810ab97e942c33495f641c6232
MD5 d2a6a9b1f224728a7f1ce6b4583f9d76
BLAKE2b-256 c438f21fd0a70ab2447b52cfef5128d1d3906184ab6fad5cac8b93d9d447cd66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page