apupier commented on code in PR #19676:
URL: https://github.com/apache/camel/pull/19676#discussion_r2454908438


##########
components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java:
##########
@@ -261,6 +278,164 @@ private void processCheckConversionStatus(Exchange 
exchange) throws Exception {
         }
     }
 
+    private void processBatchConversion(Exchange exchange, String 
outputFormat) throws Exception {
+        LOG.debug("DoclingProducer processing batch conversion with format: 
{}", outputFormat);
+
+        if (!configuration.isUseDoclingServe()) {
+            throw new IllegalStateException(
+                    "Batch operations require docling-serve mode 
(useDoclingServe=true)");
+        }
+
+        // Extract document list from body
+        List<String> documentPaths = extractDocumentList(exchange);
+
+        if (documentPaths.isEmpty()) {
+            throw new IllegalArgumentException("No documents provided for 
batch processing");
+        }
+
+        LOG.debug("Processing batch of {} documents", documentPaths.size());
+
+        // Get batch configuration from headers or use defaults
+        int batchSize = exchange.getIn().getHeader(DoclingHeaders.BATCH_SIZE, 
configuration.getBatchSize(), Integer.class);
+        int parallelism
+                = exchange.getIn().getHeader(DoclingHeaders.BATCH_PARALLELISM, 
configuration.getBatchParallelism(),
+                        Integer.class);
+        boolean failOnFirstError = 
exchange.getIn().getHeader(DoclingHeaders.BATCH_FAIL_ON_FIRST_ERROR,
+                configuration.isBatchFailOnFirstError(), Boolean.class);
+
+        // Check if we should use async mode for individual conversions
+        boolean useAsync = configuration.isUseAsyncMode();
+        Boolean asyncModeHeader = 
exchange.getIn().getHeader(DoclingHeaders.USE_ASYNC_MODE, Boolean.class);
+        if (asyncModeHeader != null) {
+            useAsync = asyncModeHeader;
+        }
+
+        // Process batch using DoclingServeClient
+        BatchProcessingResults results = 
doclingServeClient.convertDocumentsBatch(
+                documentPaths, outputFormat, batchSize, parallelism, 
failOnFirstError, useAsync);
+
+        // Check if we should split results into individual exchanges
+        boolean splitResults = configuration.isSplitBatchResults();
+        Boolean splitResultsHeader = 
exchange.getIn().getHeader("CamelDoclingBatchSplitResults", Boolean.class);

Review Comment:
   Why this one is not part of DoclingHeaders?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to