Skip to content

Commit 4eb7532

Browse files
dependabot[bot]apupier
authored andcommitted
chore(deps): Bump ai.docling:docling-serve-client from 0.4.7 to 0.5.0
Bumps [ai.docling:docling-serve-client](https://github.com/docling-project/docling-java) from 0.4.7 to 0.5.0. - [Release notes](https://github.com/docling-project/docling-java/releases) - [Commits](docling-project/docling-java@v0.4.7...v0.5.0) --- updated-dependencies: - dependency-name: ai.docling:docling-serve-client dependency-version: 0.5.0 dependency-type: direct:production update-type: version-update:semver-minor ... Adapt to API Break. Currently support only the transfer of Document when converting only in Body as it was before. An improvement would be to leverage the new API to use streaming or even an url to retrieve the content later/in async. Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Aurélien Pupier <apupier@ibm.com>
1 parent aed48e7 commit 4eb7532

3 files changed

Lines changed: 48 additions & 37 deletions

File tree

components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import ai.docling.serve.api.convert.request.source.HttpSource;
7171
import ai.docling.serve.api.convert.response.ConvertDocumentResponse;
7272
import ai.docling.serve.api.convert.response.DocumentResponse;
73+
import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse;
7374
import ai.docling.serve.api.task.request.TaskStatusPollRequest;
7475
import ai.docling.serve.api.task.response.TaskStatus;
7576
import ai.docling.serve.api.task.response.TaskStatusPollResponse;
@@ -1124,15 +1125,19 @@ private DoclingDocument convertToDoclingDocument(
11241125
}
11251126

11261127
private DoclingDocument extractDoclingDocument(ConvertDocumentResponse response) throws IOException {
1127-
DocumentResponse document = response.getDocument();
1128-
if (document == null) {
1129-
throw new IOException("No document in response");
1130-
}
1131-
DoclingDocument result = document.getJsonContent();
1132-
if (result == null) {
1133-
throw new IOException("No JSON content in document response");
1128+
if (response instanceof InBodyConvertDocumentResponse inBodyConvertDocumentResponse) {
1129+
DocumentResponse document = inBodyConvertDocumentResponse.getDocument();
1130+
if (document == null) {
1131+
throw new IOException("No document in response");
1132+
}
1133+
DoclingDocument result = document.getJsonContent();
1134+
if (result == null) {
1135+
throw new IOException("No JSON content in document response");
1136+
}
1137+
return result;
1138+
} else {
1139+
throw new IOException("Unsupported type of response. Cannot extract a DoclingDocument");
11341140
}
1135-
return result;
11361141
}
11371142

11381143
private void processBatchStructuredData(Exchange exchange) throws Exception {
@@ -1555,40 +1560,45 @@ private void applyConfigurationToOptions(ConvertDocumentOptions.Builder optionsB
15551560

15561561
private String extractConvertedContent(ConvertDocumentResponse response, String outputFormat) throws IOException {
15571562
try {
1558-
DocumentResponse document = response.getDocument();
1563+
if (response instanceof InBodyConvertDocumentResponse inBodyConvertDocumentResponse) {
1564+
DocumentResponse document = inBodyConvertDocumentResponse.getDocument();
15591565

1560-
if (document == null) {
1561-
throw new IOException("No document in response");
1562-
}
1566+
if (document == null) {
1567+
throw new IOException("No document in response");
1568+
}
15631569

1564-
String format = mapOutputFormat(outputFormat);
1565-
1566-
switch (format) {
1567-
case "md":
1568-
String markdown = document.getMarkdownContent();
1569-
return markdown != null ? markdown : "";
1570-
case "html":
1571-
String html = document.getHtmlContent();
1572-
return html != null ? html : "";
1573-
case "text":
1574-
String text = document.getTextContent();
1575-
return text != null ? text : "";
1576-
case "json":
1577-
// Return the document JSON content
1578-
var jsonDoc = document.getJsonContent();
1579-
if (jsonDoc != null) {
1580-
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonDoc);
1581-
}
1582-
return "{}";
1583-
default:
1584-
// Default to markdown
1585-
String defaultMarkdown = document.getMarkdownContent();
1586-
return defaultMarkdown != null ? defaultMarkdown : "";
1570+
String format = mapOutputFormat(outputFormat);
1571+
1572+
switch (format) {
1573+
case "md":
1574+
String markdown = document.getMarkdownContent();
1575+
return markdown != null ? markdown : "";
1576+
case "html":
1577+
String html = document.getHtmlContent();
1578+
return html != null ? html : "";
1579+
case "text":
1580+
String text = document.getTextContent();
1581+
return text != null ? text : "";
1582+
case "json":
1583+
// Return the document JSON content
1584+
var jsonDoc = document.getJsonContent();
1585+
if (jsonDoc != null) {
1586+
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonDoc);
1587+
}
1588+
return "{}";
1589+
default:
1590+
// Default to markdown
1591+
String defaultMarkdown = document.getMarkdownContent();
1592+
return defaultMarkdown != null ? defaultMarkdown : "";
1593+
}
1594+
} else {
1595+
throw new IOException("Unsupported type of response. Cannot extract a DoclingDocument");
15871596
}
15881597
} catch (Exception e) {
15891598
LOG.warn("Failed to extract content from response: {}", e.getMessage());
15901599
throw new IOException("Failed to extract content from response", e);
15911600
}
1601+
15921602
}
15931603

15941604
private OutputFormat mapToOutputFormat(String outputFormat) {

components/camel-ai/camel-docling/src/test/java/org/apache/camel/component/docling/DoclingAsyncConversionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import ai.docling.serve.api.convert.response.ConvertDocumentResponse;
2424
import ai.docling.serve.api.convert.response.DocumentResponse;
25+
import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse;
2526
import org.apache.camel.CamelExecutionException;
2627
import org.apache.camel.Exchange;
2728
import org.apache.camel.builder.RouteBuilder;
@@ -94,7 +95,7 @@ void checkStatusReturnsCompletedForFinishedLocalTask() throws Exception {
9495
Map<String, CompletableFuture<ConvertDocumentResponse>> pendingTasks = getPendingAsyncTasks(producer);
9596

9697
// Create a completed future with a mock response
97-
ConvertDocumentResponse mockResponse = ConvertDocumentResponse.builder()
98+
ConvertDocumentResponse mockResponse = InBodyConvertDocumentResponse.builder()
9899
.document(DocumentResponse.builder()
99100
.markdownContent("# Converted Document")
100101
.build())

parent/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
<dnsjava-version>3.6.4</dnsjava-version>
156156
<djl-version>0.36.0</djl-version>
157157
<djl-python-version>0.34.0</djl-python-version>
158-
<docling-java-version>0.4.7</docling-java-version>
158+
<docling-java-version>0.5.0</docling-java-version>
159159
<docker-java-version>3.7.0</docker-java-version>
160160
<dropbox-version>7.0.0</dropbox-version>
161161
<eddsa-version>0.3.0</eddsa-version>

0 commit comments

Comments
 (0)