Bug fix: Enhance embeding model to give better error message (#15346)

To resolve https://github.com/infiniflow/ragflow/issues/15343 enhance
the model embedding message to give extact failure message to customer.


# QWen

## Retrieval
<img width="3321" height="1033" alt="image"
src="https://github.com/user-attachments/assets/6b82921a-a3a7-4a33-a383-1cf316398ee2"
/>

## Chat
<img width="2241" height="311" alt="image"
src="https://github.com/user-attachments/assets/ec311365-62d5-407a-8915-5c8d72be9716"
/>


# SiliconFlow
## Retrieval
<img width="3321" height="1033" alt="image"
src="https://github.com/user-attachments/assets/ee2cd191-a27d-4729-b53d-2fbdb4e352cd"
/>

## Chat
<img width="1562" height="210" alt="image"
src="https://github.com/user-attachments/assets/10376a8e-a3f4-422f-bc2e-96f2a8a96448"
/>

# Baichuan
## Retrieval
<img width="3321" height="1107" alt="image"
src="https://github.com/user-attachments/assets/dcb5409d-f7fc-4804-b186-5e1ee11e09c4"
/>

## Chat
<img width="2241" height="311" alt="image"
src="https://github.com/user-attachments/assets/ec311365-62d5-407a-8915-5c8d72be9716"
/>


# Zhipu
zhipu is good.
This commit is contained in:
Wang Qi
2026-06-01 19:18:16 +08:00
committed by GitHub
parent 252cc19f93
commit 1a6df01b53
8 changed files with 191 additions and 57 deletions

View File

@@ -34,6 +34,7 @@ from quart_schema import QuartSchema
from common import settings
from api.utils.api_utils import server_error_response, get_json_result
from api.constants import API_VERSION
from common.exceptions import ModelException
from common.misc_utils import get_uuid
settings.init_settings()
@@ -361,6 +362,12 @@ async def unauthorized_werkzeug(error):
return get_json_result(code=error.code, message=error.description), RetCode.UNAUTHORIZED
@app.errorhandler(ModelException)
async def handle_model_exception(error):
logging.warning("Forbidden request")
return get_json_result(code=RetCode.BAD_REQUEST, message=repr(error)), 200
@app.teardown_request
def _db_close(exception):
if exception:

View File

@@ -497,17 +497,11 @@ async def search_datasets(tenant_id):
req, err = await validate_and_parse_json_request(request, SearchDatasetsReq)
if err is not None:
return get_error_argument_result(err)
try:
success, result = await dataset_api_service.search_datasets(tenant_id, req)
if success:
return get_result(data=result)
else:
return get_error_data_result(message=result)
except Exception as e:
logging.exception(e)
if "not_found" in str(e):
return get_error_data_result(message="No chunk found! Check the chunk status please!")
return get_error_data_result(message="Internal server error")
success, result = await dataset_api_service.search_datasets(tenant_id, req)
if success:
return get_result(data=result)
else:
return get_error_data_result(message=result)
@manager.route("/datasets/<dataset_id>/search", methods=["POST"]) # noqa: F821

View File

@@ -147,6 +147,9 @@ def server_error_response(e):
if repr(e).find("index_not_found_exception") >= 0:
return get_json_result(code=RetCode.EXCEPTION_ERROR, message="No chunk found, please upload file and parse it.")
if "not_found" in str(e):
return get_error_data_result(message="No chunk found! Check the chunk status please!")
return get_json_result(code=RetCode.EXCEPTION_ERROR, message=repr(e))