Datasets:
Download runner/agentgridworld/runtime/client.py from bytkim/AgentGridWorld-Hard: direct link, hf CLI and curl.
- Browser
- Download file 787 Bytes
-
https://huggingface.co/datasets/bytkim/AgentGridWorld-Hard/resolve/main/runner/agentgridworld/runtime/client.py
- Command line
-
hf download hf://datasets/bytkim/AgentGridWorld-Hard/runner/agentgridworld/runtime/client.py
-
curl -L -o client.py https://huggingface.co/datasets/bytkim/AgentGridWorld-Hard/resolve/main/runner/agentgridworld/runtime/client.py
787 Bytes
| #!/usr/bin/env python3 | |
| """Agent-facing primitive action client; the server enforces the move budget.""" | |
| import argparse | |
| import json | |
| import urllib.error | |
| import urllib.request | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('action', choices=['look', 'up', 'down', 'left', 'right', 'stop']) | |
| args = parser.parse_args() | |
| url = 'http://127.0.0.1:8765/' | |
| request = urllib.request.Request(url + 'observation') if args.action == 'look' else urllib.request.Request( | |
| url + 'action', data=json.dumps({'action': args.action}).encode(), | |
| headers={'Content-Type': 'application/json'}) | |
| try: | |
| with urllib.request.urlopen(request, timeout=5) as response: | |
| print(response.read().decode()) | |
| except urllib.error.HTTPError as exc: | |
| print(exc.read().decode()) | |
| raise SystemExit(1) | |