Skip to content

Commit 06533fd

Browse files
authored
Merge pull request #2248 from danielaskdd/preprocess-rayanything
Refact: Add Multimodal Processing Status Support to DocProcessingStatus
2 parents 00aa5e5 + 8dc23ee commit 06533fd

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

lightrag/api/routers/document_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ class Config:
458458
"id": "doc_789",
459459
"content_summary": "Document pending final indexing",
460460
"content_length": 7200,
461-
"status": "multimodal_processed",
461+
"status": "preprocessed",
462462
"created_at": "2025-03-31T09:30:00",
463463
"updated_at": "2025-03-31T09:35:00",
464464
"track_id": "upload_20250331_093000_xyz789",

lightrag/base.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ class DocStatus(str, Enum):
720720

721721
PENDING = "pending"
722722
PROCESSING = "processing"
723-
PREPROCESSED = "multimodal_processed"
723+
PREPROCESSED = "preprocessed"
724724
PROCESSED = "processed"
725725
FAILED = "failed"
726726

@@ -751,6 +751,25 @@ class DocProcessingStatus:
751751
"""Error message if failed"""
752752
metadata: dict[str, Any] = field(default_factory=dict)
753753
"""Additional metadata"""
754+
multimodal_processed: bool | None = field(default=None, repr=False)
755+
"""Internal field: indicates if multimodal processing is complete. Not shown in repr() but accessible for debugging."""
756+
757+
def __post_init__(self):
758+
"""
759+
Handle status conversion based on multimodal_processed field.
760+
761+
Business rules:
762+
- If multimodal_processed is False and status is PROCESSED,
763+
then change status to PREPROCESSED
764+
- The multimodal_processed field is kept (with repr=False) for internal use and debugging
765+
"""
766+
# Apply status conversion logic
767+
if self.multimodal_processed is not None:
768+
if (
769+
self.multimodal_processed is False
770+
and self.status == DocStatus.PROCESSED
771+
):
772+
self.status = DocStatus.PREPROCESSED
754773

755774

756775
@dataclass

lightrag_webui/src/api/lightrag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export type DeleteDocResponse = {
167167
doc_id: string
168168
}
169169

170-
export type DocStatus = 'pending' | 'processing' | 'multimodal_processed' | 'processed' | 'failed'
170+
export type DocStatus = 'pending' | 'processing' | 'preprocessed' | 'processed' | 'failed'
171171

172172
export type DocStatusResponse = {
173173
id: string

lightrag_webui/src/features/DocumentManager.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const getCountValue = (counts: Record<string, number>, ...keys: string[]): numbe
5252
const hasActiveDocumentsStatus = (counts: Record<string, number>): boolean =>
5353
getCountValue(counts, 'PROCESSING', 'processing') > 0 ||
5454
getCountValue(counts, 'PENDING', 'pending') > 0 ||
55-
getCountValue(counts, 'PREPROCESSED', 'preprocessed', 'multimodal_processed') > 0
55+
getCountValue(counts, 'PREPROCESSED', 'preprocessed') > 0
5656

5757
const getDisplayFileName = (doc: DocStatusResponse, maxLength: number = 20): string => {
5858
// Check if file_path exists and is a non-empty string
@@ -257,7 +257,7 @@ export default function DocumentManager() {
257257
const [pageByStatus, setPageByStatus] = useState<Record<StatusFilter, number>>({
258258
all: 1,
259259
processed: 1,
260-
multimodal_processed: 1,
260+
preprocessed: 1,
261261
processing: 1,
262262
pending: 1,
263263
failed: 1,
@@ -324,7 +324,7 @@ export default function DocumentManager() {
324324
setPageByStatus({
325325
all: 1,
326326
processed: 1,
327-
'multimodal_processed': 1,
327+
preprocessed: 1,
328328
processing: 1,
329329
pending: 1,
330330
failed: 1,
@@ -471,8 +471,8 @@ export default function DocumentManager() {
471471

472472
const processedCount = getCountValue(statusCounts, 'PROCESSED', 'processed') || documentCounts.processed || 0;
473473
const preprocessedCount =
474-
getCountValue(statusCounts, 'PREPROCESSED', 'preprocessed', 'multimodal_processed') ||
475-
documentCounts.multimodal_processed ||
474+
getCountValue(statusCounts, 'PREPROCESSED', 'preprocessed') ||
475+
documentCounts.preprocessed ||
476476
0;
477477
const processingCount = getCountValue(statusCounts, 'PROCESSING', 'processing') || documentCounts.processing || 0;
478478
const pendingCount = getCountValue(statusCounts, 'PENDING', 'pending') || documentCounts.pending || 0;
@@ -481,7 +481,7 @@ export default function DocumentManager() {
481481
// Store previous status counts
482482
const prevStatusCounts = useRef({
483483
processed: 0,
484-
multimodal_processed: 0,
484+
preprocessed: 0,
485485
processing: 0,
486486
pending: 0,
487487
failed: 0
@@ -572,7 +572,7 @@ export default function DocumentManager() {
572572
const legacyDocs: DocsStatusesResponse = {
573573
statuses: {
574574
processed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'processed'),
575-
multimodal_processed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'multimodal_processed'),
575+
preprocessed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'preprocessed'),
576576
processing: response.documents.filter((doc: DocStatusResponse) => doc.status === 'processing'),
577577
pending: response.documents.filter((doc: DocStatusResponse) => doc.status === 'pending'),
578578
failed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'failed')
@@ -915,7 +915,7 @@ export default function DocumentManager() {
915915
setPageByStatus({
916916
all: 1,
917917
processed: 1,
918-
multimodal_processed: 1,
918+
preprocessed: 1,
919919
processing: 1,
920920
pending: 1,
921921
failed: 1,
@@ -956,7 +956,7 @@ export default function DocumentManager() {
956956
const legacyDocs: DocsStatusesResponse = {
957957
statuses: {
958958
processed: response.documents.filter(doc => doc.status === 'processed'),
959-
multimodal_processed: response.documents.filter(doc => doc.status === 'multimodal_processed'),
959+
preprocessed: response.documents.filter(doc => doc.status === 'preprocessed'),
960960
processing: response.documents.filter(doc => doc.status === 'processing'),
961961
pending: response.documents.filter(doc => doc.status === 'pending'),
962962
failed: response.documents.filter(doc => doc.status === 'failed')
@@ -1032,7 +1032,7 @@ export default function DocumentManager() {
10321032
// Get new status counts
10331033
const newStatusCounts = {
10341034
processed: docs?.statuses?.processed?.length || 0,
1035-
multimodal_processed: docs?.statuses?.multimodal_processed?.length || 0,
1035+
preprocessed: docs?.statuses?.preprocessed?.length || 0,
10361036
processing: docs?.statuses?.processing?.length || 0,
10371037
pending: docs?.statuses?.pending?.length || 0,
10381038
failed: docs?.statuses?.failed?.length || 0
@@ -1270,12 +1270,12 @@ export default function DocumentManager() {
12701270
</Button>
12711271
<Button
12721272
size="sm"
1273-
variant={statusFilter === 'multimodal_processed' ? 'secondary' : 'outline'}
1274-
onClick={() => handleStatusFilterChange('multimodal_processed')}
1273+
variant={statusFilter === 'preprocessed' ? 'secondary' : 'outline'}
1274+
onClick={() => handleStatusFilterChange('preprocessed')}
12751275
disabled={isRefreshing}
12761276
className={cn(
12771277
preprocessedCount > 0 ? 'text-purple-600' : 'text-gray-500',
1278-
statusFilter === 'multimodal_processed' && 'bg-purple-100 dark:bg-purple-900/30 font-medium border border-purple-400 dark:border-purple-600 shadow-sm'
1278+
statusFilter === 'preprocessed' && 'bg-purple-100 dark:bg-purple-900/30 font-medium border border-purple-400 dark:border-purple-600 shadow-sm'
12791279
)}
12801280
>
12811281
{t('documentPanel.documentManager.status.preprocessed')} ({preprocessedCount})
@@ -1460,7 +1460,7 @@ export default function DocumentManager() {
14601460
{doc.status === 'processed' && (
14611461
<span className="text-green-600">{t('documentPanel.documentManager.status.completed')}</span>
14621462
)}
1463-
{doc.status === 'multimodal_processed' && (
1463+
{doc.status === 'preprocessed' && (
14641464
<span className="text-purple-600">{t('documentPanel.documentManager.status.preprocessed')}</span>
14651465
)}
14661466
{doc.status === 'processing' && (

0 commit comments

Comments
 (0)