Add test for CI (#3114)

### What problem does this PR solve?

Add test for CI

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn>
This commit is contained in:
liuhua
2024-10-31 14:07:23 +08:00
committed by GitHub
parent 5590a823c6
commit 9aeb07d830
13 changed files with 286 additions and 172 deletions

View File

@ -41,8 +41,8 @@ def create(tenant_id):
if kb.chunk_num == 0:
return get_error_data_result(f"The dataset {kb_id} doesn't own parsed file")
kbs = KnowledgebaseService.get_by_ids(ids)
embd_count = list(set(kb.embd_id for kb in kbs))
if embd_count != 1:
embd_count = list(set([kb.embd_id for kb in kbs]))
if len(embd_count) != 1:
return get_result(retmsg='Datasets use different embedding models."',retcode=RetCode.AUTHENTICATION_ERROR)
req["kb_ids"] = ids
# llm
@ -167,8 +167,8 @@ def update(tenant_id,chat_id):
if kb.chunk_num == 0:
return get_error_data_result(f"The dataset {kb_id} doesn't own parsed file")
kbs = KnowledgebaseService.get_by_ids(ids)
embd_count=list(set(kb.embd_id for kb in kbs))
if embd_count != 1 :
embd_count=list(set([kb.embd_id for kb in kbs]))
if len(embd_count) != 1 :
return get_result(
retmsg='Datasets use different embedding models."',
retcode=RetCode.AUTHENTICATION_ERROR)

View File

@ -120,7 +120,7 @@ def delete(tenant_id):
if not KnowledgebaseService.delete_by_id(id):
return get_error_data_result(
retmsg="Delete dataset error.(Database error)")
return get_result(retcode=RetCode.SUCCESS)
return get_result(retcode=RetCode.SUCCESS)
@manager.route('/datasets/<dataset_id>', methods=['PUT'])
@token_required

View File

@ -509,9 +509,9 @@ def rm_chunk(tenant_id,dataset_id,document_id):
if chunk_id not in sres.ids:
return get_error_data_result(f"Chunk {chunk_id} not found")
if not ELASTICSEARCH.deleteByQuery(
Q("ids", values=req["chunk_ids"]), search.index_name(tenant_id)):
Q("ids", values=chunk_list), search.index_name(tenant_id)):
return get_error_data_result(retmsg="Index updating failure")
deleted_chunk_ids = req["chunk_ids"]
deleted_chunk_ids = chunk_list
chunk_number = len(deleted_chunk_ids)
DocumentService.decrement_chunk_num(doc.id, doc.kb_id, 1, chunk_number, 0)
return get_result()

View File

@ -337,7 +337,7 @@ def valid(permission,valid_permission,language,valid_language,chunk_method,valid
def valid_parameter(parameter,valid_values):
if parameter and parameter not in valid_values:
return get_error_data_result(f"`{parameter}` is not in {valid_values}")
return get_error_data_result(f"'{parameter}' is not in {valid_values}")
def get_parser_config(chunk_method,parser_config):
if parser_config:
@ -354,6 +354,8 @@ def get_parser_config(chunk_method,parser_config):
"laws":{"raptor":{"use_raptor":False}},
"presentation":{"raptor":{"use_raptor":False}},
"one":None,
"knowledge_graph":{"chunk_token_num":8192,"delimiter":"\\n!?;。;!?","entity_types":["organization","person","location","event","time"]}}
"knowledge_graph":{"chunk_token_num":8192,"delimiter":"\\n!?;。;!?","entity_types":["organization","person","location","event","time"]},
"email":None,
"picture":None}
parser_config=key_mapping[chunk_method]
return parser_config