Fix RayAnything compatible problem
• Use "preprocessed" to indicate multimodal processing is required • Update DocProcessingStatus to process status convertion automatically • Remove multimodal_processed from DocStatus enum value • Update UI filter logic
This commit is contained in:
parent
00aa5e53a7
commit
8dc23eeff2
4 changed files with 36 additions and 17 deletions
|
|
@ -458,7 +458,7 @@ class DocsStatusesResponse(BaseModel):
|
||||||
"id": "doc_789",
|
"id": "doc_789",
|
||||||
"content_summary": "Document pending final indexing",
|
"content_summary": "Document pending final indexing",
|
||||||
"content_length": 7200,
|
"content_length": 7200,
|
||||||
"status": "multimodal_processed",
|
"status": "preprocessed",
|
||||||
"created_at": "2025-03-31T09:30:00",
|
"created_at": "2025-03-31T09:30:00",
|
||||||
"updated_at": "2025-03-31T09:35:00",
|
"updated_at": "2025-03-31T09:35:00",
|
||||||
"track_id": "upload_20250331_093000_xyz789",
|
"track_id": "upload_20250331_093000_xyz789",
|
||||||
|
|
|
||||||
|
|
@ -720,7 +720,7 @@ class DocStatus(str, Enum):
|
||||||
|
|
||||||
PENDING = "pending"
|
PENDING = "pending"
|
||||||
PROCESSING = "processing"
|
PROCESSING = "processing"
|
||||||
PREPROCESSED = "multimodal_processed"
|
PREPROCESSED = "preprocessed"
|
||||||
PROCESSED = "processed"
|
PROCESSED = "processed"
|
||||||
FAILED = "failed"
|
FAILED = "failed"
|
||||||
|
|
||||||
|
|
@ -751,6 +751,25 @@ class DocProcessingStatus:
|
||||||
"""Error message if failed"""
|
"""Error message if failed"""
|
||||||
metadata: dict[str, Any] = field(default_factory=dict)
|
metadata: dict[str, Any] = field(default_factory=dict)
|
||||||
"""Additional metadata"""
|
"""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
|
@dataclass
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ export type DeleteDocResponse = {
|
||||||
doc_id: string
|
doc_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DocStatus = 'pending' | 'processing' | 'multimodal_processed' | 'processed' | 'failed'
|
export type DocStatus = 'pending' | 'processing' | 'preprocessed' | 'processed' | 'failed'
|
||||||
|
|
||||||
export type DocStatusResponse = {
|
export type DocStatusResponse = {
|
||||||
id: string
|
id: string
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ const getCountValue = (counts: Record<string, number>, ...keys: string[]): numbe
|
||||||
const hasActiveDocumentsStatus = (counts: Record<string, number>): boolean =>
|
const hasActiveDocumentsStatus = (counts: Record<string, number>): boolean =>
|
||||||
getCountValue(counts, 'PROCESSING', 'processing') > 0 ||
|
getCountValue(counts, 'PROCESSING', 'processing') > 0 ||
|
||||||
getCountValue(counts, 'PENDING', 'pending') > 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 => {
|
const getDisplayFileName = (doc: DocStatusResponse, maxLength: number = 20): string => {
|
||||||
// Check if file_path exists and is a non-empty string
|
// Check if file_path exists and is a non-empty string
|
||||||
|
|
@ -257,7 +257,7 @@ export default function DocumentManager() {
|
||||||
const [pageByStatus, setPageByStatus] = useState<Record<StatusFilter, number>>({
|
const [pageByStatus, setPageByStatus] = useState<Record<StatusFilter, number>>({
|
||||||
all: 1,
|
all: 1,
|
||||||
processed: 1,
|
processed: 1,
|
||||||
multimodal_processed: 1,
|
preprocessed: 1,
|
||||||
processing: 1,
|
processing: 1,
|
||||||
pending: 1,
|
pending: 1,
|
||||||
failed: 1,
|
failed: 1,
|
||||||
|
|
@ -324,7 +324,7 @@ export default function DocumentManager() {
|
||||||
setPageByStatus({
|
setPageByStatus({
|
||||||
all: 1,
|
all: 1,
|
||||||
processed: 1,
|
processed: 1,
|
||||||
'multimodal_processed': 1,
|
preprocessed: 1,
|
||||||
processing: 1,
|
processing: 1,
|
||||||
pending: 1,
|
pending: 1,
|
||||||
failed: 1,
|
failed: 1,
|
||||||
|
|
@ -471,8 +471,8 @@ export default function DocumentManager() {
|
||||||
|
|
||||||
const processedCount = getCountValue(statusCounts, 'PROCESSED', 'processed') || documentCounts.processed || 0;
|
const processedCount = getCountValue(statusCounts, 'PROCESSED', 'processed') || documentCounts.processed || 0;
|
||||||
const preprocessedCount =
|
const preprocessedCount =
|
||||||
getCountValue(statusCounts, 'PREPROCESSED', 'preprocessed', 'multimodal_processed') ||
|
getCountValue(statusCounts, 'PREPROCESSED', 'preprocessed') ||
|
||||||
documentCounts.multimodal_processed ||
|
documentCounts.preprocessed ||
|
||||||
0;
|
0;
|
||||||
const processingCount = getCountValue(statusCounts, 'PROCESSING', 'processing') || documentCounts.processing || 0;
|
const processingCount = getCountValue(statusCounts, 'PROCESSING', 'processing') || documentCounts.processing || 0;
|
||||||
const pendingCount = getCountValue(statusCounts, 'PENDING', 'pending') || documentCounts.pending || 0;
|
const pendingCount = getCountValue(statusCounts, 'PENDING', 'pending') || documentCounts.pending || 0;
|
||||||
|
|
@ -481,7 +481,7 @@ export default function DocumentManager() {
|
||||||
// Store previous status counts
|
// Store previous status counts
|
||||||
const prevStatusCounts = useRef({
|
const prevStatusCounts = useRef({
|
||||||
processed: 0,
|
processed: 0,
|
||||||
multimodal_processed: 0,
|
preprocessed: 0,
|
||||||
processing: 0,
|
processing: 0,
|
||||||
pending: 0,
|
pending: 0,
|
||||||
failed: 0
|
failed: 0
|
||||||
|
|
@ -572,7 +572,7 @@ export default function DocumentManager() {
|
||||||
const legacyDocs: DocsStatusesResponse = {
|
const legacyDocs: DocsStatusesResponse = {
|
||||||
statuses: {
|
statuses: {
|
||||||
processed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'processed'),
|
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'),
|
processing: response.documents.filter((doc: DocStatusResponse) => doc.status === 'processing'),
|
||||||
pending: response.documents.filter((doc: DocStatusResponse) => doc.status === 'pending'),
|
pending: response.documents.filter((doc: DocStatusResponse) => doc.status === 'pending'),
|
||||||
failed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'failed')
|
failed: response.documents.filter((doc: DocStatusResponse) => doc.status === 'failed')
|
||||||
|
|
@ -915,7 +915,7 @@ export default function DocumentManager() {
|
||||||
setPageByStatus({
|
setPageByStatus({
|
||||||
all: 1,
|
all: 1,
|
||||||
processed: 1,
|
processed: 1,
|
||||||
multimodal_processed: 1,
|
preprocessed: 1,
|
||||||
processing: 1,
|
processing: 1,
|
||||||
pending: 1,
|
pending: 1,
|
||||||
failed: 1,
|
failed: 1,
|
||||||
|
|
@ -956,7 +956,7 @@ export default function DocumentManager() {
|
||||||
const legacyDocs: DocsStatusesResponse = {
|
const legacyDocs: DocsStatusesResponse = {
|
||||||
statuses: {
|
statuses: {
|
||||||
processed: response.documents.filter(doc => doc.status === 'processed'),
|
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'),
|
processing: response.documents.filter(doc => doc.status === 'processing'),
|
||||||
pending: response.documents.filter(doc => doc.status === 'pending'),
|
pending: response.documents.filter(doc => doc.status === 'pending'),
|
||||||
failed: response.documents.filter(doc => doc.status === 'failed')
|
failed: response.documents.filter(doc => doc.status === 'failed')
|
||||||
|
|
@ -1032,7 +1032,7 @@ export default function DocumentManager() {
|
||||||
// Get new status counts
|
// Get new status counts
|
||||||
const newStatusCounts = {
|
const newStatusCounts = {
|
||||||
processed: docs?.statuses?.processed?.length || 0,
|
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,
|
processing: docs?.statuses?.processing?.length || 0,
|
||||||
pending: docs?.statuses?.pending?.length || 0,
|
pending: docs?.statuses?.pending?.length || 0,
|
||||||
failed: docs?.statuses?.failed?.length || 0
|
failed: docs?.statuses?.failed?.length || 0
|
||||||
|
|
@ -1270,12 +1270,12 @@ export default function DocumentManager() {
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant={statusFilter === 'multimodal_processed' ? 'secondary' : 'outline'}
|
variant={statusFilter === 'preprocessed' ? 'secondary' : 'outline'}
|
||||||
onClick={() => handleStatusFilterChange('multimodal_processed')}
|
onClick={() => handleStatusFilterChange('preprocessed')}
|
||||||
disabled={isRefreshing}
|
disabled={isRefreshing}
|
||||||
className={cn(
|
className={cn(
|
||||||
preprocessedCount > 0 ? 'text-purple-600' : 'text-gray-500',
|
preprocessedCount > 0 ? 'text-purple-600' : 'text-gray-500',
|
||||||
statusFilter === 'multimodal_processed' && 'bg-purple-100 dark:bg-purple-900/30 font-medium border border-purple-400 dark:border-purple-600 shadow-sm'
|
statusFilter === 'preprocessed' && 'bg-purple-100 dark:bg-purple-900/30 font-medium border border-purple-400 dark:border-purple-600 shadow-sm'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{t('documentPanel.documentManager.status.preprocessed')} ({preprocessedCount})
|
{t('documentPanel.documentManager.status.preprocessed')} ({preprocessedCount})
|
||||||
|
|
@ -1460,7 +1460,7 @@ export default function DocumentManager() {
|
||||||
{doc.status === 'processed' && (
|
{doc.status === 'processed' && (
|
||||||
<span className="text-green-600">{t('documentPanel.documentManager.status.completed')}</span>
|
<span className="text-green-600">{t('documentPanel.documentManager.status.completed')}</span>
|
||||||
)}
|
)}
|
||||||
{doc.status === 'multimodal_processed' && (
|
{doc.status === 'preprocessed' && (
|
||||||
<span className="text-purple-600">{t('documentPanel.documentManager.status.preprocessed')}</span>
|
<span className="text-purple-600">{t('documentPanel.documentManager.status.preprocessed')}</span>
|
||||||
)}
|
)}
|
||||||
{doc.status === 'processing' && (
|
{doc.status === 'processing' && (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue