Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Refactor: Change update doc from PUT to patch (#14067)

Jack576431de99ce
diff --git a/admin/client/ragflow_client.py b/admin/client/ragflow_client.py
index 065dee484e..e718a3d768 100644
--- a/admin/client/ragflow_client.py
+++ b/admin/client/ragflow_client.py
@@ -1623,7 +1623,7 @@ class RAGFlowClient:
}
response = self.http_client.request(
- "PUT",
+ "PATCH",
f"/datasets/{dataset_id}/documents/{doc_id}",
json_body=payload,
use_api_base=True,
diff --git a/api/apps/restful_apis/document_api.py b/api/apps/restful_apis/document_api.py
index 9ce7bf6670..5031ab240d 100644
--- a/api/apps/restful_apis/document_api.py
+++ b/api/apps/restful_apis/document_api.py
@@ -32,7 +32,7 @@ from api.utils.validation_utils import (
UpdateDocumentReq, format_validation_error_message,
)
[email protected]("/datasets/<dataset_id>/documents/<document_id>", methods=["PUT"]) # noqa: F821
[email protected]("/datasets/<dataset_id>/documents/<document_id>", methods=["PATCH"]) # noqa: F821
@login_required
@add_tenant_id_to_kwargs
async def update_document(tenant_id, dataset_id, document_id):
diff --git a/sdk/python/ragflow_sdk/modules/document.py b/sdk/python/ragflow_sdk/modules/document.py
index 4aa3dce070..4df6d7d526 100644
--- a/sdk/python/ragflow_sdk/modules/document.py
+++ b/sdk/python/ragflow_sdk/modules/document.py
@@ -54,7 +54,7 @@ class Document(Base):
if "meta_fields" in update_message:
if not isinstance(update_message["meta_fields"], dict):
raise Exception("meta_fields must be a dictionary")
- res = self.put(f"/datasets/{self.dataset_id}/documents/{self.id}", update_message)
+ res = self.patch(f"/datasets/{self.dataset_id}/documents/{self.id}", update_message)
res = res.json()
if res.get("code") != 0:
raise Exception(res["message"])
diff --git a/test/testcases/test_http_api/common.py b/test/testcases/test_http_api/common.py
index 1e659291ee..198090ee80 100644
--- a/test/testcases/test_http_api/common.py
+++ b/test/testcases/test_http_api/common.py
@@ -122,7 +122,7 @@ def list_documents(auth, dataset_id, params=None):
def update_document(auth, dataset_id, document_id, payload=None):
url = f"{HOST_ADDRESS}{FILE_API_URL}/{document_id}".format(dataset_id=dataset_id)
- res = requests.put(url=url, headers=HEADERS, auth=auth, json=payload)
+ res = requests.patch(url=url, headers=HEADERS, auth=auth, json=payload)
return res.json()
diff --git a/web/src/pages/agents/agent-templates.tsx b/web/src/pages/agents/agent-templates.tsx
index 46737ba3a8..493a724052 100644
--- a/web/src/pages/agents/agent-templates.tsx
+++ b/web/src/pages/agents/agent-templates.tsx
@@ -79,18 +79,16 @@ export default function AgentTemplates() {
return templateList;
}
const selectedCanvasType = selectMenuItem.toLocaleLowerCase();
- return templateList.filter(
- (item) => {
- if (Array.isArray(item.canvas_types) && item.canvas_types.length > 0) {
- return item.canvas_types.some(
- (canvasType) =>
- typeof canvasType === 'string' &&
- canvasType.toLocaleLowerCase() === selectedCanvasType,
- );
- }
- return item.canvas_type?.toLocaleLowerCase() === selectedCanvasType;
- },
- );
+ return templateList.filter((item) => {
+ if (Array.isArray(item.canvas_types) && item.canvas_types.length > 0) {
+ return item.canvas_types.some(
+ (canvasType) =>
+ typeof canvasType === 'string' &&
+ canvasType.toLocaleLowerCase() === selectedCanvasType,
+ );
+ }
+ return item.canvas_type?.toLocaleLowerCase() === selectedCanvasType;
+ });
}, [selectMenuItem, templateList]);
return (
diff --git a/web/src/services/knowledge-service.ts b/web/src/services/knowledge-service.ts
index 0d5d811241..75f6d7342a 100644
--- a/web/src/services/knowledge-service.ts
+++ b/web/src/services/knowledge-service.ts
@@ -27,7 +27,6 @@ const {
switchChunk,
rmChunk,
retrievalTest,
- documentRename,
documentRun,
documentUpload,
webCrawl,
@@ -75,10 +74,6 @@ const methods = {
url: documentRm,
method: 'post',
},
- documentRename: {
- url: documentRename,
- method: 'put',
- },
documentCreate: {
url: documentCreate,
method: 'post',
@@ -255,7 +250,7 @@ export const renameDocument = (
datasetId: string,
documentId: string,
data: { name?: string },
-) => request.put(api.documentRename(datasetId, documentId), { data });
+) => request.patch(api.documentRename(datasetId, documentId), { data });
export const getMetaDataService = ({
kb_id,
diff --git a/web/src/services/plugin-service.ts b/web/src/services/plugin-service.ts
index 9435c2a0de..38fa0ed630 100644
--- a/web/src/services/plugin-service.ts
+++ b/web/src/services/plugin-service.ts
@@ -2,9 +2,7 @@ import api from '@/utils/api';
import registerServer from '@/utils/register-server';
import request from '@/utils/request';
-const {
- llmTools
-} = api;
+const { llmTools } = api;
const methods = {
getLlmTools: {