This repository has been archived on 2024-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
local-llm-server/llm_server/routes/stats.py

47 lines
1.2 KiB
Python
Raw Normal View History

2023-08-21 21:28:52 -06:00
from datetime import datetime
2023-08-23 01:14:19 -06:00
from llm_server.routes.cache import redis
2023-08-21 21:28:52 -06:00
2023-09-20 21:21:22 -06:00
# proompters_5_min = 0
# concurrent_semaphore = Semaphore(concurrent_gens)
2023-09-12 16:40:09 -06:00
server_start_time = datetime.now()
# TODO: do I need this?
# def elapsed_times_cleanup():
# global wait_in_queue_elapsed
# while True:
# current_time = time.time()
# with wait_in_queue_elapsed_lock:
# global wait_in_queue_elapsed
# wait_in_queue_elapsed = [(end_time, elapsed_time) for end_time, elapsed_time in wait_in_queue_elapsed if current_time - end_time <= 60]
# time.sleep(1)
def calculate_avg_gen_time():
# Get the average generation time from Redis
average_generation_time = redis.get('average_generation_time')
if average_generation_time is None:
return 0
else:
return float(average_generation_time)
def get_total_proompts():
2023-08-23 01:14:19 -06:00
count = redis.get('proompts')
if count is None:
count = 0
else:
count = int(count)
return count
def get_active_gen_workers():
active_gen_workers = redis.get('active_gen_workers')
if active_gen_workers is None:
count = 0
else:
count = int(active_gen_workers)
return count