oscerd commented on code in PR #19261:
URL: https://github.com/apache/camel/pull/19261#discussion_r2362550965


##########
components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingEndpoint.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.docling;
+
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * Process documents using Docling library for parsing and conversion.
+ */
+@UriEndpoint(firstVersion = "4.15.0", scheme = "docling",
+             title = "Docling",
+             syntax = "docling:operationId",
+             category = { Category.AI }, headersClass = DoclingHeaders.class)

Review Comment:
   No, it's not, but it's also AI, maybe we could stress this in the doc.



##########
components/camel-ai/camel-docling/src/main/docs/docling-component.adoc:
##########
@@ -0,0 +1,216 @@
+= Docling Component
+:doctitle: Docling
+:shortname: docling
+:artifactid: camel-docling
+:description: Process documents using Docling library for parsing and 
conversion.
+:since: 4.15
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Both producer and consumer are supported
+//Manually maintained attributes
+:group: AI
+:camel-spring-boot-name: docling
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Docling component allows you to convert and process documents using 
https://github.com/DS4SD/docling[IBM's Docling AI document parser].
+Docling is a powerful Python library that can parse and convert various 
document formats including PDF, Word documents, PowerPoint presentations, and 
more into structured formats like Markdown, HTML, JSON, or plain text.
+
+Maven users will need to add the following dependency to their `pom.xml` for 
this component:
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-docling</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+----
+
+== Prerequisites
+
+Before using this component, you need to have Docling installed on your 
system. You can install it using pip:
+
+[source,bash]
+----
+pip install docling
+----
+
+== URI format
+
+----
+docling:operation[?options]
+----
+
+Where `operation` represents the document processing operation to perform.
+
+=== Supported Operations
+
+The component supports the following operations:
+
+[width="100%",cols="2,4",options="header"]
+|===
+| Operation | Description
+
+| `CONVERT_TO_MARKDOWN`
+| Convert document to Markdown format (default)
+
+| `CONVERT_TO_HTML`
+| Convert document to HTML format
+
+| `CONVERT_TO_JSON`
+| Convert document to JSON format with structure information
+
+| `EXTRACT_TEXT`
+| Extract plain text content from document
+
+| `EXTRACT_STRUCTURED_DATA`
+| Extract structured data including tables and layout information
+
+|===
+
+// component-configure options: START
+
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+
+// endpoint options: END
+
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
+
+== Usage
+
+=== Input Types
+
+The component accepts the following input types in the message body:
+
+- `String` - File path or document content
+- `byte[]` - Binary document content
+- `File` - File object
+- `InputStream` - Input stream containing document data
+
+=== Output Behavior
+
+The component behavior depends on the `contentInBody` configuration option:
+
+- When `contentInBody=true` (default: false): The converted content is placed 
in the exchange body and the output file is automatically deleted
+- When `contentInBody=false`: The file path to the generated output file is 
returned in the exchange body
+
+== Examples
+
+=== Basic document conversion to Markdown
+
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+    .to("docling:CONVERT_TO_MARKDOWN")
+    .to("file:///data/output");
+----
+
+=== Convert to HTML with content in body
+
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+    .to("docling:CONVERT_TO_HTML?contentInBody=true")
+    .process(exchange -> {
+        String htmlContent = exchange.getIn().getBody(String.class);
+        // Process the HTML content
+    });
+----
+
+=== Extract structured data from documents
+
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+    .to("docling:EXTRACT_STRUCTURED_DATA?outputFormat=json&contentInBody=true")
+    .process(exchange -> {
+        String jsonData = exchange.getIn().getBody(String.class);
+        // Process the structured JSON data
+    });
+----
+
+=== Convert with OCR disabled
+
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+    .to("docling:CONVERT_TO_MARKDOWN?enableOCR=false")
+    .to("file:///data/output");
+----
+
+=== Using headers to control processing
+
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+    .setHeader("CamelDoclingOperation", 
constant(DoclingOperations.CONVERT_TO_HTML))
+    .setHeader("CamelDoclingEnableOCR", constant(true))
+    .setHeader("CamelDoclingOCRLanguage", constant("es"))
+    .to("docling:CONVERT_TO_MARKDOWN")  // Operation will be overridden by 
header
+    .to("file:///data/output");
+----
+
+=== Processing with custom arguments
+
+[source,java]
+----
+from("file:///data/documents?include=.*\\.pdf")
+    .process(exchange -> {
+        List<String> customArgs = Arrays.asList("--verbose", 
"--preserve-tables");
+        exchange.getIn().setHeader("CamelDoclingCustomArguments", customArgs);
+    })
+    .to("docling:CONVERT_TO_MARKDOWN")
+    .to("file:///data/output");
+----
+
+=== Content in body vs file path output
+
+[source,java]
+----
+// Get content directly in body (file is automatically deleted)
+from("file:///data/documents?include=.*\\.pdf")
+    .to("docling:CONVERT_TO_MARKDOWN?contentInBody=true")
+    .process(exchange -> {
+        String markdownContent = exchange.getIn().getBody(String.class);
+        log.info("Converted content: {}", markdownContent);
+    });
+
+// Get file path (file is preserved)
+from("file:///data/documents?include=.*\\.pdf")
+    .to("docling:CONVERT_TO_MARKDOWN?contentInBody=false")
+    .process(exchange -> {
+        String outputFilePath = exchange.getIn().getBody(String.class);
+        log.info("Output file saved at: {}", outputFilePath);
+    });
+----

Review Comment:
   Sure.



-- 
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