mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-04 23:00:30 +08:00
Refactor: Consolidation WEB API & HTTP API for document list_docs (#14176)
### What problem does this PR solve? Before consolidation Web API: POST /v1/document/list Http API - GET /api/v1/datasets/<dataset_id>/documents After consolidation, Restful API -- GET /api/v1/datasets/<dataset_id>/documents ### Type of change - [x] Refactoring
This commit is contained in:
@@ -8,12 +8,12 @@ export enum KnowledgeRouteKey {
|
||||
export const DatasetBaseKey = 'dataset';
|
||||
|
||||
export enum RunningStatus {
|
||||
UNSTART = '0', // need to run
|
||||
RUNNING = '1', // need to cancel
|
||||
CANCEL = '2', // need to refresh
|
||||
DONE = '3', // need to refresh
|
||||
FAIL = '4', // need to refresh
|
||||
SCHEDULE = '5',
|
||||
UNSTART = 'UNSTART', // need to run
|
||||
RUNNING = 'RUNNING', // need to cancel
|
||||
CANCEL = 'CANCEL', // need to refresh
|
||||
DONE = 'DONE', // need to refresh
|
||||
FAIL = 'FAIL', // need to refresh
|
||||
SCHEDULE = 'SCHEDULE',
|
||||
}
|
||||
|
||||
export const RunningStatusMap = {
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface IDocumentInfo {
|
||||
created_by: string;
|
||||
nickname: string;
|
||||
id: string;
|
||||
kb_id: string;
|
||||
dataset_id: string;
|
||||
location: string;
|
||||
name: string;
|
||||
parser_config: IParserConfig;
|
||||
|
||||
@@ -94,7 +94,7 @@ export function useDatasetTableColumns({
|
||||
className="flex items-center gap-2 cursor-pointer"
|
||||
onClick={navigateToChunkParsedResult(
|
||||
row.original.id,
|
||||
row.original.kb_id,
|
||||
row.original.dataset_id,
|
||||
)}
|
||||
>
|
||||
<FileIcon name={name}></FileIcon>
|
||||
|
||||
@@ -15,18 +15,18 @@ export const useRenameDocument = () => {
|
||||
|
||||
const onRenameOk = useCallback(
|
||||
async (name: string) => {
|
||||
if (record?.id && record?.kb_id) {
|
||||
if (record?.id && record?.dataset_id) {
|
||||
const ret = await saveName({
|
||||
documentId: record.id,
|
||||
name,
|
||||
kbId: record.kb_id,
|
||||
kbId: record.dataset_id,
|
||||
});
|
||||
if (ret === 0) {
|
||||
hideRenameModal();
|
||||
}
|
||||
}
|
||||
},
|
||||
[record?.id, record?.kb_id, saveName, hideRenameModal],
|
||||
[record?.id, record?.dataset_id, saveName, hideRenameModal],
|
||||
);
|
||||
|
||||
const handleShow = useCallback(
|
||||
|
||||
@@ -241,10 +241,25 @@ export const runRaptor = (datasetId: string) =>
|
||||
export const traceRaptor = (datasetId: string) =>
|
||||
request.get(api.traceRaptor(datasetId));
|
||||
|
||||
// Using RESTful API: GET /api/v1/datasets/{dataset_id}/documents
|
||||
export const listDocument = (
|
||||
params?: IFetchKnowledgeListRequestParams,
|
||||
body?: IFetchDocumentListRequestBody,
|
||||
) => request.post(api.getDocumentList, { data: body || {}, params });
|
||||
) => {
|
||||
if (!params || !params.id) {
|
||||
throw new Error('params and params.id are required');
|
||||
}
|
||||
// Extract page, page_size, and ext.keywords from params
|
||||
const { page, page_size, ext } = params;
|
||||
// Merge: page, page_size, keywords (from ext), body, and remaining params
|
||||
const mergedParams = {
|
||||
page,
|
||||
page_size,
|
||||
keywords: ext?.keywords,
|
||||
...body,
|
||||
};
|
||||
return request.get(api.getDocumentList(params.id), { params: mergedParams });
|
||||
};
|
||||
|
||||
export const documentFilter = (kb_id: string) =>
|
||||
request.post(api.getDatasetFilter, { kb_id });
|
||||
|
||||
@@ -106,7 +106,8 @@ export default {
|
||||
knowledgeGraph: `${webAPI}/chunk/knowledge_graph`,
|
||||
|
||||
// document
|
||||
getDocumentList: `${webAPI}/document/list`,
|
||||
getDocumentList: (datasetId: string) =>
|
||||
`${restAPIv1}/datasets/${datasetId}/documents`,
|
||||
documentChangeStatus: `${webAPI}/document/change_status`,
|
||||
documentRm: `${webAPI}/document/rm`,
|
||||
documentDelete: `${webAPI}/api/document`,
|
||||
|
||||
Reference in New Issue
Block a user