Update docnm_kwd to doc_name (#939)

### What problem does this PR solve?

Update docnm_kwd to doc_name 
#908 

### Type of change


- [x] Refactoring
This commit is contained in:
GYH 2024-05-27 19:14:04 +08:00 committed by GitHub
parent 65677f65c9
commit 7d8e03ec38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -203,6 +203,9 @@ def completion():
try:
for ans in chat(dia, msg, True, **req):
fillin_conv(ans)
for chunk_i in ans['reference'].get('chunks', []):
chunk_i['doc_name'] = chunk_i['docnm_kwd']
chunk_i.pop('docnm_kwd')
yield "data:"+json.dumps({"retcode": 0, "retmsg": "", "data": ans}, ensure_ascii=False) + "\n\n"
API4ConversationService.append_message(conv.id, conv.to_dict())
except Exception as e:
@ -225,6 +228,11 @@ def completion():
fillin_conv(ans)
API4ConversationService.append_message(conv.id, conv.to_dict())
break
for chunk_i in answer['reference'].get('chunks',[]):
chunk_i['doc_name'] = chunk_i['docnm_kwd']
chunk_i.pop('docnm_kwd')
return get_json_result(data=answer)
except Exception as e:
@ -239,7 +247,13 @@ def get(conversation_id):
if not e:
return get_data_error_result(retmsg="Conversation not found!")
return get_json_result(data=conv.to_dict())
conv = conv.to_dict()
for referenct_i in conv['reference']:
for chunk_i in referenct_i['chunks']:
if 'docnm_kwd' in chunk_i.keys():
chunk_i['doc_name'] = chunk_i['docnm_kwd']
chunk_i.pop('docnm_kwd')
return get_json_result(data=conv)
except Exception as e:
return server_error_response(e)
@ -430,7 +444,7 @@ def list_kb_docs():
return server_error_response(e)
@manager.route('/document/rm', methods=['POST'])
@manager.route('/document', methods=['DELETE'])
# @login_required
def document_rm():
token = request.headers.get('Authorization').split()[1]