File size: 899 Bytes
3ad5bcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Free external wake-up client for SEED's Gradio API.

Environment variables:
  SEED_SPACE_URL=https://italianhype-seed-autonomous-unicorn.hf.space
  SEED_TRIGGER_SECRET=...
  HF_TOKEN=hf_...  # caller token used for ZeroGPU quota and private Spaces
"""
from __future__ import annotations

import os
import sys

import requests

space_url = os.environ.get("SEED_SPACE_URL", "").rstrip("/")
trigger_secret = os.environ.get("SEED_TRIGGER_SECRET", "")
hf_token = os.environ.get("HF_TOKEN", "")

if not space_url:
    raise SystemExit("SEED_SPACE_URL is required")

headers = {"Content-Type": "application/json"}
if hf_token:
    headers["Authorization"] = f"Bearer {hf_token}"

response = requests.post(
    f"{space_url}/gradio_api/call/autonomous_cycle",
    headers=headers,
    json={"data": [trigger_secret, False]},
    timeout=30,
)
response.raise_for_status()
print(response.text)
sys.exit(0)