mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: refine error msg. (#11380)
### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -31,7 +31,7 @@ from common.constants import ActiveEnum, StatusEnum
|
|||||||
from api.utils.crypt import decrypt
|
from api.utils.crypt import decrypt
|
||||||
from common.misc_utils import get_uuid
|
from common.misc_utils import get_uuid
|
||||||
from common.time_utils import current_timestamp, datetime_format, get_format_time
|
from common.time_utils import current_timestamp, datetime_format, get_format_time
|
||||||
from common.connection_utils import construct_response
|
from common.connection_utils import sync_construct_response
|
||||||
from common import settings
|
from common import settings
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ def login_admin(email: str, password: str):
|
|||||||
user.last_login_time = get_format_time()
|
user.last_login_time = get_format_time()
|
||||||
user.save()
|
user.save()
|
||||||
msg = "Welcome back!"
|
msg = "Welcome back!"
|
||||||
return construct_response(data=resp, auth=user.get_id(), message=msg)
|
return sync_construct_response(data=resp, auth=user.get_id(), message=msg)
|
||||||
|
|
||||||
|
|
||||||
def check_admin(username: str, password: str):
|
def check_admin(username: str, password: str):
|
||||||
|
|||||||
@ -886,6 +886,7 @@ async def check_embedding():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
v, _ = emb_mdl.encode([title, txt_in])
|
v, _ = emb_mdl.encode([title, txt_in])
|
||||||
|
assert len(v[1]) == len(ck["vector"]), f"The dimension ({len(v[1])}) of given embedding model is different from the original ({len(ck['vector'])})"
|
||||||
sim_content = _cos_sim(v[1], ck["vector"])
|
sim_content = _cos_sim(v[1], ck["vector"])
|
||||||
title_w = 0.1
|
title_w = 0.1
|
||||||
qv_mix = title_w * v[0] + (1 - title_w) * v[1]
|
qv_mix = title_w * v[0] + (1 - title_w) * v[1]
|
||||||
@ -895,8 +896,8 @@ async def check_embedding():
|
|||||||
if sim_mix > sim:
|
if sim_mix > sim:
|
||||||
sim = sim_mix
|
sim = sim_mix
|
||||||
mode = "title+content"
|
mode = "title+content"
|
||||||
except Exception:
|
except Exception as e:
|
||||||
return get_error_data_result(message="embedding failure")
|
return get_error_data_result(message=f"Embedding failure. {e}")
|
||||||
|
|
||||||
eff_sims.append(sim)
|
eff_sims.append(sim)
|
||||||
results.append({
|
results.append({
|
||||||
|
|||||||
@ -120,3 +120,23 @@ async def construct_response(code=RetCode.SUCCESS, message="success", data=None,
|
|||||||
response.headers["Access-Control-Allow-Headers"] = "*"
|
response.headers["Access-Control-Allow-Headers"] = "*"
|
||||||
response.headers["Access-Control-Expose-Headers"] = "Authorization"
|
response.headers["Access-Control-Expose-Headers"] = "Authorization"
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
def sync_construct_response(code=RetCode.SUCCESS, message="success", data=None, auth=None):
|
||||||
|
import flask
|
||||||
|
result_dict = {"code": code, "message": message, "data": data}
|
||||||
|
response_dict = {}
|
||||||
|
for key, value in result_dict.items():
|
||||||
|
if value is None and key != "code":
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
response_dict[key] = value
|
||||||
|
response = flask.make_response(flask.jsonify(response_dict))
|
||||||
|
if auth:
|
||||||
|
response.headers["Authorization"] = auth
|
||||||
|
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
response.headers["Access-Control-Allow-Method"] = "*"
|
||||||
|
response.headers["Access-Control-Allow-Headers"] = "*"
|
||||||
|
response.headers["Access-Control-Allow-Headers"] = "*"
|
||||||
|
response.headers["Access-Control-Expose-Headers"] = "Authorization"
|
||||||
|
return response
|
||||||
|
|||||||
@ -4848,7 +4848,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "JieKou.AI",
|
"name": "Jiekou.AI",
|
||||||
"logo": "",
|
"logo": "",
|
||||||
"tags": "LLM,TEXT EMBEDDING,TEXT RE-RANK",
|
"tags": "LLM,TEXT EMBEDDING,TEXT RE-RANK",
|
||||||
"status": "1",
|
"status": "1",
|
||||||
|
|||||||
Reference in New Issue
Block a user