hud-python 0.1.5__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hud-python might be problematic. Click here for more details.
- {hud_python-0.1.5 → hud_python-0.2.1}/.github/workflows/ci.yml +1 -1
- {hud_python-0.1.5 → hud_python-0.2.1}/.gitignore +1 -1
- {hud_python-0.1.5 → hud_python-0.2.1}/LICENSE +1 -1
- hud_python-0.2.1/PKG-INFO +181 -0
- hud_python-0.2.1/README.md +122 -0
- hud_python-0.2.1/docs/advanced/cla-details.mdx +92 -0
- hud_python-0.2.1/docs/advanced/custom-environments.mdx +96 -0
- hud_python-0.2.1/docs/advanced/environment-control.mdx +100 -0
- hud_python-0.2.1/docs/api/reference/adapters.mdx +201 -0
- hud_python-0.2.1/docs/api-reference/adapters.mdx +109 -0
- hud_python-0.2.1/docs/api-reference/env.mdx +97 -0
- hud_python-0.2.1/docs/api-reference/gym.mdx +36 -0
- hud_python-0.2.1/docs/api-reference/job.mdx +107 -0
- hud_python-0.2.1/docs/api-reference/task.mdx +43 -0
- hud_python-0.2.1/docs/api-reference/taskset.mdx +76 -0
- hud_python-0.2.1/docs/api-reference/trajectory.mdx +58 -0
- hud_python-0.2.1/docs/concepts/adapter.mdx +62 -0
- hud_python-0.2.1/docs/concepts/agent.mdx +62 -0
- hud_python-0.2.1/docs/concepts/environment.mdx +100 -0
- hud_python-0.2.1/docs/concepts/job.mdx +100 -0
- hud_python-0.2.1/docs/concepts/task.mdx +132 -0
- hud_python-0.2.1/docs/concepts/trajectory.mdx +73 -0
- hud_python-0.2.1/docs/docs.json +73 -0
- hud_python-0.2.1/docs/examples/basic.mdx +140 -0
- hud_python-0.2.1/docs/examples/claude-agent.mdx +98 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/docs/examples/custom-agent.mdx +28 -48
- hud_python-0.2.1/docs/favicon.png +0 -0
- hud_python-0.2.1/docs/installation.mdx +59 -0
- hud_python-0.2.1/docs/logo/HUD-light-optimized.svg +5 -0
- hud_python-0.2.1/docs/quickstart.mdx +124 -0
- hud_python-0.2.1/docs/running-your-agent.mdx +237 -0
- hud_python-0.2.1/environments/novnc_ubuntu/Dockerfile +1 -0
- hud_python-0.2.1/environments/novnc_ubuntu/pyproject.toml +17 -0
- hud_python-0.2.1/environments/novnc_ubuntu/src/novnc_ubuntu/__init__.py +6 -0
- hud_python-0.2.1/environments/novnc_ubuntu/src/novnc_ubuntu/pyautogui_rosetta.py +365 -0
- hud_python-0.2.1/environments/novnc_ubuntu/src/novnc_ubuntu/step.py +35 -0
- hud_python-0.2.1/environments/qa_controller/Dockerfile +16 -0
- hud_python-0.2.1/environments/qa_controller/pyproject.toml +15 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/__init__.py +3 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/evaluate/__init__.py +6 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/evaluate/matchers.py +135 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/info.py +76 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/setup/__init__.py +8 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/setup/question.py +43 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/step.py +46 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/utils/__init__.py +1 -0
- hud_python-0.2.1/environments/qa_controller/src/qa_controller/utils/state.py +43 -0
- hud_python-0.2.1/examples/README.md +32 -0
- hud_python-0.2.1/examples/browser_use.ipynb +119 -0
- hud_python-0.2.1/examples/inspect.ipynb +169 -0
- hud_python-0.2.1/examples/jobs.ipynb +72 -0
- hud_python-0.2.1/examples/local.ipynb +77 -0
- hud_python-0.2.1/examples/osworld.ipynb +238 -0
- hud_python-0.2.1/examples/tasks.ipynb +257 -0
- hud_python-0.2.1/hud/__init__.py +26 -0
- hud_python-0.2.1/hud/adapters/__init__.py +7 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/adapters/claude/adapter.py +9 -2
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/adapters/common/adapter.py +11 -10
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/adapters/common/types.py +34 -13
- hud_python-0.2.1/hud/adapters/operator/__init__.py +5 -0
- hud_python-0.2.1/hud/adapters/operator/adapter.py +97 -0
- hud_python-0.2.1/hud/agent/__init__.py +7 -0
- hud_python-0.2.1/hud/agent/base.py +109 -0
- hud_python-0.2.1/hud/agent/claude.py +207 -0
- hud_python-0.2.1/hud/agent/operator.py +208 -0
- hud_python-0.2.1/hud/env/__init__.py +11 -0
- hud_python-0.2.1/hud/env/client.py +35 -0
- hud_python-0.2.1/hud/env/docker_client.py +306 -0
- hud_python-0.2.1/hud/env/environment.py +354 -0
- hud_python-0.2.1/hud/env/local_docker_client.py +251 -0
- hud_python-0.2.1/hud/env/remote_client.py +185 -0
- hud_python-0.2.1/hud/env/remote_docker_client.py +221 -0
- hud_python-0.2.1/hud/evaluators/__init__.py +10 -0
- hud_python-0.2.1/hud/evaluators/base.py +31 -0
- hud_python-0.2.1/hud/evaluators/inspect.py +29 -0
- hud_python-0.2.1/hud/evaluators/judge.py +213 -0
- hud_python-0.2.1/hud/evaluators/match.py +163 -0
- hud_python-0.2.1/hud/evaluators/remote.py +78 -0
- hud_python-0.2.1/hud/gym.py +108 -0
- hud_python-0.2.1/hud/job.py +185 -0
- hud_python-0.2.1/hud/server/__init__.py +5 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/server/requests.py +87 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/settings.py +13 -2
- hud_python-0.2.1/hud/task.py +144 -0
- hud_python-0.2.1/hud/taskset.py +103 -0
- hud_python-0.2.1/hud/trajectory.py +90 -0
- hud_python-0.2.1/hud/types.py +65 -0
- hud_python-0.2.1/hud/utils/__init__.py +7 -0
- hud_python-0.2.1/hud/utils/common.py +96 -0
- hud_python-0.2.1/hud/utils/config.py +94 -0
- hud_python-0.2.1/hud/utils/telemetry.py +67 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/pyproject.toml +17 -9
- {hud_python-0.1.5 → hud_python-0.2.1}/tests/test_import.py +1 -1
- hud_python-0.1.5/PKG-INFO +0 -125
- hud_python-0.1.5/README.md +0 -68
- hud_python-0.1.5/agent/base.py +0 -10
- hud_python-0.1.5/agent/claude.py +0 -152
- hud_python-0.1.5/agent/response_agent.py +0 -53
- hud_python-0.1.5/docs/api-reference/adapters.mdx +0 -178
- hud_python-0.1.5/docs/api-reference/client.mdx +0 -183
- hud_python-0.1.5/docs/api-reference/env.mdx +0 -159
- hud_python-0.1.5/docs/concepts/adapter.mdx +0 -69
- hud_python-0.1.5/docs/concepts/client.mdx +0 -32
- hud_python-0.1.5/docs/concepts/environment.mdx +0 -93
- hud_python-0.1.5/docs/concepts/gym.mdx +0 -48
- hud_python-0.1.5/docs/installation.mdx +0 -63
- hud_python-0.1.5/docs/introduction.mdx +0 -24
- hud_python-0.1.5/docs/mint.json +0 -85
- hud_python-0.1.5/docs/quickstart.mdx +0 -150
- hud_python-0.1.5/examples/README.md +0 -44
- hud_python-0.1.5/examples/claude_osworld.ipynb +0 -202
- hud_python-0.1.5/hud/__init__.py +0 -22
- hud_python-0.1.5/hud/adapters/__init__.py +0 -5
- hud_python-0.1.5/hud/client.py +0 -200
- hud_python-0.1.5/hud/environment.py +0 -318
- hud_python-0.1.5/hud/gym.py +0 -22
- hud_python-0.1.5/hud/run.py +0 -208
- hud_python-0.1.5/hud/server/__init__.py +0 -5
- hud_python-0.1.5/hud/utils/__init__.py +0 -5
- hud_python-0.1.5/hud/utils/config.py +0 -7
- {hud_python-0.1.5 → hud_python-0.2.1}/.env.example +0 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/.github/workflows/release.yml +0 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/MANIFEST.in +0 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/docs/logo/HUD.svg +0 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/adapters/claude/__init__.py +0 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/adapters/common/__init__.py +0 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/hud/py.typed +0 -0
- {hud_python-0.1.5 → hud_python-0.2.1}/tests/__init__.py +0 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hud-python
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: SDK for the HUD evaluation platform.
|
|
5
|
+
Project-URL: Homepage, https://github.com/hud-evals/hud-sdk
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/hud-evals/hud-sdk/issues
|
|
7
|
+
Project-URL: Documentation, https://hud.so
|
|
8
|
+
Author-email: Human Union Data SDK <founders@hud.so>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2025 Human Union Data, Inc
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
38
|
+
Requires-Python: <3.14,>=3.10
|
|
39
|
+
Requires-Dist: aiodocker>=0.24.0
|
|
40
|
+
Requires-Dist: httpx<1,>=0.23.0
|
|
41
|
+
Requires-Dist: inspect-ai>=0.3.80
|
|
42
|
+
Requires-Dist: pillow>=11.1.0
|
|
43
|
+
Requires-Dist: pydantic-settings<3,>=2
|
|
44
|
+
Requires-Dist: pydantic<3,>=2
|
|
45
|
+
Requires-Dist: textdistance<5,>=4.5.0
|
|
46
|
+
Requires-Dist: toml>=0.10.2
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: anthropic; extra == 'dev'
|
|
49
|
+
Requires-Dist: dotenv; extra == 'dev'
|
|
50
|
+
Requires-Dist: ipykernel; extra == 'dev'
|
|
51
|
+
Requires-Dist: ipython<9; extra == 'dev'
|
|
52
|
+
Requires-Dist: jupyter-client; extra == 'dev'
|
|
53
|
+
Requires-Dist: jupyter-core; extra == 'dev'
|
|
54
|
+
Requires-Dist: openai; extra == 'dev'
|
|
55
|
+
Requires-Dist: pyright==1.1.364; extra == 'dev'
|
|
56
|
+
Requires-Dist: pytest<9,>=8.1.1; extra == 'dev'
|
|
57
|
+
Requires-Dist: ruff==0.9.8; extra == 'dev'
|
|
58
|
+
Description-Content-Type: text/markdown
|
|
59
|
+
|
|
60
|
+
# HUD
|
|
61
|
+
|
|
62
|
+
A Python SDK for creating, evaluating, and benchmarking agent interactions with web browsers and OS environments.
|
|
63
|
+
|
|
64
|
+
> **Early Release Notice**: This SDK is currently in early release status. The API is evolving and may change in future releases as we gather feedback and improve functionality.
|
|
65
|
+
|
|
66
|
+
[](https://pypi.org/project/hud-python/)
|
|
67
|
+
|
|
68
|
+
[📚 Documentation](https://documentation.hud.so) | [🏠 Homepage](https://hud.so)
|
|
69
|
+
|
|
70
|
+
## API Key Setup
|
|
71
|
+
|
|
72
|
+
Before getting started, you'll need to obtain an API key:
|
|
73
|
+
|
|
74
|
+
1. Visit [app.hud.so](https://app.hud.so) to create a free account and generate your API key
|
|
75
|
+
2. Set it in your environment or .env file:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
export HUD_API_KEY=your_api_key_here
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Quick Start
|
|
82
|
+
|
|
83
|
+
### Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install hud-python
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Simple Browser Example with Claude Computer Use
|
|
90
|
+
|
|
91
|
+
> This example uses the `@job("test-run")` decorator, so the results of this run will appear under the job named "test-run" on the your [HUD Jobs page](https://app.hud.so/jobs).
|
|
92
|
+
|
|
93
|
+
Make sure your have defined your `ANTRHOPIC_API_KEY` in environment variables to run Claude.
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import asyncio
|
|
97
|
+
from hud import gym, job
|
|
98
|
+
from hud.task import Task
|
|
99
|
+
from hud.agent import ClaudeAgent
|
|
100
|
+
|
|
101
|
+
@job("test-run")
|
|
102
|
+
async def main():
|
|
103
|
+
task = Task(
|
|
104
|
+
prompt="Insert the text 'capybara' into the search bar",
|
|
105
|
+
gym="hud-browser",
|
|
106
|
+
setup=("goto", "google.com"),
|
|
107
|
+
evaluate=("contains_text", "capybara")
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Create environment using the gym module
|
|
111
|
+
env = await gym.make(task)
|
|
112
|
+
|
|
113
|
+
# Initialize Operator agent (API key is loaded automatically)
|
|
114
|
+
agent = ClaudeAgent()
|
|
115
|
+
|
|
116
|
+
# Agent loop with predict and step functions
|
|
117
|
+
obs, _ = await env.reset() # Gets first observation
|
|
118
|
+
for i in range(5):
|
|
119
|
+
actions, done = await agent.predict(obs)
|
|
120
|
+
if done:
|
|
121
|
+
break
|
|
122
|
+
|
|
123
|
+
obs, reward, terminated, info = await env.step(actions)
|
|
124
|
+
|
|
125
|
+
# Evaluate and close
|
|
126
|
+
result = await env.evaluate()
|
|
127
|
+
print(f"Evaluation result: {result}")
|
|
128
|
+
await env.close()
|
|
129
|
+
|
|
130
|
+
if __name__ == "__main__":
|
|
131
|
+
asyncio.run(main())
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Documentation Sections
|
|
136
|
+
|
|
137
|
+
Explore the core concepts and features of the SDK:
|
|
138
|
+
|
|
139
|
+
* **[Tasks and TaskSets](/concepts/task)**: Define goals, context, setup, and evaluation criteria for agent scenarios. This includes both interactive and **question-answering (QA)** style tasks.
|
|
140
|
+
* **[Environments](/concepts/environment)**: Understand the browser and OS runtimes where agents interact.
|
|
141
|
+
* **[Agents](/concepts/agent)**: Learn about the agent architecture (Claude, Operator) and how they process observations and predict actions.
|
|
142
|
+
* **[Adapters](/concepts/adapter)**: See how actions and observations are translated between agents and environments.
|
|
143
|
+
* **[Jobs](/concepts/job)**: Group related runs for analysis and viewing on the HUD platform.
|
|
144
|
+
* **[Trajectories](/concepts/trajectory)**: Understand the recorded data from each agent run.
|
|
145
|
+
* **Advanced Topics**:
|
|
146
|
+
* **[CLA Action Details](/advanced/cla-details)**: Explore the standardized action format.
|
|
147
|
+
* **[Custom Environments](/advanced/custom-environments)**: Build your own Docker-based local or remote environments.
|
|
148
|
+
* **[Advanced Environment Control](/advanced/environment-control)**: Use `invoke`, `execute`, and `_setup` for finer control.
|
|
149
|
+
|
|
150
|
+
* **[Full API Reference](/api-reference/gym)**: Detailed specifications for all modules and classes.
|
|
151
|
+
|
|
152
|
+
## [Examples](examples/)
|
|
153
|
+
|
|
154
|
+
We recommend you first take a look at the example notebooks showing how to use the HUD SDK:
|
|
155
|
+
|
|
156
|
+
1. [Browser Basics](examples/browser_use.ipynb) - Simple browser interaction with live view
|
|
157
|
+
2. [Task Design](examples/tasks.ipynb) - Creating and customizing tasks
|
|
158
|
+
3. [OSWorld](examples/osworld.ipynb) - Running the OSWorld benchmark
|
|
159
|
+
4. [Local Development](examples/local.ipynb) - Setting up local custom environments
|
|
160
|
+
|
|
161
|
+
## Documentation
|
|
162
|
+
|
|
163
|
+
For comprehensive guides, examples, and API reference, visit [our docs](https://docs.hud.so/introduction)
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
[MIT License](LICENSE)
|
|
168
|
+
|
|
169
|
+
## Citation
|
|
170
|
+
|
|
171
|
+
If you use this SDK in your research, please cite it as follows:
|
|
172
|
+
|
|
173
|
+
```bibtex
|
|
174
|
+
@software{hud2025agentevalplatform,
|
|
175
|
+
author = {HUD and Jay Ram and Lorenss Martinsons and Parth Patel and Max Muoto and Oskars Putans and Govind Pimpale and Mayank Singamreddy and Nguyen Nhat Minh},
|
|
176
|
+
title = {{HUD: An Evaluation Platform for Agents}},
|
|
177
|
+
date = {2025-04},
|
|
178
|
+
url = {https://github.com/hud-evals/hud-sdk},
|
|
179
|
+
langid = {en}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# HUD
|
|
2
|
+
|
|
3
|
+
A Python SDK for creating, evaluating, and benchmarking agent interactions with web browsers and OS environments.
|
|
4
|
+
|
|
5
|
+
> **Early Release Notice**: This SDK is currently in early release status. The API is evolving and may change in future releases as we gather feedback and improve functionality.
|
|
6
|
+
|
|
7
|
+
[](https://pypi.org/project/hud-python/)
|
|
8
|
+
|
|
9
|
+
[📚 Documentation](https://documentation.hud.so) | [🏠 Homepage](https://hud.so)
|
|
10
|
+
|
|
11
|
+
## API Key Setup
|
|
12
|
+
|
|
13
|
+
Before getting started, you'll need to obtain an API key:
|
|
14
|
+
|
|
15
|
+
1. Visit [app.hud.so](https://app.hud.so) to create a free account and generate your API key
|
|
16
|
+
2. Set it in your environment or .env file:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
export HUD_API_KEY=your_api_key_here
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install hud-python
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Simple Browser Example with Claude Computer Use
|
|
31
|
+
|
|
32
|
+
> This example uses the `@job("test-run")` decorator, so the results of this run will appear under the job named "test-run" on the your [HUD Jobs page](https://app.hud.so/jobs).
|
|
33
|
+
|
|
34
|
+
Make sure your have defined your `ANTRHOPIC_API_KEY` in environment variables to run Claude.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import asyncio
|
|
38
|
+
from hud import gym, job
|
|
39
|
+
from hud.task import Task
|
|
40
|
+
from hud.agent import ClaudeAgent
|
|
41
|
+
|
|
42
|
+
@job("test-run")
|
|
43
|
+
async def main():
|
|
44
|
+
task = Task(
|
|
45
|
+
prompt="Insert the text 'capybara' into the search bar",
|
|
46
|
+
gym="hud-browser",
|
|
47
|
+
setup=("goto", "google.com"),
|
|
48
|
+
evaluate=("contains_text", "capybara")
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Create environment using the gym module
|
|
52
|
+
env = await gym.make(task)
|
|
53
|
+
|
|
54
|
+
# Initialize Operator agent (API key is loaded automatically)
|
|
55
|
+
agent = ClaudeAgent()
|
|
56
|
+
|
|
57
|
+
# Agent loop with predict and step functions
|
|
58
|
+
obs, _ = await env.reset() # Gets first observation
|
|
59
|
+
for i in range(5):
|
|
60
|
+
actions, done = await agent.predict(obs)
|
|
61
|
+
if done:
|
|
62
|
+
break
|
|
63
|
+
|
|
64
|
+
obs, reward, terminated, info = await env.step(actions)
|
|
65
|
+
|
|
66
|
+
# Evaluate and close
|
|
67
|
+
result = await env.evaluate()
|
|
68
|
+
print(f"Evaluation result: {result}")
|
|
69
|
+
await env.close()
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
asyncio.run(main())
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Documentation Sections
|
|
77
|
+
|
|
78
|
+
Explore the core concepts and features of the SDK:
|
|
79
|
+
|
|
80
|
+
* **[Tasks and TaskSets](/concepts/task)**: Define goals, context, setup, and evaluation criteria for agent scenarios. This includes both interactive and **question-answering (QA)** style tasks.
|
|
81
|
+
* **[Environments](/concepts/environment)**: Understand the browser and OS runtimes where agents interact.
|
|
82
|
+
* **[Agents](/concepts/agent)**: Learn about the agent architecture (Claude, Operator) and how they process observations and predict actions.
|
|
83
|
+
* **[Adapters](/concepts/adapter)**: See how actions and observations are translated between agents and environments.
|
|
84
|
+
* **[Jobs](/concepts/job)**: Group related runs for analysis and viewing on the HUD platform.
|
|
85
|
+
* **[Trajectories](/concepts/trajectory)**: Understand the recorded data from each agent run.
|
|
86
|
+
* **Advanced Topics**:
|
|
87
|
+
* **[CLA Action Details](/advanced/cla-details)**: Explore the standardized action format.
|
|
88
|
+
* **[Custom Environments](/advanced/custom-environments)**: Build your own Docker-based local or remote environments.
|
|
89
|
+
* **[Advanced Environment Control](/advanced/environment-control)**: Use `invoke`, `execute`, and `_setup` for finer control.
|
|
90
|
+
|
|
91
|
+
* **[Full API Reference](/api-reference/gym)**: Detailed specifications for all modules and classes.
|
|
92
|
+
|
|
93
|
+
## [Examples](examples/)
|
|
94
|
+
|
|
95
|
+
We recommend you first take a look at the example notebooks showing how to use the HUD SDK:
|
|
96
|
+
|
|
97
|
+
1. [Browser Basics](examples/browser_use.ipynb) - Simple browser interaction with live view
|
|
98
|
+
2. [Task Design](examples/tasks.ipynb) - Creating and customizing tasks
|
|
99
|
+
3. [OSWorld](examples/osworld.ipynb) - Running the OSWorld benchmark
|
|
100
|
+
4. [Local Development](examples/local.ipynb) - Setting up local custom environments
|
|
101
|
+
|
|
102
|
+
## Documentation
|
|
103
|
+
|
|
104
|
+
For comprehensive guides, examples, and API reference, visit [our docs](https://docs.hud.so/introduction)
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
[MIT License](LICENSE)
|
|
109
|
+
|
|
110
|
+
## Citation
|
|
111
|
+
|
|
112
|
+
If you use this SDK in your research, please cite it as follows:
|
|
113
|
+
|
|
114
|
+
```bibtex
|
|
115
|
+
@software{hud2025agentevalplatform,
|
|
116
|
+
author = {HUD and Jay Ram and Lorenss Martinsons and Parth Patel and Max Muoto and Oskars Putans and Govind Pimpale and Mayank Singamreddy and Nguyen Nhat Minh},
|
|
117
|
+
title = {{HUD: An Evaluation Platform for Agents}},
|
|
118
|
+
date = {2025-04},
|
|
119
|
+
url = {https://github.com/hud-evals/hud-sdk},
|
|
120
|
+
langid = {en}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'CLA Action Details'
|
|
3
|
+
description: 'Detailed look at the Common Language Action (CLA) format'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Common Language Action (CLA) Details
|
|
7
|
+
|
|
8
|
+
The HUD SDK uses a standardized format called **CLA** (Common Language Actions) for representing agent interactions within an [Environment](/concepts/environment). When your [Agent](/concepts/agent) decides on an action (e.g., "click at x=100, y=200"), its associated [Adapter](/concepts/adapter) converts this into a specific `CLA` Pydantic model instance before it's sent to `env.step()`.
|
|
9
|
+
|
|
10
|
+
Understanding the structure of these `CLA` types can be helpful for debugging or creating custom adapters/controllers. The main types are defined in `hud.adapters.common.types`.
|
|
11
|
+
|
|
12
|
+
## Base Structure
|
|
13
|
+
|
|
14
|
+
All CLA actions inherit from `CLAAction` and have a `type` field which acts as a discriminator:
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
class CLAAction(pydantic.BaseModel):
|
|
18
|
+
type: str
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Action Categories & Examples
|
|
22
|
+
|
|
23
|
+
Here are some key CLA types grouped by category:
|
|
24
|
+
|
|
25
|
+
### Mouse Actions
|
|
26
|
+
|
|
27
|
+
* **`ClickAction`**: Simulates mouse clicks.
|
|
28
|
+
* `point: Point | None`: Target coordinates (`Point(x: int, y: int)`).
|
|
29
|
+
* `button: Literal[...]`: `"left"`, `"right"`, `"wheel"`, `"back"`, `"forward"` (default: `"left"`).
|
|
30
|
+
* `pattern: list[int] | None`: List of delays (ms) for multi-clicks (e.g., `[100]` for double-click, `[100, 100]` for triple).
|
|
31
|
+
* `hold_keys: list[CLAKey] | None`: Modifier keys (e.g., `"shift"`, `"ctrl"`) to hold during the click.
|
|
32
|
+
* `selector: str | None`: Optional CSS selector to target instead of coordinates.
|
|
33
|
+
|
|
34
|
+
* **`MoveAction`**: Moves the mouse cursor.
|
|
35
|
+
* `point: Point | None`: Target coordinates.
|
|
36
|
+
* `selector: str | None`: Optional CSS selector to move to.
|
|
37
|
+
* `offset: Point | None`: Offset relative to the target point/selector.
|
|
38
|
+
|
|
39
|
+
* **`ScrollAction`**: Scrolls the view.
|
|
40
|
+
* `point: Point | None`: Coordinates *where* the scroll should originate (often ignored, scrolls the window).
|
|
41
|
+
* `scroll: Point | None`: Scroll amount `Point(x=dx, y=dy)`. Positive `dy` scrolls down, positive `dx` scrolls right.
|
|
42
|
+
* `hold_keys: list[CLAKey] | None`: Modifier keys to hold.
|
|
43
|
+
|
|
44
|
+
* **`DragAction`**: Simulates clicking and dragging.
|
|
45
|
+
* `path: list[Point]`: A sequence of points defining the drag path (must have at least two points).
|
|
46
|
+
* `pattern: list[int] | None`: Optional delays between path segments.
|
|
47
|
+
* `hold_keys: list[CLAKey] | None`: Modifier keys to hold.
|
|
48
|
+
|
|
49
|
+
### Keyboard Actions
|
|
50
|
+
|
|
51
|
+
* **`TypeAction`**: Types text.
|
|
52
|
+
* `text: str`: The text string to type.
|
|
53
|
+
* `selector: str | None`: Optional CSS selector to focus before typing.
|
|
54
|
+
* `enter_after: bool | None`: Whether to press Enter after typing (default: `False`).
|
|
55
|
+
|
|
56
|
+
* **`PressAction`**: Presses and releases one or more keys simultaneously (hotkey).
|
|
57
|
+
* `keys: list[CLAKey]`: List of key names (`CLAKey` Literal type) to press together (e.g., `["ctrl", "c"]`).
|
|
58
|
+
|
|
59
|
+
* **`KeyDownAction` / `KeyUpAction`**: Presses or releases keys without the corresponding up/down action. Useful for holding modifier keys.
|
|
60
|
+
* `keys: list[CLAKey]`: List of key names to press down or release up.
|
|
61
|
+
|
|
62
|
+
### Control Actions
|
|
63
|
+
|
|
64
|
+
* **`WaitAction`**: Pauses execution.
|
|
65
|
+
* `time: int`: Duration to wait in milliseconds.
|
|
66
|
+
|
|
67
|
+
### Fetch Actions (Get Information)
|
|
68
|
+
|
|
69
|
+
* **`ScreenshotFetch`**: Requests a screenshot (used internally, typically not sent by agents directly).
|
|
70
|
+
* **`PositionFetch`**: Requests the current cursor position (used internally).
|
|
71
|
+
|
|
72
|
+
### Custom Actions
|
|
73
|
+
|
|
74
|
+
* **`CustomAction`**: Allows defining arbitrary actions specific to a custom environment controller.
|
|
75
|
+
* `action: str`: The name/identifier of the custom action.
|
|
76
|
+
* *(Implicit)*: Any additional fields required by the custom action can be added if defined in the custom controller logic receiving it.
|
|
77
|
+
|
|
78
|
+
## `CLAKey` Type
|
|
79
|
+
|
|
80
|
+
The `CLAKey` is a `typing.Literal` containing dozens of standard key names, including:
|
|
81
|
+
|
|
82
|
+
* Control Keys: `"backspace"`, `"tab"`, `"enter"`, `"shift"`, `"ctrl"`, `"alt"`, `"escape"`, `"space"`, `"pageup"`, `"pagedown"`, `"end"`, `"home"`, `"left"`, `"up"`, `"right"`, `"down"`, `"insert"`, `"delete"`.
|
|
83
|
+
* Function Keys: `"f1"`, `"f2"`, ..., `"f24"`.
|
|
84
|
+
* Numpad Keys: `"num0"`, `"num1"`, ..., `"add"`, `"multiply"`, etc.
|
|
85
|
+
* Modifier Keys: `"win"`, `"command"`, `"option"`.
|
|
86
|
+
* Printable Characters: `"a"`, `"b"`, `"1"`, `"!"`, `"#"` etc. (Note: For typing sentences, use `TypeAction`).
|
|
87
|
+
|
|
88
|
+
Refer to `hud/adapters/common/types.py` for the exhaustive list.
|
|
89
|
+
|
|
90
|
+
## Usage Context
|
|
91
|
+
|
|
92
|
+
Remember, an [Agent](/concepts/agent) typically outputs actions in its model's native format. The [Adapter](/concepts/adapter) converts these raw actions into one or more of these specific `CLA` Pydantic model instances, which are then passed in a list to `env.step()`.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Custom Environments'
|
|
3
|
+
description: 'Define and run your own Docker-based environments locally or remotely'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Custom Environments
|
|
7
|
+
|
|
8
|
+
While the HUD SDK provides standard environments like `"hud-browser"` and `"OSWorld-Ubuntu"`, you can also define and run your own custom environments using Docker. This allows you to create specific testing scenarios with custom software stacks or configurations.
|
|
9
|
+
|
|
10
|
+
Custom environments are defined using the `CustomGym` type from `hud.types`.
|
|
11
|
+
|
|
12
|
+
## Defining a Custom Environment (`CustomGym`)
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from hud.types import CustomGym
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
# Example 1: Local Docker environment using a source directory
|
|
19
|
+
# Points to a directory containing controller code and a Dockerfile
|
|
20
|
+
local_env_spec = CustomGym(
|
|
21
|
+
location="local",
|
|
22
|
+
controller_source_dir="./my_custom_controller" # Path to your controller code
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Example 2: Remote Docker environment (built and run on HUD platform)
|
|
26
|
+
remote_env_spec = CustomGym(
|
|
27
|
+
location="remote",
|
|
28
|
+
# Dockerfile content is sent to HUD to build the image remotely
|
|
29
|
+
dockerfile="FROM ubuntu:latest\nRUN apt-get update && apt-get install -y my-package\n..."
|
|
30
|
+
)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Key `CustomGym` Attributes:**
|
|
34
|
+
|
|
35
|
+
* **`location` (`"local"` | `"remote"`):**
|
|
36
|
+
* `"local"`: Builds and runs the Docker container on your *local* machine. Requires Docker installed. Ideal for development. See [Local Environment Structure](#local-environment-structure) below.
|
|
37
|
+
* `"remote"`: Sends the `dockerfile` content to the HUD platform for remote build and execution. Good for sharing or running complex setups.
|
|
38
|
+
* **`dockerfile` (str | None):** The Dockerfile content.
|
|
39
|
+
* Required if `location="remote"`.
|
|
40
|
+
* Optional if `location="local"` and `controller_source_dir` is provided (will look for `Dockerfile` inside that directory).
|
|
41
|
+
* **`controller_source_dir` (str | `Path` | None):**
|
|
42
|
+
* *Only relevant for `location="local"`.*
|
|
43
|
+
* Path to your local directory containing the controller code and potentially the `Dockerfile`. This directory is mounted into the container.
|
|
44
|
+
|
|
45
|
+
## <a name="local-environment-structure"></a>Local Environment Structure
|
|
46
|
+
|
|
47
|
+
When creating a `local` custom environment, the directory specified by `controller_source_dir` typically contains:
|
|
48
|
+
|
|
49
|
+
1. **`Dockerfile`:** Defines the base image, system dependencies, Python dependencies (often via `pip install -e .`), and the command to run your controller script (`CMD [...]`).
|
|
50
|
+
2. **`pyproject.toml`:** Defines your controller as an installable Python package. The HUD SDK reads the `[project.name]` from this file to know how to import your controller code within the container after installation.
|
|
51
|
+
3. **`src/` (or your package name):** A directory containing your Python controller code. This code needs to implement the functions called by `setup`, `evaluate`, and `step` (e.g., interacting with applications inside the container, returning observations).
|
|
52
|
+
|
|
53
|
+
**Example Structure (`./my_custom_controller/`):**
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
my_custom_controller/
|
|
57
|
+
├── Dockerfile
|
|
58
|
+
├── pyproject.toml
|
|
59
|
+
└── src/
|
|
60
|
+
└── my_controller_pkg/
|
|
61
|
+
├── __init__.py
|
|
62
|
+
└── main.py # Your controller logic (e.g., setup, step functions)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
* **Examples:** The top-level `environments/` directory in the SDK repository contains reference implementations (like `novnc_ubuntu`) following this structure.
|
|
66
|
+
* **Dependencies:** For local custom environments, you might need to install development dependencies using `pip install -e ".[dev]"` in your SDK checkout to ensure the local components (like the Docker client) function correctly.
|
|
67
|
+
|
|
68
|
+
## Using a Custom Environment
|
|
69
|
+
|
|
70
|
+
Use your `CustomGym` object with `hud.gym.make()`:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from hud import gym
|
|
74
|
+
from hud.types import CustomGym
|
|
75
|
+
|
|
76
|
+
# Assuming local_env_spec = CustomGym(location="local", controller_source_dir="./my_custom_controller")
|
|
77
|
+
env = await gym.make(local_env_spec)
|
|
78
|
+
|
|
79
|
+
print("Custom local environment created.")
|
|
80
|
+
|
|
81
|
+
# Interact as usual - Task setup/evaluate calls functions in your controller
|
|
82
|
+
# task = Task(prompt="...", gym=local_env_spec, setup=("my_setup_func", arg1), ...)
|
|
83
|
+
# env = await gym.make(task)
|
|
84
|
+
# obs, _ = await env.reset()
|
|
85
|
+
# result = await env.evaluate()
|
|
86
|
+
|
|
87
|
+
await env.close()
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Creating a custom environment requires careful design of both the Dockerfile and the controller script to ensure they work together correctly.
|
|
91
|
+
|
|
92
|
+
## Related Concepts
|
|
93
|
+
|
|
94
|
+
* [Environment](/concepts/environment): The runtime instance created from the `CustomGym` spec.
|
|
95
|
+
* [Task](/concepts/task): Can specify a `CustomGym` object in its `gym` attribute to request your custom environment.
|
|
96
|
+
* [Advanced Environment Control](/advanced/environment-control): Using `invoke` and `execute` for debugging or advanced control.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Advanced Environment Control'
|
|
3
|
+
description: 'Using invoke, execute, and _setup for finer control over environments'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Advanced Environment Control
|
|
7
|
+
|
|
8
|
+
While the standard `step`, `evaluate`, and `close` methods cover most interactions, the `Environment` object provides lower-level methods for more direct control, particularly useful for custom environments, debugging, and complex setup/evaluation scenarios.
|
|
9
|
+
|
|
10
|
+
## `invoke`
|
|
11
|
+
|
|
12
|
+
The `env._invoke_all()` method (and its underlying `client.invoke()`) is the core mechanism for calling specific functions *within* the environment's controller script.
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
async def _invoke_all(self, configs: HudStyleConfigs) -> list[Any]: ...
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
* **Purpose:** Execute custom functions defined in your environment controller (the Python code running inside the Docker container or remote instance). This is how `setup` and `evaluate` configurations in a `Task` are ultimately executed.
|
|
19
|
+
* **Usage:** You provide a configuration (string, tuple, dict, or list) matching the `HudStyleConfigs` format. The SDK sends this to the environment controller, which runs the specified function(s) with the given arguments.
|
|
20
|
+
* **When to Use:**
|
|
21
|
+
* Triggering custom evaluation logic not suitable for the standard `evaluate` attribute.
|
|
22
|
+
* Running specific diagnostic or state-setting functions within your custom environment controller during development or debugging.
|
|
23
|
+
* Implementing complex, multi-step setup or teardown procedures beyond what's easily defined in the `Task` `setup`.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from hud.task import Task
|
|
27
|
+
from hud import gym
|
|
28
|
+
|
|
29
|
+
# Assume a custom environment controller has a function 'get_system_load()'
|
|
30
|
+
task = Task(prompt="Check system load", gym=...) # Using a CustomGym spec
|
|
31
|
+
|
|
32
|
+
env = await gym.make(task)
|
|
33
|
+
|
|
34
|
+
# Manually invoke the custom function
|
|
35
|
+
# Use the dictionary format for clarity
|
|
36
|
+
config = {"function": "get_system_load", "args": []}
|
|
37
|
+
results = await env._invoke_all(config)
|
|
38
|
+
system_load = results[0] # _invoke_all returns a list of results
|
|
39
|
+
|
|
40
|
+
print(f"Current system load: {system_load}")
|
|
41
|
+
|
|
42
|
+
await env.close()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## `execute`
|
|
46
|
+
|
|
47
|
+
The `client.execute()` method (accessible via `env.client.execute()` if `env.client` is a `DockerClient` subclass like `LocalDockerClient` or `RemoteDockerClient`) allows running arbitrary shell commands *inside* the environment container.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
# Assuming env.client is a LocalDockerClient or RemoteDockerClient
|
|
51
|
+
# Example: List files in the container's /tmp directory
|
|
52
|
+
result: ExecuteResult = await env.client.execute(
|
|
53
|
+
command=["ls", "-la", "/tmp"],
|
|
54
|
+
timeout=10 # Timeout in seconds
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
print("STDOUT:", result['stdout'].decode())
|
|
58
|
+
if result['stderr']:
|
|
59
|
+
print("STDERR:", result['stderr'].decode())
|
|
60
|
+
print("Exit Code:", result['exit_code'])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
* **Purpose:** Directly interact with the environment's shell.
|
|
64
|
+
* **Availability:** Primarily available for Docker-based environments (local or remote custom). Standard remote environments (like `"hud-browser"`) might not support arbitrary command execution via this method.
|
|
65
|
+
* **When to Use:**
|
|
66
|
+
* **Debugging:** Checking file existence, process status, or network connectivity *inside* the container.
|
|
67
|
+
* **Complex Setup:** Running intricate setup scripts or commands that are difficult to express using the standard `setup` configuration.
|
|
68
|
+
* **Local Development:** Installing packages or modifying the container state interactively during development of a custom environment.
|
|
69
|
+
* **Returns:** An `ExecuteResult` typed dictionary containing `stdout` (bytes), `stderr` (bytes), and `exit_code` (int).
|
|
70
|
+
|
|
71
|
+
## `_setup`
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
async def _setup(self, config: HudStyleConfigs | None = None) -> None: ...
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
* **Purpose:** Executes the setup configuration for the environment.
|
|
78
|
+
* **Execution:** This is normally called *automatically* by `hud.gym.make(task)` if the provided `task` has a `setup` configuration.
|
|
79
|
+
* **When to Use Manually:**
|
|
80
|
+
* **Debugging:** To re-run setup steps on an already created environment instance without recreating it entirely.
|
|
81
|
+
* **Custom Flow:** If you create an environment *without* an initial task (`env = await gym.make("gym-id")`) and later want to apply setup steps before starting agent interaction (though `env.reset(task=...)` might be more idiomatic).
|
|
82
|
+
* To override the task's default setup by passing a different `config`.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
# Example: Manually re-running setup (less common)
|
|
86
|
+
task = Task(prompt="...", gym="...", setup=("goto", "initial_page.com"))
|
|
87
|
+
env = await gym.make(task) # Initial setup runs here
|
|
88
|
+
|
|
89
|
+
# ... some interaction ...
|
|
90
|
+
|
|
91
|
+
print("Re-running setup...")
|
|
92
|
+
await env._setup() # Re-runs the setup defined in the task
|
|
93
|
+
|
|
94
|
+
# Or run different setup steps
|
|
95
|
+
await env._setup( ("goto", "another_page.com") )
|
|
96
|
+
|
|
97
|
+
await env.close()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
These advanced methods provide deeper control when the standard `step`/`evaluate`/`close` cycle isn't sufficient. Use them carefully, especially `execute`, as direct shell access can make scenarios less reproducible if not managed properly.
|