Spaces:
Running
Running
Download test_api.py from mjpsm/activity-composition-api: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/mjpsm/activity-composition-api/resolve/main/test_api.py
- Command line
-
hf download hf://spaces/mjpsm/activity-composition-api/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/mjpsm/activity-composition-api/resolve/main/test_api.py
1.04 kB
| import json | |
| import os | |
| import requests | |
| BASE_URL = os.getenv( | |
| "COMPOSITION_API_URL", | |
| "http://localhost:7860", | |
| ).rstrip("/") | |
| payload = { | |
| "progression": { | |
| "knowledge_state": "PARTIAL", | |
| "demonstrated_state": [ | |
| "Created the initial animation and added the first set of assets" | |
| ], | |
| "next_gap": "Finish and polish the remaining animation work", | |
| "activity_plan": { | |
| "action": "complete the remaining animation work", | |
| "target": "the animation", | |
| "avoid_repeating": [ | |
| "recreating the initial animation", | |
| "re-adding assets already included", | |
| ], | |
| }, | |
| } | |
| } | |
| print("HEALTH") | |
| health = requests.get( | |
| f"{BASE_URL}/health", | |
| timeout=30, | |
| ) | |
| print(health.status_code) | |
| print(json.dumps(health.json(), indent=2)) | |
| print("\nGENERATE") | |
| response = requests.post( | |
| f"{BASE_URL}/generate", | |
| json=payload, | |
| timeout=180, | |
| ) | |
| print(response.status_code) | |
| print(json.dumps(response.json(), indent=2)) | |