docling 2.31.2__py3-none-any.whl → 2.32.0__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.
@@ -90,6 +90,7 @@ FormatToMimeType: Dict[InputFormat, List[str]] = {
90
90
  "image/tiff",
91
91
  "image/gif",
92
92
  "image/bmp",
93
+ "image/webp",
93
94
  ],
94
95
  InputFormat.PDF: ["application/pdf"],
95
96
  InputFormat.ASCIIDOC: ["text/asciidoc"],
@@ -225,6 +225,7 @@ class PictureDescriptionApiOptions(PictureDescriptionBaseOptions):
225
225
  headers: Dict[str, str] = {}
226
226
  params: Dict[str, Any] = {}
227
227
  timeout: float = 20
228
+ concurrency: int = 1
228
229
 
229
230
  prompt: str = "Describe this image in a few sentences."
230
231
  provenance: str = ""
@@ -295,6 +296,7 @@ class ApiVlmOptions(BaseVlmOptions):
295
296
  params: Dict[str, Any] = {}
296
297
  scale: float = 2.0
297
298
  timeout: float = 60
299
+ concurrency: int = 1
298
300
  response_format: ResponseFormat
299
301
 
300
302
 
@@ -56,13 +56,15 @@ class DebugSettings(BaseModel):
56
56
 
57
57
 
58
58
  class AppSettings(BaseSettings):
59
- model_config = SettingsConfigDict(env_prefix="DOCLING_", env_nested_delimiter="_")
59
+ model_config = SettingsConfigDict(
60
+ env_prefix="DOCLING_", env_nested_delimiter="_", env_nested_max_split=1
61
+ )
60
62
 
61
- perf: BatchConcurrencySettings
62
- debug: DebugSettings
63
+ perf: BatchConcurrencySettings = BatchConcurrencySettings()
64
+ debug: DebugSettings = DebugSettings()
63
65
 
64
66
  cache_dir: Path = Path.home() / ".cache" / "docling"
65
67
  artifacts_path: Optional[Path] = None
66
68
 
67
69
 
68
- settings = AppSettings(perf=BatchConcurrencySettings(), debug=DebugSettings())
70
+ settings = AppSettings()
@@ -1,4 +1,5 @@
1
1
  from collections.abc import Iterable
2
+ from concurrent.futures import ThreadPoolExecutor
2
3
 
3
4
  from docling.datamodel.base_models import Page, VlmPrediction
4
5
  from docling.datamodel.document import ConversionResult
@@ -27,6 +28,7 @@ class ApiVlmModel(BasePageModel):
27
28
  )
28
29
 
29
30
  self.timeout = self.vlm_options.timeout
31
+ self.concurrency = self.vlm_options.concurrency
30
32
  self.prompt_content = (
31
33
  f"This is a page from a document.\n{self.vlm_options.prompt}"
32
34
  )
@@ -38,10 +40,10 @@ class ApiVlmModel(BasePageModel):
38
40
  def __call__(
39
41
  self, conv_res: ConversionResult, page_batch: Iterable[Page]
40
42
  ) -> Iterable[Page]:
41
- for page in page_batch:
43
+ def _vlm_request(page):
42
44
  assert page._backend is not None
43
45
  if not page._backend.is_valid():
44
- yield page
46
+ return page
45
47
  else:
46
48
  with TimeRecorder(conv_res, "vlm"):
47
49
  assert page.size is not None
@@ -63,4 +65,7 @@ class ApiVlmModel(BasePageModel):
63
65
 
64
66
  page.predictions.vlm_response = VlmPrediction(text=page_tags)
65
67
 
66
- yield page
68
+ return page
69
+
70
+ with ThreadPoolExecutor(max_workers=self.concurrency) as executor:
71
+ yield from executor.map(_vlm_request, page_batch)
@@ -1,4 +1,5 @@
1
1
  from collections.abc import Iterable
2
+ from concurrent.futures import ThreadPoolExecutor
2
3
  from pathlib import Path
3
4
  from typing import Optional, Type, Union
4
5
 
@@ -37,6 +38,7 @@ class PictureDescriptionApiModel(PictureDescriptionBaseModel):
37
38
  accelerator_options=accelerator_options,
38
39
  )
39
40
  self.options: PictureDescriptionApiOptions
41
+ self.concurrency = self.options.concurrency
40
42
 
41
43
  if self.enabled:
42
44
  if not enable_remote_services:
@@ -48,8 +50,8 @@ class PictureDescriptionApiModel(PictureDescriptionBaseModel):
48
50
  def _annotate_images(self, images: Iterable[Image.Image]) -> Iterable[str]:
49
51
  # Note: technically we could make a batch request here,
50
52
  # but not all APIs will allow for it. For example, vllm won't allow more than 1.
51
- for image in images:
52
- yield api_image_request(
53
+ def _api_request(image):
54
+ return api_image_request(
53
55
  image=image,
54
56
  prompt=self.options.prompt,
55
57
  url=self.options.url,
@@ -57,3 +59,6 @@ class PictureDescriptionApiModel(PictureDescriptionBaseModel):
57
59
  headers=self.options.headers,
58
60
  **self.options.params,
59
61
  )
62
+
63
+ with ThreadPoolExecutor(max_workers=self.concurrency) as executor:
64
+ yield from executor.map(_api_request, images)
@@ -249,7 +249,7 @@ class TesseractOcrCliModel(BaseOcrModel):
249
249
  cell = TextCell(
250
250
  index=ix,
251
251
  text=str(text),
252
- orig=text,
252
+ orig=str(text),
253
253
  from_ocr=True,
254
254
  confidence=conf / 100.0,
255
255
  rect=BoundingRectangle.from_bounding_box(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: docling
3
- Version: 2.31.2
3
+ Version: 2.32.0
4
4
  Summary: SDK and CLI for parsing PDF, DOCX, HTML, and more, to a unified document representation for powering downstream workflows such as gen AI applications.
5
5
  Home-page: https://github.com/docling-project/docling
6
6
  License: MIT
@@ -28,14 +28,14 @@ docling/cli/main.py,sha256=D7WEY4x6pQCVFRy3peK9KUDOb0Y5IVc-vTDqPnHPK00,26138
28
28
  docling/cli/models.py,sha256=9yLGp6QRJGpR86U3SjmWAXDt3MvBaJLLY4xDVdsu3O8,4160
29
29
  docling/cli/tools.py,sha256=QhtRxQG0TVrfsMqdv5i7J0_qQy1ZZyWYnHPwJl7b5oY,322
30
30
  docling/datamodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- docling/datamodel/base_models.py,sha256=DRE_XoldtCreWF4ucO0iK0l8uOnfvnhQaYjV0z1Qe0M,7921
31
+ docling/datamodel/base_models.py,sha256=3BmGoV2HLXOWFuRHFAa42YnWceh-JEpcLXzfFz9AD9Y,7943
32
32
  docling/datamodel/document.py,sha256=_0Z4zUgCB5677ZW8Y7C1fv75enLZJOJUjcUkGTSiTBA,15553
33
- docling/datamodel/pipeline_options.py,sha256=-1QG8dY0RZkTJb66lXErEAnPq4F_1vgnk_5AcIr3cgU,13350
34
- docling/datamodel/settings.py,sha256=bNMdowIKv7RUchabQTo4rFNEsxfB6pGg2LoZSY634zo,1869
33
+ docling/datamodel/pipeline_options.py,sha256=uwjBvK4egrgcF1_w4B5EDxpGnl4IgBzmxP7dJ7zm394,13400
34
+ docling/datamodel/settings.py,sha256=ajMz7Ao2m0ZGYkfArqTDDbiF89O408mtgeh06PUi0MA,1900
35
35
  docling/document_converter.py,sha256=PRRr65nigQ3LZDl4G2fBMkOtJyswT7xyGt7fpUeDO3w,13849
36
36
  docling/exceptions.py,sha256=K1WnCS1leK2JtMB5ewZWKkb0EaijFgl-tRzrO9ntgPM,134
37
37
  docling/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- docling/models/api_vlm_model.py,sha256=w1SzdG3Ypz_0iZGiX-skMwV1E1JnOHH2BJiNkcEEIAA,2478
38
+ docling/models/api_vlm_model.py,sha256=TuLUR-EeUcoUkQKz5Tv6rvphhJKyQShpb99d7bVTdJE,2728
39
39
  docling/models/base_model.py,sha256=Zx_nByGYkubTvvYiQxwiB6P8lc7wOD4ZTC2QIw6vCEg,2950
40
40
  docling/models/base_ocr_model.py,sha256=_iD8QCKQdv2VWrIuSRPyGP4oCz94h84WriHg9F2k-Z0,7172
41
41
  docling/models/code_formula_model.py,sha256=9cplJFvP7jcJGz-p-MmL8_lqUhmaXZu7wKyX2aOTujs,11504
@@ -51,7 +51,7 @@ docling/models/layout_model.py,sha256=0fiJXJ4aPmcMsYY7rbN9LJ2mZ0_8G0ODY9kyNTAN3W
51
51
  docling/models/ocr_mac_model.py,sha256=A3TlEbvvwhkWiq9YARos3Y9yNcpPYQ7JGc_4hFtAK-8,5370
52
52
  docling/models/page_assemble_model.py,sha256=GO7JI1D6T6EkSW94cLQobPGNQUahkxQqTPRwj5CnmFE,6304
53
53
  docling/models/page_preprocessing_model.py,sha256=6pOGXiFQ-oz06UmJdcaYMdVyfZ0YVLWS6efGcx7Mxws,3105
54
- docling/models/picture_description_api_model.py,sha256=qs3n0smC9DXhzwJeK_iQG08Y6ZFHInKtdGPVhzgvxgU,2091
54
+ docling/models/picture_description_api_model.py,sha256=kCuAFOGEuI5QsRul7Pc1LccxWN7WIvIUhXEmSICYegw,2332
55
55
  docling/models/picture_description_base_model.py,sha256=FbBVXzAOB87xpJN28tuGCxoAdcf6mZNUOqJR7ljUg5g,2946
56
56
  docling/models/picture_description_vlm_model.py,sha256=DiTjnehVy1n0N04xPUvZl8rx4TiNHzHn9Cnzy_ePGts,4177
57
57
  docling/models/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -59,7 +59,7 @@ docling/models/plugins/defaults.py,sha256=qslXGnRX07Z3GGttNriqaox0v0vXp4zs4KLurH
59
59
  docling/models/rapid_ocr_model.py,sha256=Tq_1Egu5Hjx7Y69Vox17QTtRXztSyflB1fhN08CWQwY,5894
60
60
  docling/models/readingorder_model.py,sha256=S9ru2ApY9sE-Uue3hptWHmbmElwo36bUbAikxCFpHYs,14574
61
61
  docling/models/table_structure_model.py,sha256=1gxLaooK0IKMrnmS8nT1BItKqt1GAKghfpmLKb3i53g,12566
62
- docling/models/tesseract_ocr_cli_model.py,sha256=iFdOud5ymoW9WV8bWLCDpd3LJBo9M5bTT5vc635zEDY,10229
62
+ docling/models/tesseract_ocr_cli_model.py,sha256=LXYUCMQAPxQA2pY3zs9wcPSrAHHorTffSmIIWgltoaw,10234
63
63
  docling/models/tesseract_ocr_model.py,sha256=72009TJL_7tXTEnhlsGRiw_KibrQ0LjZlCBtW8NtwUc,9339
64
64
  docling/pipeline/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  docling/pipeline/base_pipeline.py,sha256=DnuxAf7EQusdSRae0QUVth-0f2mSff8JZjX-2vazk00,8751
@@ -79,8 +79,8 @@ docling/utils/ocr_utils.py,sha256=F7iOOjqolUcImUzir4qjDQd4QWSO3s6JC4WRn3U7uY4,26
79
79
  docling/utils/profiling.py,sha256=YaMGoB9MMZpagF9mb5ndoHj8Lpb9aIdb7El-Pl7IcFs,1753
80
80
  docling/utils/utils.py,sha256=kJtIYuzXeOyJHYlxmLAo7dGM5rEsDa1i84qEsUj1nio,1908
81
81
  docling/utils/visualization.py,sha256=tY2ylE2aiQKkmzlSLnFW-HTfFyqUUMguW18ldd1PLfo,2868
82
- docling-2.31.2.dist-info/LICENSE,sha256=mBb7ErEcM8VS9OhiGHnQ2kk75HwPhr54W1Oiz3965MY,1088
83
- docling-2.31.2.dist-info/METADATA,sha256=V11tJajepssRJ-ltuRsNThmo9_6U6Gc28wqZlgDzdz0,10138
84
- docling-2.31.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
85
- docling-2.31.2.dist-info/entry_points.txt,sha256=pIxel-UeVo1S7FhoNG5xgEfPjLZfBLi_N9TsGPtJSLo,144
86
- docling-2.31.2.dist-info/RECORD,,
82
+ docling-2.32.0.dist-info/LICENSE,sha256=mBb7ErEcM8VS9OhiGHnQ2kk75HwPhr54W1Oiz3965MY,1088
83
+ docling-2.32.0.dist-info/METADATA,sha256=Nd6x_-yL4ghk90c6Z--1nrkq6_8TpojB6K9iyDYQ2KM,10138
84
+ docling-2.32.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
85
+ docling-2.32.0.dist-info/entry_points.txt,sha256=pIxel-UeVo1S7FhoNG5xgEfPjLZfBLi_N9TsGPtJSLo,144
86
+ docling-2.32.0.dist-info/RECORD,,