This commit is contained in:
Cyberes 2023-10-03 13:49:00 -06:00
parent 581a0fec99
commit e16f415749
2 changed files with 3 additions and 2 deletions

View File

@ -52,6 +52,7 @@ def log_prompt(ip: str, token: str, prompt: str, response: Union[str, None], gen
backend_info = cluster_config.get_backend(backend_url) backend_info = cluster_config.get_backend(backend_url)
running_model = backend_info.get('model') running_model = backend_info.get('model')
backend_mode = backend_info['mode']
timestamp = int(time.time()) timestamp = int(time.time())
cursor = database.cursor() cursor = database.cursor()
try: try:
@ -60,7 +61,7 @@ def log_prompt(ip: str, token: str, prompt: str, response: Union[str, None], gen
(ip, token, model, backend_mode, backend_url, request_url, generation_time, prompt, prompt_tokens, response, response_tokens, response_status, parameters, headers, timestamp) (ip, token, model, backend_mode, backend_url, request_url, generation_time, prompt, prompt_tokens, response, response_tokens, response_status, parameters, headers, timestamp)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
""", """,
(ip, token, running_model, cluster_config['mode'], backend_url, request_url, gen_time, prompt, prompt_tokens, response, response_tokens, backend_response_code, json.dumps(parameters), json.dumps(headers), timestamp)) (ip, token, running_model, backend_mode, backend_url, request_url, gen_time, prompt, prompt_tokens, response, response_tokens, backend_response_code, json.dumps(parameters), json.dumps(headers), timestamp))
finally: finally:
cursor.close() cursor.close()

View File

@ -45,7 +45,7 @@ class RequestHandler:
self.parameters = None self.parameters = None
self.used = False self.used = False
if not self.token.startswith('SYSTEM__'): if self.token and not self.token.startswith('SYSTEM__'):
# "recent_prompters" is only used for stats. # "recent_prompters" is only used for stats.
redis.zadd('recent_prompters', {self.client_ip: time.time()}) redis.zadd('recent_prompters', {self.client_ip: time.time()})