Refactor: dataset / kb API to RESTFul style (#13619)

### What problem does this PR solve?

1. Split dataset api to gateway and service, and modify web UI to use
restful http api.
2. Old KB releated APIs are commented.

### Type of change

- [x] Refactoring
This commit is contained in:
Lynn
2026-03-16 22:51:34 +08:00
committed by GitHub
parent 73bc9b91de
commit 1db5409d82
53 changed files with 1721 additions and 1207 deletions
@@ -14,7 +14,7 @@
# limitations under the License.
#
import pytest
from common import batch_create_datasets, list_kbs, rm_kb
from common import batch_create_datasets, list_datasets, delete_datasets
from libs.auth import RAGFlowWebApiAuth
from pytest import FixtureRequest
from ragflow_sdk import RAGFlow
@@ -26,11 +26,10 @@ def add_datasets(request: FixtureRequest, client: RAGFlow, WebApiAuth: RAGFlowWe
def cleanup():
# Web KB cleanup cannot call SDK dataset bulk delete with empty ids; deletion must stay explicit.
res = list_kbs(WebApiAuth, params={"page_size": 1000})
existing_ids = {kb["id"] for kb in res["data"]["kbs"]}
for dataset_id in dataset_ids:
if dataset_id in existing_ids:
rm_kb(WebApiAuth, {"kb_id": dataset_id})
res = list_datasets(WebApiAuth, params={"page_size": 1000})
existing_ids = {kb["id"] for kb in res["data"]}
ids_to_delete = list({dataset_id for dataset_id in dataset_ids if dataset_id in existing_ids})
delete_datasets(WebApiAuth, {"ids": ids_to_delete})
request.addfinalizer(cleanup)
return dataset_ids
@@ -42,11 +41,10 @@ def add_datasets_func(request: FixtureRequest, client: RAGFlow, WebApiAuth: RAGF
def cleanup():
# Web KB cleanup cannot call SDK dataset bulk delete with empty ids; deletion must stay explicit.
res = list_kbs(WebApiAuth, params={"page_size": 1000})
existing_ids = {kb["id"] for kb in res["data"]["kbs"]}
for dataset_id in dataset_ids:
if dataset_id in existing_ids:
rm_kb(WebApiAuth, {"kb_id": dataset_id})
res = list_datasets(WebApiAuth, params={"page_size": 1000})
existing_ids = {kb["id"] for kb in res["data"]}
ids_to_delete = list({dataset_id for dataset_id in dataset_ids if dataset_id in existing_ids})
delete_datasets(WebApiAuth, {"ids": ids_to_delete})
request.addfinalizer(cleanup)
return dataset_ids