sofhiaazzhr commited on
Commit
0000030
·
1 Parent(s): cd06c0f

[KM-556] wire document process endpoint to on_tabular_uploaded[KM-556] wire document process endpoint to on_tabular_uploaded

Browse files
Files changed (1) hide show
  1. src/api/v1/document.py +11 -2
src/api/v1/document.py CHANGED
@@ -6,7 +6,7 @@ from src.db.postgres.connection import get_db
6
  from src.document.document_service import document_service
7
  from src.middlewares.logging import get_logger, log_execution
8
  from src.middlewares.rate_limit import limiter
9
- from src.pipeline.document_pipeline.document_pipeline import document_pipeline
10
  from pydantic import BaseModel
11
  from typing import List
12
 
@@ -24,7 +24,7 @@ class DocumentResponse(BaseModel):
24
  created_at: str
25
 
26
 
27
- # NOTE: Keep in sync with SUPPORTED_FILE_TYPES in src/pipeline/document_pipeline/document_pipeline.py
28
  _DOC_TYPES = [
29
  {"doc_type": "pdf", "max_size": 10, "status": "active", "message": None},
30
  {"doc_type": "docx", "max_size": 10, "status": "active", "message": None},
@@ -104,5 +104,14 @@ async def process_document(
104
  ):
105
  """Process document and ingest to vector index."""
106
  data = await document_pipeline.process(document_id, user_id, db)
 
 
 
 
 
 
 
 
 
107
  return {"status": "success", "message": "Document processed successfully", "data": data}
108
 
 
6
  from src.document.document_service import document_service
7
  from src.middlewares.logging import get_logger, log_execution
8
  from src.middlewares.rate_limit import limiter
9
+ from src.pipeline.document_pipeline import document_pipeline
10
  from pydantic import BaseModel
11
  from typing import List
12
 
 
24
  created_at: str
25
 
26
 
27
+ # NOTE: Keep in sync with SUPPORTED_FILE_TYPES in src/pipeline/document_pipeline.py
28
  _DOC_TYPES = [
29
  {"doc_type": "pdf", "max_size": 10, "status": "active", "message": None},
30
  {"doc_type": "docx", "max_size": 10, "status": "active", "message": None},
 
104
  ):
105
  """Process document and ingest to vector index."""
106
  data = await document_pipeline.process(document_id, user_id, db)
107
+
108
+ document = await document_service.get_document(db, document_id)
109
+ if document and document.file_type in ("csv", "xlsx"):
110
+ from src.pipeline.triggers import on_tabular_uploaded
111
+ try:
112
+ await on_tabular_uploaded(document_id, user_id)
113
+ except Exception as e:
114
+ logger.error("catalog ingestion failed after process", document_id=document_id, error=str(e))
115
+
116
  return {"status": "success", "message": "Document processed successfully", "data": data}
117