diff --git a/lightrag/api/routers/document_routes.py b/lightrag/api/routers/document_routes.py index 848d5eb8..9ea831d2 100644 --- a/lightrag/api/routers/document_routes.py +++ b/lightrag/api/routers/document_routes.py @@ -458,7 +458,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 e569de2a..3cf40136 100644 --- a/lightrag/base.py +++ b/lightrag/base.py @@ -720,7 +720,7 @@ class DocStatus(str, Enum): PENDING = "pending" PROCESSING = "processing" - PREPROCESSED = "multimodal_processed" + PREPROCESSED = "preprocessed" PROCESSED = "processed" FAILED = "failed" @@ -751,6 +751,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 cf9a7e7a..eac6989e 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 530e98c7..204c7daf 100644 --- a/lightrag_webui/src/features/DocumentManager.tsx +++ b/lightrag_webui/src/features/DocumentManager.tsx @@ -52,7 +52,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 @@ -257,7 +257,7 @@ export default function DocumentManager() { const [pageByStatus, setPageByStatus] = useState>({ all: 1, processed: 1, - multimodal_processed: 1, + preprocessed: 1, processing: 1, pending: 1, failed: 1, @@ -324,7 +324,7 @@ export default function DocumentManager() { setPageByStatus({ all: 1, processed: 1, - 'multimodal_processed': 1, + preprocessed: 1, processing: 1, pending: 1, failed: 1, @@ -471,8 +471,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; @@ -481,7 +481,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 @@ -572,7 +572,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') @@ -915,7 +915,7 @@ export default function DocumentManager() { setPageByStatus({ all: 1, processed: 1, - multimodal_processed: 1, + preprocessed: 1, processing: 1, pending: 1, failed: 1, @@ -956,7 +956,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') @@ -1032,7 +1032,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 @@ -1270,12 +1270,12 @@ export default function DocumentManager() {