change proompters 1 min to 5 min

This commit is contained in:
Cyberes 2023-09-20 21:21:22 -06:00
parent 8593198216
commit f9a80f3028
2 changed files with 6 additions and 6 deletions

View File

@ -4,7 +4,7 @@ from threading import Lock, Thread
from llm_server.routes.cache import redis from llm_server.routes.cache import redis
# proompters_1_min = 0 # proompters_5_min = 0
# concurrent_semaphore = Semaphore(concurrent_gens) # concurrent_semaphore = Semaphore(concurrent_gens)
server_start_time = datetime.now() server_start_time = datetime.now()
@ -93,7 +93,7 @@ class SemaphoreCheckerThread(Thread):
while True: while True:
current_time = time.time() current_time = time.time()
recent_prompters = redis.get_dict('recent_prompters') recent_prompters = redis.get_dict('recent_prompters')
new_recent_prompters = {ip: timestamp for ip, timestamp in recent_prompters.items() if current_time - timestamp <= 60} new_recent_prompters = {ip: timestamp for ip, timestamp in recent_prompters.items() if current_time - timestamp <= 300}
redis.set_dict('recent_prompters', new_recent_prompters) redis.set_dict('recent_prompters', new_recent_prompters)
redis.set('proompters_1_min', len(new_recent_prompters)) redis.set('proompters_5_min', len(new_recent_prompters))
time.sleep(1) time.sleep(1)

View File

@ -88,14 +88,14 @@ def generate_stats():
base_client_api = x.decode() if x else None base_client_api = x.decode() if x else None
del x del x
x = redis.get('proompters_1_min') x = redis.get('proompters_5_min')
proompters_1_min = int(x) if x else None proompters_5_min = int(x) if x else None
del x del x
output = { output = {
'stats': { 'stats': {
'proompters': { 'proompters': {
'1_min': proompters_1_min, '5_min': proompters_5_min,
'24_hrs': get_distinct_ips_24h(), '24_hrs': get_distinct_ips_24h(),
}, },
'proompts_total': get_total_proompts() if opts.show_num_prompts else None, 'proompts_total': get_total_proompts() if opts.show_num_prompts else None,