|
@@ -2,9 +2,10 @@
|
|
@author: luojunhui
|
|
@author: luojunhui
|
|
"""
|
|
"""
|
|
import requests
|
|
import requests
|
|
|
|
+import traceback
|
|
from requests.exceptions import RequestException, JSONDecodeError
|
|
from requests.exceptions import RequestException, JSONDecodeError
|
|
|
|
|
|
-from applications.feishuBotApi import bot
|
|
+from applications.aliyunLogApi import log
|
|
|
|
|
|
|
|
|
|
def similarity_between_title_list(target_title_list: list[str], base_title_list: list[str]) -> list[list[float]]:
|
|
def similarity_between_title_list(target_title_list: list[str], base_title_list: list[str]) -> list[list[float]]:
|
|
@@ -31,24 +32,29 @@ def similarity_between_title_list(target_title_list: list[str], base_title_list:
|
|
if response.status_code != 200:
|
|
if response.status_code != 200:
|
|
response = requests.post(url_backup, json=body, timeout=120)
|
|
response = requests.post(url_backup, json=body, timeout=120)
|
|
except RequestException as e:
|
|
except RequestException as e:
|
|
- bot(
|
|
+ log(
|
|
- title='NLP API 网络异常',
|
|
+ task="nlp",
|
|
- detail={
|
|
+ function="similarity_between_title_list",
|
|
- "error_type": type(e).__name__,
|
|
+ status="fail",
|
|
- "error_msg": str(e)
|
|
+ message="nlp server web error",
|
|
- },
|
|
+ data={
|
|
- mention=False
|
|
+ "e": str(e),
|
|
|
|
+ "error_msg": traceback.format_exc()
|
|
|
|
+ }
|
|
)
|
|
)
|
|
- return []
|
|
+
|
|
|
|
+ response = requests.post(url_backup, json=body, timeout=120)
|
|
|
|
|
|
if response.status_code != 200:
|
|
if response.status_code != 200:
|
|
- bot(
|
|
+ log(
|
|
- title='NLP API 业务异常',
|
|
+ task="nlp",
|
|
- detail={
|
|
+ function="similarity_between_title_list",
|
|
|
|
+ status="fail",
|
|
|
|
+ message='nlp server request error',
|
|
|
|
+ data={
|
|
"status_code": response.status_code,
|
|
"status_code": response.status_code,
|
|
"response_text": response.text[:200]
|
|
"response_text": response.text[:200]
|
|
- },
|
|
+ }
|
|
- mention=False
|
|
|
|
)
|
|
)
|
|
return []
|
|
return []
|
|
|
|
|
|
@@ -56,13 +62,15 @@ def similarity_between_title_list(target_title_list: list[str], base_title_list:
|
|
response_json = response.json()
|
|
response_json = response.json()
|
|
score_array = response_json['score_list_list']
|
|
score_array = response_json['score_list_list']
|
|
except (JSONDecodeError, KeyError) as e:
|
|
except (JSONDecodeError, KeyError) as e:
|
|
- bot(
|
|
+ log(
|
|
- title='NLP响应数据异常',
|
|
+ task="nlp",
|
|
- detail={
|
|
+ function="similarity_between_title_list",
|
|
|
|
+ status="fail",
|
|
|
|
+ message='nlp server response error',
|
|
|
|
+ data={
|
|
"error_type": type(e).__name__,
|
|
"error_type": type(e).__name__,
|
|
"raw_response": response.text[:200]
|
|
"raw_response": response.text[:200]
|
|
- },
|
|
+ }
|
|
- mention=False
|
|
|
|
)
|
|
)
|
|
return []
|
|
return []
|
|
|
|
|