Merge cluster to master #3

Merged
cyberes merged 163 commits from cluster into master 2023-10-27 19:19:22 -06:00
5 changed files with 21 additions and 2 deletions
Showing only changes of commit 21da2f6373 - Show all commits

View File

@ -61,3 +61,6 @@ def validate_oai(parameters):
return format_oai_err(f"{parameters['top_p']} is greater than the maximum of 1 - 'top_p'") return format_oai_err(f"{parameters['top_p']} is greater than the maximum of 1 - 'top_p'")
if parameters.get('top_p', 1) < 0: if parameters.get('top_p', 1) < 0:
return format_oai_err(f"{parameters['top_p']} less than the minimum of 0 - 'top_p'") return format_oai_err(f"{parameters['top_p']} less than the minimum of 0 - 'top_p'")
if parameters.get('max_tokens', 2) < 1:
return format_oai_err(f"{parameters['max_tokens']} is less than the minimum of 1 - 'max_tokens'")

View File

@ -27,6 +27,9 @@ def openai_chat_completions():
handler = OpenAIRequestHandler(incoming_request=request, incoming_json=request_json_body) handler = OpenAIRequestHandler(incoming_request=request, incoming_json=request_json_body)
if not request_json_body.get('stream'): if not request_json_body.get('stream'):
try: try:
invalid_oai_err_msg = validate_oai(request_json_body)
if invalid_oai_err_msg:
return invalid_oai_err_msg
return handler.handle_request() return handler.handle_request()
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()

View File

@ -44,6 +44,9 @@ def openai_completions():
pass pass
if not request_json_body.get('stream'): if not request_json_body.get('stream'):
invalid_oai_err_msg = validate_oai(request_json_body)
if invalid_oai_err_msg:
return invalid_oai_err_msg
response, status_code = handler.handle_request(return_ok=False) response, status_code = handler.handle_request(return_ok=False)
if status_code == 429: if status_code == 429:
return handler.handle_ratelimited() return handler.handle_ratelimited()

View File

@ -171,7 +171,17 @@ class RequestHandler:
else: else:
error_msg = error_msg.strip('.') + '.' error_msg = error_msg.strip('.') + '.'
backend_response = self.handle_error(error_msg) backend_response = self.handle_error(error_msg)
log_prompt(self.client_ip, self.token, prompt, backend_response[0].data.decode('utf-8'), None, self.parameters, dict(self.request.headers), response_status_code, self.request.url, self.backend_url, is_error=True) log_prompt(ip=self.client_ip,
token=self.token,
prompt=prompt,
response=backend_response[0].data.decode('utf-8'),
gen_time=None,
parameters=self.parameters,
headers=dict(self.request.headers),
backend_response_code=response_status_code,
request_url=self.request.url,
backend_url=self.backend_url,
is_error=True)
return (False, None, None, 0), backend_response return (False, None, None, 0), backend_response
# =============================================== # ===============================================