Merge cluster to master #3
|
@ -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'")
|
||||
if parameters.get('top_p', 1) < 0:
|
||||
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'")
|
||||
|
|
|
@ -27,6 +27,9 @@ def openai_chat_completions():
|
|||
handler = OpenAIRequestHandler(incoming_request=request, incoming_json=request_json_body)
|
||||
if not request_json_body.get('stream'):
|
||||
try:
|
||||
invalid_oai_err_msg = validate_oai(request_json_body)
|
||||
if invalid_oai_err_msg:
|
||||
return invalid_oai_err_msg
|
||||
return handler.handle_request()
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -44,6 +44,9 @@ def openai_completions():
|
|||
pass
|
||||
|
||||
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)
|
||||
if status_code == 429:
|
||||
return handler.handle_ratelimited()
|
||||
|
|
|
@ -171,7 +171,17 @@ class RequestHandler:
|
|||
else:
|
||||
error_msg = error_msg.strip('.') + '.'
|
||||
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
|
||||
|
||||
# ===============================================
|
||||
|
|
Reference in New Issue