hud-python 0.1.5__py3-none-any.whl → 0.2.0__py3-none-any.whl
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/__init__.py +16 -12
- hud/adapters/__init__.py +4 -2
- hud/adapters/claude/adapter.py +0 -1
- hud/adapters/common/adapter.py +11 -10
- hud/adapters/common/types.py +27 -13
- hud/adapters/operator/__init__.py +5 -0
- hud/adapters/operator/adapter.py +93 -0
- hud/agent/__init__.py +7 -0
- hud/agent/base.py +109 -0
- hud/agent/claude.py +187 -0
- hud/agent/operator.py +190 -0
- hud/env/__init__.py +11 -0
- hud/env/client.py +35 -0
- hud/env/docker_client.py +306 -0
- hud/env/environment.py +181 -0
- hud/env/local_docker_client.py +249 -0
- hud/env/remote_client.py +185 -0
- hud/env/remote_docker_client.py +221 -0
- hud/evaluators/__init__.py +10 -0
- hud/evaluators/base.py +31 -0
- hud/evaluators/inspect.py +29 -0
- hud/evaluators/judge.py +213 -0
- hud/evaluators/match.py +163 -0
- hud/evaluators/remote.py +78 -0
- hud/gym.py +101 -15
- hud/job.py +185 -0
- hud/server/__init__.py +2 -2
- hud/server/requests.py +87 -0
- hud/settings.py +13 -2
- hud/task.py +133 -0
- hud/taskset.py +95 -0
- hud/trajectory.py +90 -0
- hud/types.py +65 -0
- hud/utils/__init__.py +4 -2
- hud/utils/common.py +69 -0
- hud/utils/config.py +182 -4
- hud/utils/telemetry.py +67 -0
- hud_python-0.2.0.dist-info/METADATA +188 -0
- hud_python-0.2.0.dist-info/RECORD +44 -0
- {hud_python-0.1.5.dist-info → hud_python-0.2.0.dist-info}/licenses/LICENSE +1 -1
- hud/client.py +0 -200
- hud/environment.py +0 -318
- hud/run.py +0 -208
- hud_python-0.1.5.dist-info/METADATA +0 -125
- hud_python-0.1.5.dist-info/RECORD +0 -21
- {hud_python-0.1.5.dist-info → hud_python-0.2.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hud-python
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: SDK for the HUD evaluation platform.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Human-Data/hud-sdk
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/Human-Data/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 SDK - Human-Agent Interaction Toolkit
|
|
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 Operator
|
|
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
|
+
```python
|
|
94
|
+
import os
|
|
95
|
+
import asyncio
|
|
96
|
+
from hud import gym, job
|
|
97
|
+
from hud.task import Task
|
|
98
|
+
from hud.utils import stream
|
|
99
|
+
from hud.agent import OperatorAgent
|
|
100
|
+
|
|
101
|
+
@job("test-run")
|
|
102
|
+
async def main():
|
|
103
|
+
# Define a simple task
|
|
104
|
+
task = Task(
|
|
105
|
+
prompt="Insert the text 'capybara' into the search bar",
|
|
106
|
+
gym="hud-browser",
|
|
107
|
+
setup=("goto", "google.com"),
|
|
108
|
+
evaluate=("contains_text", "capybara")
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Create environment
|
|
112
|
+
env = await gym.make(task)
|
|
113
|
+
|
|
114
|
+
# Get URLs and display live view (optional)
|
|
115
|
+
# urls = await env.get_urls()
|
|
116
|
+
# stream(urls["live_url"])
|
|
117
|
+
|
|
118
|
+
# Initialize Operator agent (API key is loaded automatically)
|
|
119
|
+
agent = OperatorAgent()
|
|
120
|
+
|
|
121
|
+
# Agent loop
|
|
122
|
+
obs, _ = env.reset()
|
|
123
|
+
for i in range(5):
|
|
124
|
+
actions, done = await agent.predict(obs)
|
|
125
|
+
if done:
|
|
126
|
+
break
|
|
127
|
+
|
|
128
|
+
obs, reward, terminated, info = await env.step(actions)
|
|
129
|
+
if terminated:
|
|
130
|
+
break
|
|
131
|
+
|
|
132
|
+
# Evaluate and close
|
|
133
|
+
result = await env.evaluate()
|
|
134
|
+
print(f"Evaluation result: {result}")
|
|
135
|
+
await env.close()
|
|
136
|
+
|
|
137
|
+
if __name__ == "__main__":
|
|
138
|
+
asyncio.run(main())
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Documentation Sections
|
|
143
|
+
|
|
144
|
+
Explore the core concepts and features of the SDK:
|
|
145
|
+
|
|
146
|
+
* **[Tasks and TaskSets](/concepts/task)**: Define goals, context, setup, and evaluation criteria for agent scenarios.
|
|
147
|
+
* **[Environments](/concepts/environment)**: Understand the browser and OS runtimes where agents interact.
|
|
148
|
+
* **[Agents](/concepts/agent)**: Learn about the agent architecture (Claude, Operator) and how they process observations and predict actions.
|
|
149
|
+
* **[Adapters](/concepts/adapter)**: See how actions and observations are translated between agents and environments.
|
|
150
|
+
* **[Jobs](/concepts/job)**: Group related runs for analysis and viewing on the HUD platform.
|
|
151
|
+
* **[Trajectories](/concepts/trajectory)**: Understand the recorded data from each agent run.
|
|
152
|
+
* **Advanced Topics**:
|
|
153
|
+
* **[Custom Environments](/advanced/custom-environments)**: Build your own Docker-based local or remote environments.
|
|
154
|
+
* **[Advanced Environment Control](/advanced/environment-control)**: Use `invoke`, `execute`, and `_setup` for finer control.
|
|
155
|
+
* **[CLA Action Details](/advanced/cla-details)**: Dive deeper into the standardized action format.
|
|
156
|
+
|
|
157
|
+
* **[Full API Reference](/api-reference/gym)**: Detailed specifications for all modules and classes.
|
|
158
|
+
|
|
159
|
+
## [Examples](examples/)
|
|
160
|
+
|
|
161
|
+
We provide several example notebooks showing how to use the HUD SDK:
|
|
162
|
+
|
|
163
|
+
1. [Browser Basics](examples/browser_use.ipynb) - Simple browser interaction with live view
|
|
164
|
+
2. [Task Design](examples/tasks.ipynb) - Creating and customizing tasks
|
|
165
|
+
3. [OSWorld](examples/osworld.ipynb) - Working with OS environments
|
|
166
|
+
4. [Local Development](examples/local.ipynb) - Setting up local custom environments
|
|
167
|
+
|
|
168
|
+
## Documentation
|
|
169
|
+
|
|
170
|
+
For comprehensive guides, examples, and API reference, visit [our docs](https://docs.hud.so/introduction)
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
[MIT License](LICENSE)
|
|
175
|
+
|
|
176
|
+
## Citation
|
|
177
|
+
|
|
178
|
+
If you use this SDK in your research, please cite it as follows:
|
|
179
|
+
|
|
180
|
+
```bibtex
|
|
181
|
+
@software{hud2025agentevalplatform,
|
|
182
|
+
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},
|
|
183
|
+
title = {{HUD: An Evaluation Platform for Computer Use Agents}},
|
|
184
|
+
date = {2025-03},
|
|
185
|
+
url = {https://github.com/Human-Data/hud-sdk},
|
|
186
|
+
langid = {en}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
hud/__init__.py,sha256=YX9zAqOSjAFZqHbDJGUVefOsxg7PhkH1ZDflRoiSgP8,464
|
|
2
|
+
hud/gym.py,sha256=cKjIuJS7A0vJx4K7fctpUjIEv8TkW5x6aB_PRrODrDY,3651
|
|
3
|
+
hud/job.py,sha256=E4RN1CkppRQVy46RWCUDjNIyhMa7lNlFfCgpky2vKFk,5463
|
|
4
|
+
hud/settings.py,sha256=rv8TiZx4wmBzIoEEkOzoywC0nt8UZXlHxIa_LW4tWAg,1346
|
|
5
|
+
hud/task.py,sha256=q1E_urMavnfsb87x2JHkRNMBzbkkaQI1skOulkpJ5DY,5132
|
|
6
|
+
hud/taskset.py,sha256=fV4QgHf8tphDoMjTdBzkyCJT7pQBLEMoGu_Uxuji2DM,2226
|
|
7
|
+
hud/trajectory.py,sha256=PA-sE2iyt2BctO2Dex-2ZaRmS95AkEXTicZjHCVCYqE,3749
|
|
8
|
+
hud/types.py,sha256=fJZnzK3j3mq7G0gO5TbqRaN92qT4xAb4jUNOXIX8ZZ0,2395
|
|
9
|
+
hud/adapters/__init__.py,sha256=0RNQgrzBCkhNBq1Q7JRESN1WfUVLs_99fR5g1re3APs,207
|
|
10
|
+
hud/adapters/claude/__init__.py,sha256=i7QEF-29FLb9qxp1eYtXs-adIk_tG54tL-9g6d3xodk,100
|
|
11
|
+
hud/adapters/claude/adapter.py,sha256=sgdgkCtNFjFPSSmfsUD1vx0Xz9xhG81A_it4BvRsOXE,5781
|
|
12
|
+
hud/adapters/common/__init__.py,sha256=BjdZWJVs_AKtpFrt-tNsdQRjnz7D97DFEQirJ-r0mp8,118
|
|
13
|
+
hud/adapters/common/adapter.py,sha256=ls-gXtg1N_SQc211rkDb3LL511HNZv6etm1nx2ZtrkQ,5808
|
|
14
|
+
hud/adapters/common/types.py,sha256=ubnWlm4JMtCkTNonKZGb425p6oi8jZyIVcekp-pjTXQ,4905
|
|
15
|
+
hud/adapters/operator/__init__.py,sha256=31vTRs268_TOLd-TeQRKau5bDYy78wxCNpJFhD5_l8U,104
|
|
16
|
+
hud/adapters/operator/adapter.py,sha256=j2bBe_bwOhdbd7Qr6UvWUEkTkUTOA-ADvWYx0B1c_TU,3159
|
|
17
|
+
hud/agent/__init__.py,sha256=cI3bqfmG2_Lwzn2RjrxV0X9qIxCRDiffwd1UaWToct4,238
|
|
18
|
+
hud/agent/base.py,sha256=RThJ_h4A3oU23zyvvKtxY2a_YM03Vd1XYDXdY3bAf8g,3881
|
|
19
|
+
hud/agent/claude.py,sha256=ZPoged_sun2CmPgludfkV4uv-gjak_yyIlGgCIRcWx0,6583
|
|
20
|
+
hud/agent/operator.py,sha256=zJaYW5kJ7rgvRQCufrjsoNCPn2Ra9EakmFFwut_v7Hk,7335
|
|
21
|
+
hud/env/__init__.py,sha256=BHFY_N0kEI142pjWtMyqUb3BGnoiekY8evRCIbSbO2w,271
|
|
22
|
+
hud/env/client.py,sha256=SPR6ct6NFxmIrgIi3K8tEC-vnqOmCbCBtuT81PaVjuY,869
|
|
23
|
+
hud/env/docker_client.py,sha256=4G3OeFBCbIqg9zOXxreDekNvLNMhgtc2cMAjMbqB6Tk,10394
|
|
24
|
+
hud/env/environment.py,sha256=h-Z7I_1Y8vXBL1oOYbC5xRIKwl28NZt0PJ4GmKcd0AM,5863
|
|
25
|
+
hud/env/local_docker_client.py,sha256=9p2IHeSRmk9_lU7FRiHaCMWn0CjbtWLQjsT3x8x6qxY,7767
|
|
26
|
+
hud/env/remote_client.py,sha256=iJiwueuf98xOx0_Y2ltu_63BwKIKNvohhim73Goq74E,5804
|
|
27
|
+
hud/env/remote_docker_client.py,sha256=FwaO7NyygDt9oe3pDD7PwUS21pxzc465mwcXk-Cx-60,6838
|
|
28
|
+
hud/evaluators/__init__.py,sha256=XophB666xPnurhQ_ygfW44h0Jh0BQGCgUzCXEOG2Q1g,158
|
|
29
|
+
hud/evaluators/base.py,sha256=CNbrvFWQfl1YuBxJKzuG4_TBAdAf0TOQA3hl7eGsbaA,782
|
|
30
|
+
hud/evaluators/inspect.py,sha256=eTu9E2eBFe4jd4sPtXL0_vGIEY8aiEmTgmN__v77jvI,735
|
|
31
|
+
hud/evaluators/judge.py,sha256=0T9DHFRR38oH2X1d87t58SBSAhbKWRH5PlljzCa3rkg,6449
|
|
32
|
+
hud/evaluators/match.py,sha256=iFJ_qqaHJQ19TICdQPjHgTubBhq7izCIET5qU_104Fk,4719
|
|
33
|
+
hud/evaluators/remote.py,sha256=NVUJJvrpGQj2eL-aFxzTEnAWW7iuSI9eDWtar54dc6E,2174
|
|
34
|
+
hud/server/__init__.py,sha256=cxDKTwMdGzhj7bYajtejN8XCt7K8Xq3eKB2No0qBpoY,169
|
|
35
|
+
hud/server/requests.py,sha256=s8LZZYWT1wl7lPu2vwRaYPZs9_gjKwSg3LZLvS5-s6E,9085
|
|
36
|
+
hud/utils/__init__.py,sha256=LnoI2tQUnd-mQ4eg-gpJJgmHBBIhggJ6c9ap7MBgrfs,260
|
|
37
|
+
hud/utils/common.py,sha256=qTAgiqQqplfrCrll06SAYYr9TyT8gnV4mwDSxsj-W1s,1842
|
|
38
|
+
hud/utils/config.py,sha256=x3F9Rg2lTGEG8_FcnEyymh4Y02qD1UWmcDlOSA1Xq0U,6476
|
|
39
|
+
hud/utils/telemetry.py,sha256=md7AuKxtDqsONMeeTOHen1XpmNds8CbXROX_PnkDxFc,1993
|
|
40
|
+
hud/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
+
hud_python-0.2.0.dist-info/METADATA,sha256=GbG7OHnQ8WqR3iXT6utC26PkCmgPKrOePTdCNZxuwK4,7222
|
|
42
|
+
hud_python-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
43
|
+
hud_python-0.2.0.dist-info/licenses/LICENSE,sha256=yIzBheVUf86FC1bztAcr7RYWWNxyd3B-UJQ3uddg1HA,1078
|
|
44
|
+
hud_python-0.2.0.dist-info/RECORD,,
|
hud/client.py
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
HUD client for interacting with the API.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
import json
|
|
8
|
-
from typing import Any
|
|
9
|
-
|
|
10
|
-
from .adapters.common import Adapter
|
|
11
|
-
from .environment import EvalSet
|
|
12
|
-
from .gym import Gym
|
|
13
|
-
from .run import Run, RunResponse
|
|
14
|
-
from .server import make_request
|
|
15
|
-
from .settings import settings
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class HUDClient:
|
|
19
|
-
"""
|
|
20
|
-
Client for interacting with the HUD API.
|
|
21
|
-
|
|
22
|
-
This is the main entry point for the SDK, providing methods to load gyms,
|
|
23
|
-
evalsets, and create runs.
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
def __init__(self, api_key: str | None = None) -> None:
|
|
27
|
-
"""
|
|
28
|
-
Initialize the HUD client with an API key.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
api_key: API key for authentication with the HUD API
|
|
32
|
-
"""
|
|
33
|
-
self.api_key = api_key or settings.api_key
|
|
34
|
-
settings.api_key = self.api_key
|
|
35
|
-
|
|
36
|
-
async def load_gym(self, id: str) -> Gym:
|
|
37
|
-
"""
|
|
38
|
-
Load a gym by ID from the HUD API.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
id: The ID of the gym to load
|
|
42
|
-
|
|
43
|
-
Returns:
|
|
44
|
-
Gym: The loaded gym object
|
|
45
|
-
"""
|
|
46
|
-
# API call to get gym info
|
|
47
|
-
data = await make_request(
|
|
48
|
-
method="GET",
|
|
49
|
-
url=f"{settings.base_url}/gyms/{id}",
|
|
50
|
-
api_key=self.api_key,
|
|
51
|
-
)
|
|
52
|
-
return Gym(id=data["id"], name=data["name"])
|
|
53
|
-
|
|
54
|
-
async def load_evalset(self, id: str) -> EvalSet:
|
|
55
|
-
"""
|
|
56
|
-
Load an evalset by ID from the HUD API.
|
|
57
|
-
|
|
58
|
-
Args:
|
|
59
|
-
id: The ID of the evalset to load
|
|
60
|
-
|
|
61
|
-
Returns:
|
|
62
|
-
EvalSet: The loaded evalset object
|
|
63
|
-
"""
|
|
64
|
-
# API call to get evalset info
|
|
65
|
-
data = await make_request(
|
|
66
|
-
method="GET",
|
|
67
|
-
url=f"{settings.base_url}/evalsets/{id}",
|
|
68
|
-
api_key=self.api_key,
|
|
69
|
-
)
|
|
70
|
-
return EvalSet(id=data["id"], name=data["name"])
|
|
71
|
-
|
|
72
|
-
async def list_gyms(self) -> list[str]:
|
|
73
|
-
"""
|
|
74
|
-
List all available gyms.
|
|
75
|
-
|
|
76
|
-
Returns:
|
|
77
|
-
list[str]: List of gym IDs
|
|
78
|
-
"""
|
|
79
|
-
# API call to get gyms
|
|
80
|
-
data = await make_request(
|
|
81
|
-
method="GET", url=f"{settings.base_url}/gyms", api_key=self.api_key
|
|
82
|
-
)
|
|
83
|
-
return data["gyms"]
|
|
84
|
-
|
|
85
|
-
async def get_runs(self) -> list[Run]:
|
|
86
|
-
"""
|
|
87
|
-
Get all runs associated with the API key.
|
|
88
|
-
|
|
89
|
-
Returns:
|
|
90
|
-
list[Run]: List of run objects
|
|
91
|
-
"""
|
|
92
|
-
# API call to get runs
|
|
93
|
-
data = await make_request(
|
|
94
|
-
method="GET", url=f"{settings.base_url}/runs", api_key=self.api_key
|
|
95
|
-
)
|
|
96
|
-
return data["runs"]
|
|
97
|
-
|
|
98
|
-
async def load_run(self, id: str, adapter: Adapter | None = None) -> Run | None:
|
|
99
|
-
"""
|
|
100
|
-
Load a run by ID from the HUD API.
|
|
101
|
-
|
|
102
|
-
Args:
|
|
103
|
-
id: The ID of the run to load
|
|
104
|
-
adapter: Optional adapter for action conversion
|
|
105
|
-
|
|
106
|
-
Returns:
|
|
107
|
-
Run: The loaded run object, or None if not found
|
|
108
|
-
"""
|
|
109
|
-
adapter = adapter or Adapter()
|
|
110
|
-
# API call to get run info
|
|
111
|
-
data = await make_request(
|
|
112
|
-
method="GET",
|
|
113
|
-
url=f"{settings.base_url}/runs/{id}",
|
|
114
|
-
api_key=self.api_key,
|
|
115
|
-
)
|
|
116
|
-
if data:
|
|
117
|
-
response = RunResponse(**data)
|
|
118
|
-
gym = Gym(id=response.gym["id"], name=response.gym["name"])
|
|
119
|
-
evalset = EvalSet(
|
|
120
|
-
id=response.evalset["id"],
|
|
121
|
-
name=response.evalset["name"],
|
|
122
|
-
tasks=response.evalset["tasks"],
|
|
123
|
-
)
|
|
124
|
-
return Run(
|
|
125
|
-
id=response.id,
|
|
126
|
-
name=response.name,
|
|
127
|
-
gym=gym,
|
|
128
|
-
evalset=evalset,
|
|
129
|
-
adapter=adapter,
|
|
130
|
-
config=response.config,
|
|
131
|
-
metadata=response.metadata,
|
|
132
|
-
)
|
|
133
|
-
return None
|
|
134
|
-
|
|
135
|
-
async def create_run(
|
|
136
|
-
self,
|
|
137
|
-
name: str,
|
|
138
|
-
gym: Gym,
|
|
139
|
-
evalset: EvalSet,
|
|
140
|
-
config: dict[str, Any] | None = None,
|
|
141
|
-
metadata: dict[str, Any] | None = None,
|
|
142
|
-
adapter: Adapter | None = None,
|
|
143
|
-
) -> Run:
|
|
144
|
-
"""
|
|
145
|
-
Create a new run in the HUD system.
|
|
146
|
-
|
|
147
|
-
Args:
|
|
148
|
-
name: Name of the run
|
|
149
|
-
gym: Gym to use for the run
|
|
150
|
-
evalset: Evalset to use for the run
|
|
151
|
-
config: Optional configuration parameters
|
|
152
|
-
metadata: Optional metadata for the run
|
|
153
|
-
adapter: Optional adapter for action conversion
|
|
154
|
-
|
|
155
|
-
Returns:
|
|
156
|
-
Run: The created run object
|
|
157
|
-
"""
|
|
158
|
-
adapter = adapter or Adapter()
|
|
159
|
-
# Make synchronous API call to create run
|
|
160
|
-
if metadata is None:
|
|
161
|
-
metadata = {}
|
|
162
|
-
if config is None:
|
|
163
|
-
config = {}
|
|
164
|
-
data = await make_request(
|
|
165
|
-
method="POST",
|
|
166
|
-
url=f"{settings.base_url}/runs",
|
|
167
|
-
json={
|
|
168
|
-
"name": name,
|
|
169
|
-
"gym_id": gym.id,
|
|
170
|
-
"evalset_id": evalset.id,
|
|
171
|
-
"config": json.dumps(config),
|
|
172
|
-
"metadata": json.dumps(metadata),
|
|
173
|
-
},
|
|
174
|
-
api_key=self.api_key,
|
|
175
|
-
)
|
|
176
|
-
return Run(
|
|
177
|
-
id=data["id"],
|
|
178
|
-
name=name,
|
|
179
|
-
gym=gym,
|
|
180
|
-
evalset=evalset,
|
|
181
|
-
adapter=adapter,
|
|
182
|
-
config=config,
|
|
183
|
-
metadata=metadata,
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
def display_stream(self, live_url: str) -> None:
|
|
187
|
-
"""
|
|
188
|
-
Display a stream in the HUD system.
|
|
189
|
-
"""
|
|
190
|
-
from IPython.display import HTML, display
|
|
191
|
-
|
|
192
|
-
html_content = f"""
|
|
193
|
-
<div style="width: 960px; height: 540px; overflow: hidden;">
|
|
194
|
-
<div style="transform: scale(0.5); transform-origin: top left;">
|
|
195
|
-
<iframe src="{live_url}" width="1920" height="1080" style="border: 1px solid #ddd;">
|
|
196
|
-
</iframe>
|
|
197
|
-
</div>
|
|
198
|
-
</div>
|
|
199
|
-
"""
|
|
200
|
-
display(HTML(html_content))
|