Merge cluster to master #3

Merged
cyberes merged 163 commits from cluster into master 2023-10-27 19:19:22 -06:00
1 changed files with 51 additions and 54 deletions
Showing only changes of commit 0718f10eb9 - Show all commits

View File

@ -3,7 +3,6 @@ import time
import traceback import traceback
from flask import Response, jsonify, request from flask import Response, jsonify, request
from redis import Redis
from llm_server.custom_redis import redis from llm_server.custom_redis import redis
from . import openai_bp from . import openai_bp
@ -98,7 +97,6 @@ def openai_chat_completions():
oai_string = generate_oai_string(30) oai_string = generate_oai_string(30)
def generate(): def generate():
try:
response = generator(msg_to_backend, handler.backend_url) response = generator(msg_to_backend, handler.backend_url)
generated_text = '' generated_text = ''
partial_response = b'' partial_response = b''
@ -147,13 +145,12 @@ def openai_chat_completions():
r_url, r_url,
handler.backend_url, handler.backend_url,
) )
finally:
# The worker incremented it, we'll decrement it.
decrement_ip_count(handler.client_ip, 'processing_ips')
decr_active_workers(handler.selected_model, handler.backend_url)
print('cleaned up')
return Response(generate(), mimetype='text/event-stream') return Response(generate(), mimetype='text/event-stream')
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
return 'INTERNAL SERVER', 500 return 'INTERNAL SERVER', 500
finally:
# The worker incremented it, we'll decrement it.
decrement_ip_count(handler.client_ip, 'processing_ips')
decr_active_workers(handler.selected_model, handler.backend_url)