mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
Refactor: Change update doc from PUT to patch (#14067)
### What problem does this PR solve? Before change, update_document in api/apps/restful_apis/document_api.py is using "PUT". After change, it will use "PATCH" which is more suitable. ### Type of change - [x] Refactoring
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -32,7 +32,7 @@ from api.utils.validation_utils import (
|
||||
UpdateDocumentReq, format_validation_error_message,
|
||||
)
|
||||
|
||||
@manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["PUT"]) # noqa: F821
|
||||
@manager.route("/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):
|
||||
|
||||
@@ -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"])
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user