From 4be85870e02ef9ba3f10b4fb8d7a580aa0ed9af0 Mon Sep 17 00:00:00 2001 From: Sean Sun <1194458432@qq.com> Date: Wed, 1 Jan 2025 13:08:15 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20data=5Fsource=20?= =?UTF-8?q?=E4=B8=AD=E7=A1=AE=E5=AE=9E=20data=5Fsource=5Ftype=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controllers/service_api/dataset/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/service_api/dataset/document.py b/api/controllers/service_api/dataset/document.py index ea664b8f1be4d4..1ac553f9004c84 100644 --- a/api/controllers/service_api/dataset/document.py +++ b/api/controllers/service_api/dataset/document.py @@ -190,7 +190,7 @@ def post(self, tenant_id, dataset_id): user=current_user, source="datasets", ) - data_source = {"type": "upload_file", "info_list": {"file_info_list": {"file_ids": [upload_file.id]}}} + data_source = {"type": "upload_file", "info_list": {"data_source_type":"upload_file", "file_info_list": {"file_ids": [upload_file.id]}}} args["data_source"] = data_source # validate args knowledge_config = KnowledgeConfig(**args) From 3310b24d2edb8eeba16ffec8dd3dce27432a8e49 Mon Sep 17 00:00:00 2001 From: Sean Sun <1194458432@qq.com> Date: Wed, 1 Jan 2025 13:36:57 +0800 Subject: [PATCH 2/5] fit the python code style, add space after the colon mark of data_source_type field --- api/controllers/service_api/dataset/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/service_api/dataset/document.py b/api/controllers/service_api/dataset/document.py index 1ac553f9004c84..14a6acae598f23 100644 --- a/api/controllers/service_api/dataset/document.py +++ b/api/controllers/service_api/dataset/document.py @@ -190,7 +190,7 @@ def post(self, tenant_id, dataset_id): user=current_user, source="datasets", ) - data_source = {"type": "upload_file", "info_list": {"data_source_type":"upload_file", "file_info_list": {"file_ids": [upload_file.id]}}} + data_source = {"type": "upload_file", "info_list": {"data_source_type": "upload_file", "file_info_list": {"file_ids": [upload_file.id]}}} args["data_source"] = data_source # validate args knowledge_config = KnowledgeConfig(**args) From 733b39fd5dcafc3727787da15e1ee1e10b948ee6 Mon Sep 17 00:00:00 2001 From: Sean Sun <1194458432@qq.com> Date: Wed, 1 Jan 2025 14:48:58 +0800 Subject: [PATCH 3/5] refer to DocumentUpdateByTextApi adjust the format --- api/controllers/service_api/dataset/document.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/controllers/service_api/dataset/document.py b/api/controllers/service_api/dataset/document.py index 14a6acae598f23..b237ba011b0ab8 100644 --- a/api/controllers/service_api/dataset/document.py +++ b/api/controllers/service_api/dataset/document.py @@ -190,7 +190,10 @@ def post(self, tenant_id, dataset_id): user=current_user, source="datasets", ) - data_source = {"type": "upload_file", "info_list": {"data_source_type": "upload_file", "file_info_list": {"file_ids": [upload_file.id]}}} + data_source = { + "type": "upload_file", + "info_list": {"data_source_type": "upload_file", "file_info_list": {"file_ids": [upload_file.id]}} + } args["data_source"] = data_source # validate args knowledge_config = KnowledgeConfig(**args) From 7630d843c9bd26907472f3b15547566ce89e84ee Mon Sep 17 00:00:00 2001 From: Sean Sun <1194458432@qq.com> Date: Thu, 2 Jan 2025 10:42:45 +0800 Subject: [PATCH 4/5] meet the ruff require format --- api/controllers/service_api/dataset/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/service_api/dataset/document.py b/api/controllers/service_api/dataset/document.py index b237ba011b0ab8..0fd6601721f563 100644 --- a/api/controllers/service_api/dataset/document.py +++ b/api/controllers/service_api/dataset/document.py @@ -192,7 +192,7 @@ def post(self, tenant_id, dataset_id): ) data_source = { "type": "upload_file", - "info_list": {"data_source_type": "upload_file", "file_info_list": {"file_ids": [upload_file.id]}} + "info_list": {"data_source_type": "upload_file", "file_info_list": {"file_ids": [upload_file.id]}}, } args["data_source"] = data_source # validate args From 6f1de8da9a83fc27195bbf5f528f86078a6a22bc Mon Sep 17 00:00:00 2001 From: Sean Sun <1194458432@qq.com> Date: Thu, 2 Jan 2025 10:50:40 +0800 Subject: [PATCH 5/5] fix the DocumentUpdateByFileApi for the same problem --- api/controllers/service_api/dataset/document.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/controllers/service_api/dataset/document.py b/api/controllers/service_api/dataset/document.py index 0fd6601721f563..2e148dd84c05da 100644 --- a/api/controllers/service_api/dataset/document.py +++ b/api/controllers/service_api/dataset/document.py @@ -257,7 +257,10 @@ def post(self, tenant_id, dataset_id, document_id): raise FileTooLargeError(file_too_large_error.description) except services.errors.file.UnsupportedFileTypeError: raise UnsupportedFileTypeError() - data_source = {"type": "upload_file", "info_list": {"file_info_list": {"file_ids": [upload_file.id]}}} + data_source = { + "type": "upload_file", + "info_list": {"data_source_type": "upload_file", "file_info_list": {"file_ids": [upload_file.id]}}, + } args["data_source"] = data_source # validate args args["original_document_id"] = str(document_id)