Browse Source

增加邮件报警

master
majiahui@haimaqingfan.com 1 year ago
parent
commit
301a1ec91f
  1. 2
      gunicorn_config.py
  2. 16
      mistral_api.py
  3. 2
      run_model.sh

2
gunicorn_config.py

@ -1,7 +1,7 @@
# 并行工作线程数
workers = 8
# 监听内网端口5000【按需要更改】
bind = '0.0.0.0:12003'
bind = '0.0.0.0:12000'
loglevel = 'debug'

16
mistral_api.py

@ -59,7 +59,7 @@ def predict():
id_ = str(uuid.uuid1()) # 为query生成唯一标识
print("uuid: ", uuid)
d = {'id': id_, 'text': text} # 绑定文本和query id
try:
# try:
load_request_path = './request_data_logs/{}.json'.format(id_)
with open(load_request_path, 'w', encoding='utf8') as f2:
# ensure_ascii=False才能输入中文,否则是Unicode字符
@ -69,9 +69,9 @@ def predict():
redis_.sadd(db_key_querying, id_)
redis_.sadd(db_key_queryset, id_)
return_text = {"texts": {'id': id_, }, "probabilities": None, "status_code": 200}
except:
return_text = {"texts": {'id': id_, }, "probabilities": None, "status_code": 400}
smtp_f("vllm-main")
# except:
# return_text = {"texts": {'id': id_, }, "probabilities": None, "status_code": 400}
# smtp_f("vllm-main")
return jsonify(return_text) # 返回结果
@ -79,7 +79,7 @@ def predict():
def search():
id_ = request.json['id'] # 获取用户query中的文本 例如"I love you"
result = redis_.get(id_) # 获取该query的模型结果
try:
# try:
if result is not None:
result_path = result.decode('UTF-8')
with open(result_path, encoding='utf8') as f1:
@ -124,9 +124,9 @@ def search():
# ensure_ascii=False才能输入中文,否则是Unicode字符
# indent=2 JSON数据的缩进,美观
json.dump(result_text, f2, ensure_ascii=False, indent=4)
except:
smtp_f("vllm-main")
result_text = {'code': "400", 'text': "", 'probabilities': None}
# except:
# smtp_f("vllm-main")
# result_text = {'code': "400", 'text': "", 'probabilities': None}
return jsonify(result_text) # 返回结果
if __name__ == "__main__":

2
run_model.sh

@ -1 +1 @@
nohup python mistral_model_predict_vllm.py > myout.file 2>&1 &
nohup python mistral_model_predict_vllm.py > myout_model_11.file 2>&1 &

Loading…
Cancel
Save