Skip to content

Commit

Permalink
Turn resource to plural form (#3059)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Turn resource to plural form

### Type of change

- [x] Refactoring

Co-authored-by: liuhua <10215101452@stu.ecun.edu.cn>
  • Loading branch information
Feiue and liuhua authored Oct 28, 2024
1 parent a813736 commit f93f485
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 102 deletions.
8 changes: 4 additions & 4 deletions api/apps/sdk/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@



@manager.route('/chat', methods=['POST'])
@manager.route('/chats', methods=['POST'])
@token_required
def create(tenant_id):
req=request.json
Expand Down Expand Up @@ -142,7 +142,7 @@ def create(tenant_id):
res["avatar"] = res.pop("icon")
return get_result(data=res)

@manager.route('/chat/<chat_id>', methods=['PUT'])
@manager.route('/chats/<chat_id>', methods=['PUT'])
@token_required
def update(tenant_id,chat_id):
if not DialogService.query(tenant_id=tenant_id, id=chat_id, status=StatusEnum.VALID.value):
Expand Down Expand Up @@ -221,7 +221,7 @@ def update(tenant_id,chat_id):
return get_result()


@manager.route('/chat', methods=['DELETE'])
@manager.route('/chats', methods=['DELETE'])
@token_required
def delete(tenant_id):
req = request.json
Expand All @@ -235,7 +235,7 @@ def delete(tenant_id):
DialogService.update_by_id(id, temp_dict)
return get_result()

@manager.route('/chat', methods=['GET'])
@manager.route('/chats', methods=['GET'])
@token_required
def list_chat(tenant_id):
id = request.args.get("id")
Expand Down
8 changes: 4 additions & 4 deletions api/apps/sdk/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from api.utils.api_utils import get_result, token_required, get_error_data_result, valid,get_parser_config


@manager.route('/dataset', methods=['POST'])
@manager.route('/datasets', methods=['POST'])
@token_required
def create(tenant_id):
req = request.json
Expand Down Expand Up @@ -88,7 +88,7 @@ def create(tenant_id):
renamed_data[new_key] = value
return get_result(data=renamed_data)

@manager.route('/dataset', methods=['DELETE'])
@manager.route('/datasets', methods=['DELETE'])
@token_required
def delete(tenant_id):
req = request.json
Expand All @@ -112,7 +112,7 @@ def delete(tenant_id):
retmsg="Delete dataset error.(Database error)")
return get_result(retcode=RetCode.SUCCESS)

@manager.route('/dataset/<dataset_id>', methods=['PUT'])
@manager.route('/datasets/<dataset_id>', methods=['PUT'])
@token_required
def update(tenant_id,dataset_id):
if not KnowledgebaseService.query(id=dataset_id,tenant_id=tenant_id):
Expand Down Expand Up @@ -183,7 +183,7 @@ def update(tenant_id,dataset_id):
return get_error_data_result(retmsg="Update dataset error.(Database error)")
return get_result(retcode=RetCode.SUCCESS)

@manager.route('/dataset', methods=['GET'])
@manager.route('/datasets', methods=['GET'])
@token_required
def list(tenant_id):
id = request.args.get("id")
Expand Down
2 changes: 1 addition & 1 deletion api/apps/sdk/dify_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from api.utils.api_utils import validate_request, build_error_result, apikey_required


@manager.route('/dify/retrieval', methods=['POST'])
@manager.route('/dify/retrievals', methods=['POST'])
@apikey_required
@validate_request("knowledge_id", "query")
def retrieval(tenant_id):
Expand Down
24 changes: 12 additions & 12 deletions api/apps/sdk/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
MAXIMUM_OF_UPLOADING_FILES = 256


@manager.route('/dataset/<dataset_id>/document', methods=['POST'])
@manager.route('/datasets/<dataset_id>/documents', methods=['POST'])
@token_required
def upload(dataset_id, tenant_id):
if 'file' not in request.files:
Expand Down Expand Up @@ -103,7 +103,7 @@ def upload(dataset_id, tenant_id):
return get_result(data=renamed_doc_list)


@manager.route('/dataset/<dataset_id>/info/<document_id>', methods=['PUT'])
@manager.route('/datasets/<dataset_id>/documents/<document_id>', methods=['PUT'])
@token_required
def update_doc(tenant_id, dataset_id, document_id):
req = request.json
Expand Down Expand Up @@ -169,7 +169,7 @@ def update_doc(tenant_id, dataset_id, document_id):
return get_result()


@manager.route('/dataset/<dataset_id>/document/<document_id>', methods=['GET'])
@manager.route('/datasets/<dataset_id>/documents/<document_id>', methods=['GET'])
@token_required
def download(tenant_id, dataset_id, document_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand All @@ -192,7 +192,7 @@ def download(tenant_id, dataset_id, document_id):
)


@manager.route('/dataset/<dataset_id>/info', methods=['GET'])
@manager.route('/datasets/<dataset_id>/documents', methods=['GET'])
@token_required
def list_docs(dataset_id, tenant_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand Down Expand Up @@ -236,7 +236,7 @@ def list_docs(dataset_id, tenant_id):
return get_result(data={"total": tol, "docs": renamed_doc_list})


@manager.route('/dataset/<dataset_id>/document', methods=['DELETE'])
@manager.route('/datasets/<dataset_id>/documents', methods=['DELETE'])
@token_required
def delete(tenant_id,dataset_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand Down Expand Up @@ -286,7 +286,7 @@ def delete(tenant_id,dataset_id):
return get_result()


@manager.route('/dataset/<dataset_id>/chunk', methods=['POST'])
@manager.route('/datasets/<dataset_id>/chunks', methods=['POST'])
@token_required
def parse(tenant_id,dataset_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand Down Expand Up @@ -316,7 +316,7 @@ def parse(tenant_id,dataset_id):
queue_tasks(doc, bucket, name)
return get_result()

@manager.route('/dataset/<dataset_id>/chunk', methods=['DELETE'])
@manager.route('/datasets/<dataset_id>/chunks', methods=['DELETE'])
@token_required
def stop_parsing(tenant_id,dataset_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand All @@ -339,7 +339,7 @@ def stop_parsing(tenant_id,dataset_id):
return get_result()


@manager.route('/dataset/<dataset_id>/document/<document_id>/chunk', methods=['GET'])
@manager.route('/datasets/<dataset_id>/documents/<document_id>/chunks', methods=['GET'])
@token_required
def list_chunks(tenant_id,dataset_id,document_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand Down Expand Up @@ -427,7 +427,7 @@ def list_chunks(tenant_id,dataset_id,document_id):



@manager.route('/dataset/<dataset_id>/document/<document_id>/chunk', methods=['POST'])
@manager.route('/datasets/<dataset_id>/documents/<document_id>/chunks', methods=['POST'])
@token_required
def add_chunk(tenant_id,dataset_id,document_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand Down Expand Up @@ -488,7 +488,7 @@ def add_chunk(tenant_id,dataset_id,document_id):
# return get_result(data={"chunk_id": chunk_id})


@manager.route('dataset/<dataset_id>/document/<document_id>/chunk', methods=['DELETE'])
@manager.route('datasets/<dataset_id>/documents/<document_id>/chunks', methods=['DELETE'])
@token_required
def rm_chunk(tenant_id,dataset_id,document_id):
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
Expand Down Expand Up @@ -516,7 +516,7 @@ def rm_chunk(tenant_id,dataset_id,document_id):



@manager.route('/dataset/<dataset_id>/document/<document_id>/chunk/<chunk_id>', methods=['PUT'])
@manager.route('/datasets/<dataset_id>/documents/<document_id>/chunks/<chunk_id>', methods=['PUT'])
@token_required
def update_chunk(tenant_id,dataset_id,document_id,chunk_id):
try:
Expand Down Expand Up @@ -574,7 +574,7 @@ def update_chunk(tenant_id,dataset_id,document_id,chunk_id):



@manager.route('/retrieval', methods=['POST'])
@manager.route('/retrievals', methods=['POST'])
@token_required
def retrieval_test(tenant_id):
req = request.json
Expand Down
10 changes: 5 additions & 5 deletions api/apps/sdk/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from api.utils.api_utils import get_error_data_result
from api.utils.api_utils import get_result, token_required

@manager.route('/chat/<chat_id>/session', methods=['POST'])
@manager.route('/chats/<chat_id>/sessions', methods=['POST'])
@token_required
def create(tenant_id,chat_id):
req = request.json
Expand All @@ -50,7 +50,7 @@ def create(tenant_id,chat_id):
del conv["reference"]
return get_result(data=conv)

@manager.route('/chat/<chat_id>/session/<session_id>', methods=['PUT'])
@manager.route('/chats/<chat_id>/sessions/<session_id>', methods=['PUT'])
@token_required
def update(tenant_id,chat_id,session_id):
req = request.json
Expand All @@ -72,7 +72,7 @@ def update(tenant_id,chat_id,session_id):
return get_result()


@manager.route('/chat/<chat_id>/completion', methods=['POST'])
@manager.route('/chats/<chat_id>/completions', methods=['POST'])
@token_required
def completion(tenant_id,chat_id):
req = request.json
Expand Down Expand Up @@ -161,7 +161,7 @@ def stream():
break
return get_result(data=answer)

@manager.route('/chat/<chat_id>/session', methods=['GET'])
@manager.route('/chats/<chat_id>/sessions', methods=['GET'])
@token_required
def list(chat_id,tenant_id):
if not DialogService.query(tenant_id=tenant_id, id=chat_id, status=StatusEnum.VALID.value):
Expand Down Expand Up @@ -213,7 +213,7 @@ def list(chat_id,tenant_id):
del conv["reference"]
return get_result(data=convs)

@manager.route('/chat/<chat_id>/session', methods=["DELETE"])
@manager.route('/chats/<chat_id>/sessions', methods=["DELETE"])
@token_required
def delete(tenant_id,chat_id):
if not DialogService.query(id=chat_id, tenant_id=tenant_id, status=StatusEnum.VALID.value):
Expand Down
Loading

0 comments on commit f93f485

Please sign in to comment.