diff --git a/lightrag/api/routers/document_routes.py b/lightrag/api/routers/document_routes.py index 7dc2c34c..7e3703bd 100644 --- a/lightrag/api/routers/document_routes.py +++ b/lightrag/api/routers/document_routes.py @@ -454,7 +454,7 @@ class DocsStatusesResponse(BaseModel): "id": "doc_789", "content_summary": "Document pending final indexing", "content_length": 7200, - "status": "multimodal_processed", + "status": "preprocessed", "created_at": "2025-03-31T09:30:00", "updated_at": "2025-03-31T09:35:00", "track_id": "upload_20250331_093000_xyz789", diff --git a/lightrag/base.py b/lightrag/base.py index 45c5cb2c..6c125ef8 100644 --- a/lightrag/base.py +++ b/lightrag/base.py @@ -712,7 +712,7 @@ class DocStatus(str, Enum): PENDING = "pending" PROCESSING = "processing" - PREPROCESSED = "multimodal_processed" + PREPROCESSED = "preprocessed" PROCESSED = "processed" FAILED = "failed" @@ -743,6 +743,25 @@ class DocProcessingStatus: """Error message if failed""" metadata: dict[str, Any] = field(default_factory=dict) """Additional metadata""" + multimodal_processed: bool | None = field(default=None, repr=False) + """Internal field: indicates if multimodal processing is complete. Not shown in repr() but accessible for debugging.""" + + def __post_init__(self): + """ + Handle status conversion based on multimodal_processed field. + + Business rules: + - If multimodal_processed is False and status is PROCESSED, + then change status to PREPROCESSED + - The multimodal_processed field is kept (with repr=False) for internal use and debugging + """ + # Apply status conversion logic + if self.multimodal_processed is not None: + if ( + self.multimodal_processed is False + and self.status == DocStatus.PROCESSED + ): + self.status = DocStatus.PREPROCESSED @dataclass diff --git a/lightrag_webui/src/api/lightrag.ts b/lightrag_webui/src/api/lightrag.ts index d370739d..5b273595 100644 --- a/lightrag_webui/src/api/lightrag.ts +++ b/lightrag_webui/src/api/lightrag.ts @@ -167,7 +167,7 @@ export type DeleteDocResponse = { doc_id: string } -export type DocStatus = 'pending' | 'processing' | 'multimodal_processed' | 'processed' | 'failed' +export type DocStatus = 'pending' | 'processing' | 'preprocessed' | 'processed' | 'failed' export type DocStatusResponse = { id: string diff --git a/lightrag_webui/src/features/DocumentManager.tsx b/lightrag_webui/src/features/DocumentManager.tsx index 4fd06e82..2791165f 100644 --- a/lightrag_webui/src/features/DocumentManager.tsx +++ b/lightrag_webui/src/features/DocumentManager.tsx @@ -53,7 +53,7 @@ const getCountValue = (counts: Record, ...keys: string[]): numbe const hasActiveDocumentsStatus = (counts: Record): boolean => getCountValue(counts, 'PROCESSING', 'processing') > 0 || getCountValue(counts, 'PENDING', 'pending') > 0 || - getCountValue(counts, 'PREPROCESSED', 'preprocessed', 'multimodal_processed') > 0 + getCountValue(counts, 'PREPROCESSED', 'preprocessed') > 0 const getDisplayFileName = (doc: DocStatusResponse, maxLength: number = 20): string => { // Check if file_path exists and is a non-empty string @@ -276,7 +276,7 @@ export default function DocumentManager() { const [pageByStatus, setPageByStatus] = useState>({ all: routeState.page, processed: 1, - multimodal_processed: 1, + preprocessed: 1, processing: 1, pending: 1, failed: 1, @@ -357,7 +357,7 @@ export default function DocumentManager() { setPageByStatus({ all: 1, processed: 1, - 'multimodal_processed': 1, + preprocessed: 1, processing: 1, pending: 1, failed: 1, @@ -504,8 +504,8 @@ export default function DocumentManager() { const processedCount = getCountValue(statusCounts, 'PROCESSED', 'processed') || documentCounts.processed || 0; const preprocessedCount = - getCountValue(statusCounts, 'PREPROCESSED', 'preprocessed', 'multimodal_processed') || - documentCounts.multimodal_processed || + getCountValue(statusCounts, 'PREPROCESSED', 'preprocessed') || + documentCounts.preprocessed || 0; const processingCount = getCountValue(statusCounts, 'PROCESSING', 'processing') || documentCounts.processing || 0; const pendingCount = getCountValue(statusCounts, 'PENDING', 'pending') || documentCounts.pending || 0; @@ -514,7 +514,7 @@ export default function DocumentManager() { // Store previous status counts const prevStatusCounts = useRef({ processed: 0, - multimodal_processed: 0, + preprocessed: 0, processing: 0, pending: 0, failed: 0 @@ -605,7 +605,7 @@ export default function DocumentManager() { const legacyDocs: DocsStatusesResponse = { statuses: { processed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'processed'), - multimodal_processed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'multimodal_processed'), + preprocessed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'preprocessed'), processing: response.documents.filter((doc: DocStatusResponse) => doc.status === 'processing'), pending: response.documents.filter((doc: DocStatusResponse) => doc.status === 'pending'), failed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'failed') @@ -995,7 +995,7 @@ export default function DocumentManager() { setPageByStatus({ all: 1, processed: 1, - multimodal_processed: 1, + preprocessed: 1, processing: 1, pending: 1, failed: 1, @@ -1042,7 +1042,7 @@ export default function DocumentManager() { const legacyDocs: DocsStatusesResponse = { statuses: { processed: response.documents.filter(doc => doc.status === 'processed'), - multimodal_processed: response.documents.filter(doc => doc.status === 'multimodal_processed'), + preprocessed: response.documents.filter(doc => doc.status === 'preprocessed'), processing: response.documents.filter(doc => doc.status === 'processing'), pending: response.documents.filter(doc => doc.status === 'pending'), failed: response.documents.filter(doc => doc.status === 'failed') @@ -1121,7 +1121,7 @@ export default function DocumentManager() { // Get new status counts const newStatusCounts = { processed: docs?.statuses?.processed?.length || 0, - multimodal_processed: docs?.statuses?.multimodal_processed?.length || 0, + preprocessed: docs?.statuses?.preprocessed?.length || 0, processing: docs?.statuses?.processing?.length || 0, pending: docs?.statuses?.pending?.length || 0, failed: docs?.statuses?.failed?.length || 0 @@ -1474,12 +1474,12 @@ export default function DocumentManager() {