Spaces:
Runtime error
Runtime error
Oscar Wang
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -19,18 +19,16 @@ state = {
|
|
19 |
}
|
20 |
|
21 |
@retry(stop=stop_after_attempt(3), wait=wait_fixed(2), retry=retry_if_exception_type(httpx.ReadTimeout))
|
22 |
-
def get_token_count(client
|
23 |
-
|
24 |
-
|
25 |
-
response.raise_for_status() # Raise an exception for HTTP errors
|
26 |
-
return int(response.json())
|
27 |
|
28 |
def monitor_growth():
|
29 |
while True:
|
30 |
try:
|
31 |
-
curr_count1 = get_token_count(client1
|
32 |
-
curr_count2 = get_token_count(client2
|
33 |
-
curr_count3 = get_token_count(client3
|
34 |
growth_speed1 = curr_count1 - state["prev_count1"]
|
35 |
growth_speed2 = curr_count2 - state["prev_count2"]
|
36 |
growth_speed3 = curr_count3 - state["prev_count3"]
|
|
|
19 |
}
|
20 |
|
21 |
@retry(stop=stop_after_attempt(3), wait=wait_fixed(2), retry=retry_if_exception_type(httpx.ReadTimeout))
|
22 |
+
def get_token_count(client):
|
23 |
+
result = client.predict(api_name="/update_token_display")
|
24 |
+
return int(result)
|
|
|
|
|
25 |
|
26 |
def monitor_growth():
|
27 |
while True:
|
28 |
try:
|
29 |
+
curr_count1 = get_token_count(client1)
|
30 |
+
curr_count2 = get_token_count(client2)
|
31 |
+
curr_count3 = get_token_count(client3)
|
32 |
growth_speed1 = curr_count1 - state["prev_count1"]
|
33 |
growth_speed2 = curr_count2 - state["prev_count2"]
|
34 |
growth_speed3 = curr_count3 - state["prev_count3"]
|