Update app.py
Browse files
app.py
CHANGED
@@ -434,6 +434,7 @@ scheduler.add_job(refresh_models, 'interval', hours=1)
|
|
434 |
def index():
|
435 |
current_time = time.time()
|
436 |
one_minute_ago = current_time - 60
|
|
|
437 |
|
438 |
with data_lock:
|
439 |
while request_timestamps and request_timestamps[0] < one_minute_ago:
|
@@ -443,7 +444,15 @@ def index():
|
|
443 |
rpm = len(request_timestamps)
|
444 |
tpm = sum(token_counts)
|
445 |
|
446 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
447 |
|
448 |
@app.route('/handsome/v1/models', methods=['GET'])
|
449 |
def list_models():
|
|
|
434 |
def index():
|
435 |
current_time = time.time()
|
436 |
one_minute_ago = current_time - 60
|
437 |
+
one_day_ago = current_time - 86400
|
438 |
|
439 |
with data_lock:
|
440 |
while request_timestamps and request_timestamps[0] < one_minute_ago:
|
|
|
444 |
rpm = len(request_timestamps)
|
445 |
tpm = sum(token_counts)
|
446 |
|
447 |
+
with data_lock:
|
448 |
+
while request_timestamps and request_timestamps[0] < one_day_ago:
|
449 |
+
request_timestamps.pop(0)
|
450 |
+
token_counts.pop(0)
|
451 |
+
|
452 |
+
rpd = len(request_timestamps)
|
453 |
+
tpd = sum(token_counts)
|
454 |
+
|
455 |
+
return jsonify({"rpm": rpm, "tpm": tpm, "rpd": rpd, "tpd": tpd})
|
456 |
|
457 |
@app.route('/handsome/v1/models', methods=['GET'])
|
458 |
def list_models():
|