feat: add metadata timestamps to document processing and update frontend compatibility
- Add metadata field to doc_status storage with Unix timestamps for processing start/end times - Update frontend API types: error -> error_msg, add track_id and metadata support - Add getTrackStatus API method for document tracking functionality - Fix frontend DocumentManager to use error_msg field for proper error display - Ensure full compatibility between backend metadata changes and frontend UI
This commit is contained in:
parent
93afa7d8a7
commit
6f958d5aee
4 changed files with 26 additions and 7 deletions
|
|
@ -369,7 +369,7 @@ class DocStatusResponse(BaseModel):
|
||||||
chunks_count: Optional[int] = Field(
|
chunks_count: Optional[int] = Field(
|
||||||
default=None, description="Number of chunks the document was split into"
|
default=None, description="Number of chunks the document was split into"
|
||||||
)
|
)
|
||||||
error: Optional[str] = Field(
|
error_msg: Optional[str] = Field(
|
||||||
default=None, description="Error message if processing failed"
|
default=None, description="Error message if processing failed"
|
||||||
)
|
)
|
||||||
metadata: Optional[dict[str, Any]] = Field(
|
metadata: Optional[dict[str, Any]] = Field(
|
||||||
|
|
@ -1570,7 +1570,7 @@ def create_document_routes(
|
||||||
updated_at=format_datetime(doc_status.updated_at),
|
updated_at=format_datetime(doc_status.updated_at),
|
||||||
track_id=doc_status.track_id,
|
track_id=doc_status.track_id,
|
||||||
chunks_count=doc_status.chunks_count,
|
chunks_count=doc_status.chunks_count,
|
||||||
error=doc_status.error,
|
error_msg=doc_status.error_msg,
|
||||||
metadata=doc_status.metadata,
|
metadata=doc_status.metadata,
|
||||||
file_path=doc_status.file_path,
|
file_path=doc_status.file_path,
|
||||||
)
|
)
|
||||||
|
|
@ -1844,7 +1844,7 @@ def create_document_routes(
|
||||||
updated_at=format_datetime(doc_status.updated_at),
|
updated_at=format_datetime(doc_status.updated_at),
|
||||||
track_id=doc_status.track_id,
|
track_id=doc_status.track_id,
|
||||||
chunks_count=doc_status.chunks_count,
|
chunks_count=doc_status.chunks_count,
|
||||||
error=doc_status.error,
|
error_msg=doc_status.error_msg,
|
||||||
metadata=doc_status.metadata,
|
metadata=doc_status.metadata,
|
||||||
file_path=doc_status.file_path,
|
file_path=doc_status.file_path,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -647,7 +647,7 @@ class DocProcessingStatus:
|
||||||
"""Number of chunks after splitting, used for processing"""
|
"""Number of chunks after splitting, used for processing"""
|
||||||
chunks_list: list[str] | None = field(default_factory=list)
|
chunks_list: list[str] | None = field(default_factory=list)
|
||||||
"""List of chunk IDs associated with this document, used for deletion"""
|
"""List of chunk IDs associated with this document, used for deletion"""
|
||||||
error: str | None = None
|
error_msg: str | None = None
|
||||||
"""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"""
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,7 @@ export type QueryResponse = {
|
||||||
export type DocActionResponse = {
|
export type DocActionResponse = {
|
||||||
status: 'success' | 'partial_success' | 'failure' | 'duplicated'
|
status: 'success' | 'partial_success' | 'failure' | 'duplicated'
|
||||||
message: string
|
message: string
|
||||||
|
track_id?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DeleteDocResponse = {
|
export type DeleteDocResponse = {
|
||||||
|
|
@ -160,8 +161,9 @@ export type DocStatusResponse = {
|
||||||
status: DocStatus
|
status: DocStatus
|
||||||
created_at: string
|
created_at: string
|
||||||
updated_at: string
|
updated_at: string
|
||||||
|
track_id?: string
|
||||||
chunks_count?: number
|
chunks_count?: number
|
||||||
error?: string
|
error_msg?: string
|
||||||
metadata?: Record<string, any>
|
metadata?: Record<string, any>
|
||||||
file_path: string
|
file_path: string
|
||||||
}
|
}
|
||||||
|
|
@ -170,6 +172,13 @@ export type DocsStatusesResponse = {
|
||||||
statuses: Record<DocStatus, DocStatusResponse[]>
|
statuses: Record<DocStatus, DocStatusResponse[]>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TrackStatusResponse = {
|
||||||
|
track_id: string
|
||||||
|
documents: DocStatusResponse[]
|
||||||
|
total_count: number
|
||||||
|
status_summary: Record<string, number>
|
||||||
|
}
|
||||||
|
|
||||||
export type AuthStatusResponse = {
|
export type AuthStatusResponse = {
|
||||||
auth_configured: boolean
|
auth_configured: boolean
|
||||||
access_token?: string
|
access_token?: string
|
||||||
|
|
@ -689,3 +698,13 @@ export const checkEntityNameExists = async (entityName: string): Promise<boolean
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the processing status of documents by tracking ID
|
||||||
|
* @param trackId The tracking ID returned from upload, text, or texts endpoints
|
||||||
|
* @returns Promise with the track status response containing documents and summary
|
||||||
|
*/
|
||||||
|
export const getTrackStatus = async (trackId: string): Promise<TrackStatusResponse> => {
|
||||||
|
const response = await axiosInstance.get(`/documents/track_status/${encodeURIComponent(trackId)}`)
|
||||||
|
return response.data
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -749,8 +749,8 @@ export default function DocumentManager() {
|
||||||
{doc.status === 'failed' && (
|
{doc.status === 'failed' && (
|
||||||
<span className="text-red-600">{t('documentPanel.documentManager.status.failed')}</span>
|
<span className="text-red-600">{t('documentPanel.documentManager.status.failed')}</span>
|
||||||
)}
|
)}
|
||||||
{doc.error && (
|
{doc.error_msg && (
|
||||||
<span className="ml-2 text-red-500" title={doc.error}>
|
<span className="ml-2 text-red-500" title={doc.error_msg}>
|
||||||
⚠️
|
⚠️
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue