Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: document batch operation tool add re-index operation (#30275)
wangxiaolei8b38e3f79d3c
diff --git a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx b/web/app/components/datasets/documents/detail/completed/common/batch-action.tsxindex 6cc60453dde..bf43e41dee8 100644--- a/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx+++ b/web/app/components/datasets/documents/detail/completed/common/batch-action.tsx@@ -1,5 +1,5 @@import type { FC } from 'react'-import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine, RiDraftLine } from '@remixicon/react'+import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine, RiDraftLine, RiRefreshLine } from '@remixicon/react'import { useBoolean } from 'ahooks'import * as React from 'react'import { useTranslation } from 'react-i18next'@@ -17,6 +17,7 @@ type IBatchActionProps = {onBatchDelete: () => Promise<void>onArchive?: () => voidonEditMetadata?: () => void+ onBatchReIndex?: () => voidonCancel: () => void}@@ -28,6 +29,7 @@ const BatchAction: FC<IBatchActionProps> = ({onArchive,onBatchDelete,onEditMetadata,+ onBatchReIndex,onCancel,}) => {const { t } = useTranslation()@@ -91,6 +93,16 @@ const BatchAction: FC<IBatchActionProps> = ({<span className="px-0.5">{t(`${i18nPrefix}.archive`)}</span></Button>)}+ {onBatchReIndex && (+ <Button+ variant="ghost"+ className="gap-x-0.5 px-3"+ onClick={onBatchReIndex}+ >+ <RiRefreshLine className="size-4" />+ <span className="px-0.5">{t(`${i18nPrefix}.reIndex`)}</span>+ </Button>+ )}<Buttonvariant="ghost"destructivediff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsxindex 670cdd659c9..348ecb271eb 100644--- a/web/app/components/datasets/documents/list.tsx+++ b/web/app/components/datasets/documents/list.tsx@@ -26,7 +26,7 @@ import { useDatasetDetailContextWithSelector as useDatasetDetailContext } from 'import useTimestamp from '@/hooks/use-timestamp'import { ChunkingMode, DataSourceType, DocumentActionType } from '@/models/datasets'import { DatasourceType } from '@/models/pipeline'-import { useDocumentArchive, useDocumentDelete, useDocumentDisable, useDocumentEnable } from '@/service/knowledge/use-document'+import { useDocumentArchive, useDocumentBatchRetryIndex, useDocumentDelete, useDocumentDisable, useDocumentEnable } from '@/service/knowledge/use-document'import { asyncRunSafe } from '@/utils'import { cn } from '@/utils/classnames'import { formatNumber } from '@/utils/format'@@ -220,6 +220,7 @@ const DocumentList: FC<IDocumentListProps> = ({const { mutateAsync: enableDocument } = useDocumentEnable()const { mutateAsync: disableDocument } = useDocumentDisable()const { mutateAsync: deleteDocument } = useDocumentDelete()+ const { mutateAsync: retryIndexDocument } = useDocumentBatchRetryIndex()const handleAction = (actionName: DocumentActionType) => {return async () => {@@ -250,6 +251,22 @@ const DocumentList: FC<IDocumentListProps> = ({}}+ const handleBatchReIndex = async () => {+ const [e] = await asyncRunSafe<CommonResponse>(retryIndexDocument({ datasetId, documentIds: selectedIds }))+ if (!e) {+ onSelectedIdChange([])+ Toast.notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })+ onUpdate()+ }+ else {+ Toast.notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })+ }+ }++ const hasErrorDocumentsSelected = useMemo(() => {+ return localDocs.some(doc => selectedIds.includes(doc.id) && doc.display_status === 'error')+ }, [localDocs, selectedIds])+const getFileExtension = useCallback((fileName: string): string => {if (!fileName)return ''@@ -447,6 +464,7 @@ const DocumentList: FC<IDocumentListProps> = ({onBatchDisable={handleAction(DocumentActionType.disable)}onBatchDelete={handleAction(DocumentActionType.delete)}onEditMetadata={showEditModal}+ onBatchReIndex={hasErrorDocumentsSelected ? handleBatchReIndex : undefined}onCancel={() => {onSelectedIdChange([])}}diff --git a/web/i18n/en-US/dataset.ts b/web/i18n/en-US/dataset.tsindex ee1997f6999..af144266905 100644--- a/web/i18n/en-US/dataset.ts+++ b/web/i18n/en-US/dataset.ts@@ -170,6 +170,7 @@ const translation = {enable: 'Enable',disable: 'Disable',archive: 'Archive',+ reIndex: 'Re-index',delete: 'Delete',cancel: 'Cancel',},diff --git a/web/i18n/zh-Hans/dataset.ts b/web/i18n/zh-Hans/dataset.tsindex 781fb5aa943..7abd208edf4 100644--- a/web/i18n/zh-Hans/dataset.ts+++ b/web/i18n/zh-Hans/dataset.ts@@ -170,6 +170,7 @@ const translation = {enable: '启用',disable: '禁用',archive: '归档',+ reIndex: '重新索引',delete: '删除',cancel: '取消',},diff --git a/web/service/knowledge/use-document.ts b/web/service/knowledge/use-document.tsindex 476f3534bc5..63713130d92 100644--- a/web/service/knowledge/use-document.ts+++ b/web/service/knowledge/use-document.ts@@ -7,7 +7,7 @@ import {} from '@tanstack/react-query'import { normalizeStatusForQuery } from '@/app/components/datasets/documents/status-filter'import { DocumentActionType } from '@/models/datasets'-import { del, get, patch } from '../base'+import { del, get, patch, post } from '../base'import { pauseDocIndexing, resumeDocIndexing } from '../datasets'import { useInvalid } from '../use-base'@@ -163,3 +163,15 @@ export const useDocumentResume = () => {},})}++export const useDocumentBatchRetryIndex = () => {+ return useMutation({+ mutationFn: ({ datasetId, documentIds }: { datasetId: string, documentIds: string[] }) => {+ return post<CommonResponse>(`/datasets/${datasetId}/retry`, {+ body: {+ document_ids: documentIds,+ },+ })+ },+ })+}