Spaces:
Sleeping
Sleeping
Commit ·
b872fd0
1
Parent(s): cfa0a05
Update client.py (#15)
Browse files- Update client.py (778057bd00d4be4fda2af0c510396c86781a84c8)
Co-authored-by: tarun saroya <Tarun-sar0ya@users.noreply.huggingface.co>
client.py
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Client for the API Triage Agent environment.
|
| 2 |
+
|
| 3 |
+
Implements the EnvClient interface for connecting to the
|
| 4 |
+
API Triage environment server over HTTP.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
from openenv.core.env_client import EnvClient
|
| 9 |
+
|
| 10 |
+
class APITriageClient(EnvClient):
|
| 11 |
+
"""Client for the API Triage Agent OpenEnv environment."""
|
| 12 |
+
pass
|
| 13 |
+
|
| 14 |
+
except ImportError:
|
| 15 |
+
# Fallback if openenv-core not installed locally
|
| 16 |
+
class APITriageClient: # type: ignore
|
| 17 |
+
"""Stub client for local development without openenv-core."""
|
| 18 |
+
|
| 19 |
+
def __init__(self, base_url: str = "http://localhost:7860"):
|
| 20 |
+
self.base_url = base_url
|
| 21 |
+
|
| 22 |
+
def reset(self):
|
| 23 |
+
import requests
|
| 24 |
+
return requests.post(f"{self.base_url}/reset").json()
|
| 25 |
+
|
| 26 |
+
def step(self, action: str):
|
| 27 |
+
import requests
|
| 28 |
+
return requests.post(
|
| 29 |
+
f"{self.base_url}/step",
|
| 30 |
+
json={"action": action}
|
| 31 |
+
).json()
|
| 32 |
+
|
| 33 |
+
def state(self):
|
| 34 |
+
import requests
|
| 35 |
+
return requests.get(f"{self.base_url}/state").json()
|