Yingxu He
commited on
Commit
•
51a7d0f
1
Parent(s):
2c4a7ea
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,9 @@ def query(payload):
|
|
23 |
response = requests.post(endpoint_url, headers=headers, json=payload)
|
24 |
return response.json()
|
25 |
|
26 |
-
|
|
|
|
|
27 |
|
28 |
def respond(
|
29 |
message,
|
@@ -36,13 +38,13 @@ def respond(
|
|
36 |
):
|
37 |
progress(0, desc="Starting")
|
38 |
|
39 |
-
if
|
40 |
endpoint.client.post(json={
|
41 |
"inputs": "wake up!"
|
42 |
})
|
43 |
progress(0.25, desc="Waking up model")
|
44 |
|
45 |
-
while
|
46 |
time.sleep(1)
|
47 |
|
48 |
progress(0.5, desc="Generating")
|
|
|
23 |
response = requests.post(endpoint_url, headers=headers, json=payload)
|
24 |
return response.json()
|
25 |
|
26 |
+
def get_status():
|
27 |
+
endpoint = get_inference_endpoint(endpoint_name, token=personal_secret_token)
|
28 |
+
return endpoint.status
|
29 |
|
30 |
def respond(
|
31 |
message,
|
|
|
38 |
):
|
39 |
progress(0, desc="Starting")
|
40 |
|
41 |
+
if get_status() != "running":
|
42 |
endpoint.client.post(json={
|
43 |
"inputs": "wake up!"
|
44 |
})
|
45 |
progress(0.25, desc="Waking up model")
|
46 |
|
47 |
+
while get_status() != "running":
|
48 |
time.sleep(1)
|
49 |
|
50 |
progress(0.5, desc="Generating")
|