OpenRAG 0.5.1.dev5__py3-none-any.whl → 0.5.1.dev7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
models/processors.py CHANGED
@@ -27,6 +27,15 @@ from .tasks import FileTask, TaskStatus, UploadTask
27
27
 
28
28
  logger = get_logger(__name__)
29
29
 
30
+ # Image file extensions that require OCR
31
+ IMAGE_EXTENSIONS = {"bmp", "jpeg", "jpg", "png", "tiff", "tif", "webp"}
32
+
33
+
34
+ def is_image_file(filename: str) -> bool:
35
+ """Check if a file is an image based on its extension."""
36
+ ext = filename.split(".")[-1].lower() if "." in filename else ""
37
+ return ext in IMAGE_EXTENSIONS
38
+
30
39
  if TYPE_CHECKING:
31
40
  from connectors.base import DocumentACL
32
41
 
@@ -455,6 +464,18 @@ class DocumentFileProcessor(TaskProcessor):
455
464
  file_task.updated_at = time.time()
456
465
 
457
466
  try:
467
+ # Check if OCR is disabled and file is an image
468
+ filename = os.path.basename(item)
469
+ config = get_openrag_config()
470
+ ocr_enabled = config.knowledge.ocr
471
+
472
+ if not ocr_enabled and is_image_file(filename):
473
+ file_task.status = TaskStatus.FAILED
474
+ file_task.error = f"The file '{filename}' is an image file and cannot be ingested because OCR is disabled."
475
+ file_task.updated_at = time.time()
476
+ upload_task.failed_files += 1
477
+ return
478
+
458
479
  # Compute hash
459
480
  file_hash = hash_id(item)
460
481
 
@@ -578,6 +599,17 @@ class ConnectorFileProcessor(TaskProcessor):
578
599
  file_task.updated_at = time.time()
579
600
  upload_task.failed_files += 1
580
601
  return
602
+
603
+ # Check if OCR is disabled and file is an image
604
+ config = get_openrag_config()
605
+ ocr_enabled = config.knowledge.ocr
606
+
607
+ if not ocr_enabled and is_image_file(file_task.filename):
608
+ file_task.status = TaskStatus.FAILED
609
+ file_task.error = f"The file '{file_task.filename}' is an image file and cannot be ingested because OCR is disabled."
610
+ file_task.updated_at = time.time()
611
+ upload_task.failed_files += 1
612
+ return
581
613
 
582
614
  # Get file content from connector
583
615
  try:
@@ -642,6 +674,17 @@ class ConnectorFileProcessor(TaskProcessor):
642
674
  file_task.updated_at = time.time()
643
675
  upload_task.failed_files += 1
644
676
  return
677
+
678
+ # Check if OCR is disabled and file is an image
679
+ config = get_openrag_config()
680
+ ocr_enabled = config.knowledge.ocr
681
+
682
+ if not ocr_enabled and is_image_file(name):
683
+ file_task.status = TaskStatus.FAILED
684
+ file_task.error = f"The file '{name}' is an image file and cannot be ingested because OCR is disabled."
685
+ file_task.updated_at = time.time()
686
+ upload_task.failed_files += 1
687
+ return
645
688
 
646
689
  if not self.user_id:
647
690
  raise ValueError("user_id not provided to ConnectorFileProcessor")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openrag
3
- Version: 0.5.1.dev5
3
+ Version: 0.5.1.dev7
4
4
  Summary: OpenRAG is a comprehensive Retrieval-Augmented Generation platform that enables intelligent document search and AI-powered conversations.
5
5
  Classifier: Development Status :: 4 - Beta
6
6
  Classifier: Environment :: Console
@@ -68,10 +68,10 @@ connectors/sharepoint/utils.py,sha256=OBNEbXb8uAfR-iR-ML0aOojGfGj03vJnKm9DbYf2hW
68
68
  mcp_http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  mcp_http/server.py,sha256=JutP94fQRCizeCN69kKkdYDFE71L3DqLTCcb397T8Eo,7738
70
70
  models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
- models/processors.py,sha256=1EDaMugIigfSu31Yxf54VRNrag1KXVE9Gdxl6VwFNZc,42351
71
+ models/processors.py,sha256=a5q6E33OU0TVwU-jS2D9qP6u5VdKhjNOTYhhgLVqgyk,44361
72
72
  models/tasks.py,sha256=EySl0-h2YHG0QfKDswVvO3v4tKyz_t_9e6z8IwKj61Y,1951
73
73
  models/url.py,sha256=92rsrLLyIqUErYipYz5QwUNTdHwJ2jBRV7PIVpncTyo,5764
74
- openrag-0.5.1.dev5.dist-info/licenses/LICENSE,sha256=jWcnPXkUxEinX60Yn-_zjsY9i84vz2QSb0fi53djOkg,11334
74
+ openrag-0.5.1.dev7.dist-info/licenses/LICENSE,sha256=jWcnPXkUxEinX60Yn-_zjsY9i84vz2QSb0fi53djOkg,11334
75
75
  services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  services/api_key_service.py,sha256=HFULyy47ixp38XBx-BVmCA1Wggv9v98HBTZT4XLTr8M,11923
77
77
  services/auth_service.py,sha256=nAKTvMyX-YUtiNfKF06Dq4E4iwHPBhfKR6nliqGpOSs,22090
@@ -158,8 +158,8 @@ utils/telemetry/__init__.py,sha256=xoStY8hoYWnVe0B_jNthSdzRb7AxCT0rhM8ba9Q0Obg,2
158
158
  utils/telemetry/category.py,sha256=wei3V5WyUaiadYjEE5s0ys9PY0TjnebIvTykQU0P_2k,1114
159
159
  utils/telemetry/client.py,sha256=RhjW1a27w7W6gHt9X7AxdRPdZGmCEQDPskkxj5nsuiQ,12500
160
160
  utils/telemetry/message_id.py,sha256=IAu0wBVNOGPcSlQ0bAzvqIYr1Ac_n8wSTSxXzq_tiV0,9634
161
- openrag-0.5.1.dev5.dist-info/METADATA,sha256=WoJv2AhRDbcKcjMGBhkOiy6RTB-X8WiRyIXzqEhuSOw,7818
162
- openrag-0.5.1.dev5.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
163
- openrag-0.5.1.dev5.dist-info/entry_points.txt,sha256=ArKNHB63I3K8vynNkogvZOLmmQFpIsHDL7MvreCmju4,45
164
- openrag-0.5.1.dev5.dist-info/top_level.txt,sha256=5vfLBIkzuwBJrizhCSZiXV7NTzTRIMlNLsyzYDEeCF8,125
165
- openrag-0.5.1.dev5.dist-info/RECORD,,
161
+ openrag-0.5.1.dev7.dist-info/METADATA,sha256=dzzY0WHIhAmyQRM1_Ld-X4299UB3OfFAhHcKba8kP5Y,7818
162
+ openrag-0.5.1.dev7.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
163
+ openrag-0.5.1.dev7.dist-info/entry_points.txt,sha256=ArKNHB63I3K8vynNkogvZOLmmQFpIsHDL7MvreCmju4,45
164
+ openrag-0.5.1.dev7.dist-info/top_level.txt,sha256=5vfLBIkzuwBJrizhCSZiXV7NTzTRIMlNLsyzYDEeCF8,125
165
+ openrag-0.5.1.dev7.dist-info/RECORD,,