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
|
2023-08-23 21:33:52 -06:00
|
|
|
# concurrent_semaphore = Semaphore(concurrent_gens)
|
2023-09-12 16:40:09 -06:00
|
|
|
|
2023-08-23 21:33:52 -06:00
|
|
|
server_start_time = datetime.now()
|
|
|
|
|
|
|
|
|
2023-08-23 22:20:39 -06:00
|
|
|
# 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)
|
2023-08-23 21:33:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2023-08-23 22:01:06 -06:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2023-08-23 22:01:06 -06:00
|
|
|
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
|