diff --git a/llm_server/routes/stats.py b/llm_server/routes/stats.py index c2fd88d..91c358a 100644 --- a/llm_server/routes/stats.py +++ b/llm_server/routes/stats.py @@ -7,13 +7,15 @@ from llm_server import opts from llm_server.integer import ThreadSafeInteger from llm_server.opts import concurrent_gens -proompters_1_min = 0 +# proompters_1_min = 0 concurrent_semaphore = Semaphore(concurrent_gens) proompts = ThreadSafeInteger(0) start_time = datetime.now() class SemaphoreCheckerThread(Thread): + proompters_1_min = 0 + def __init__(self, semaphore): Thread.__init__(self) self.semaphore = semaphore @@ -22,7 +24,6 @@ class SemaphoreCheckerThread(Thread): self.daemon = True def run(self): - global proompters_1_min while True: current_semaphore_value = self.semaphore._value if current_semaphore_value < opts.concurrent_gens and current_semaphore_value != self.prev_semaphore_value: @@ -30,6 +31,5 @@ class SemaphoreCheckerThread(Thread): else: self.values.append(0) self.prev_semaphore_value = current_semaphore_value - proompters_1_min = sum(self.values) - # print(proompters_1_min) + SemaphoreCheckerThread.proompters_1_min = sum(self.values) time.sleep(1) diff --git a/llm_server/routes/v1/proxy.py b/llm_server/routes/v1/proxy.py index 646044f..b854bda 100644 --- a/llm_server/routes/v1/proxy.py +++ b/llm_server/routes/v1/proxy.py @@ -7,9 +7,7 @@ from llm_server import opts from llm_server.routes.v1.generate import concurrent_semaphore from . import bp from .. import stats -from ..cache import cache -from ..helpers.http import cache_control -from ..stats import proompters_1_min +from ..stats import SemaphoreCheckerThread from ...llm.info import get_running_model @@ -23,12 +21,10 @@ def get_stats(): else: online = True - # print('-->', proompters_1_min) - return jsonify({ 'stats': { 'proompters_now': opts.concurrent_gens - concurrent_semaphore._value, - 'proompters_1_min': proompters_1_min, + 'proompters_1_min': SemaphoreCheckerThread.proompters_1_min, 'total_proompts': stats.proompts.value, 'uptime': int((datetime.now() - stats.start_time).total_seconds()), },