fix
This commit is contained in:
parent
68930d6fc7
commit
6b1097edfa
2 changed files with 9 additions and 5 deletions
|
|
@ -55,6 +55,10 @@ def create():
|
|||
**req
|
||||
)
|
||||
|
||||
code = req.get("code")
|
||||
if code:
|
||||
return get_data_error_result(code=code, message=req.get("message"))
|
||||
|
||||
try:
|
||||
if not KnowledgebaseService.save(**req):
|
||||
return get_data_error_result()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from common.time_utils import current_timestamp, datetime_format
|
|||
from api.db.services import duplicate_name
|
||||
from api.db.services.user_service import TenantService
|
||||
from common.misc_utils import get_uuid
|
||||
from common.constants import StatusEnum
|
||||
from common.constants import StatusEnum, RetCode
|
||||
from api.constants import DATASET_NAME_LIMIT
|
||||
from api.utils.api_utils import get_parser_config, get_data_error_result
|
||||
|
||||
|
|
@ -391,12 +391,12 @@ class KnowledgebaseService(CommonService):
|
|||
"""
|
||||
# Validate name
|
||||
if not isinstance(name, str):
|
||||
return get_data_error_result(message="Dataset name must be string.")
|
||||
return {"code": RetCode.DATA_ERROR, "message": "Dataset name must be string."}
|
||||
dataset_name = name.strip()
|
||||
if len(dataset_name) == 0:
|
||||
return get_data_error_result(message="Dataset name can't be empty.")
|
||||
return {"code": RetCode.DATA_ERROR, "message": "Dataset name can't be empty."}
|
||||
if len(dataset_name.encode("utf-8")) > DATASET_NAME_LIMIT:
|
||||
return get_data_error_result(message=f"Dataset name length is {len(dataset_name)} which is larger than {DATASET_NAME_LIMIT}")
|
||||
return {"code": RetCode.DATA_ERROR, "message": f"Dataset name length is {len(dataset_name)} which is larger than {DATASET_NAME_LIMIT}"}
|
||||
|
||||
# Deduplicate name within tenant
|
||||
dataset_name = duplicate_name(
|
||||
|
|
@ -409,7 +409,7 @@ class KnowledgebaseService(CommonService):
|
|||
# Verify tenant exists
|
||||
ok, _t = TenantService.get_by_id(tenant_id)
|
||||
if not ok:
|
||||
return get_data_error_result(message="Tenant does not exist.")
|
||||
return {"code": RetCode.DATA_ERROR, "message": "Tenant does not exist."}
|
||||
|
||||
# Build payload
|
||||
parser_config = get_parser_config(parser_id, kwargs.get("parser_config"))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue