From d6879fac5937a597fcb3a28e012b97a557e3771f Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Tue, 1 Dec 2026 15:07:20 -0500 Subject: [PATCH 1/3] feat(api): support convert-side chunking ConvertDocumentsOptions exposes chunking_preset and chunking_options, letting the convert endpoints chunk a document in the same pass that converts it, instead of converting and then sending the result back to /chunk. Mapping these two request properties alone would be inert, so this change lands them together with the two other pieces needed to make the feature usable: * OutputFormat.CHUNKS, the trigger the server requires in to_formats to activate chunking, appended at the end of the enum to preserve the ordinal position of the existing constants. * A new ChunkedConvertDocumentResponse (ResponseType.CHUNKED) for the in-body shape, reusing the chunk API's Chunk and Document types since the server's ChunkedDocumentResult is structurally identical. The Jackson 2/3 convert response deserializers now check for "chunks" before "documents", since a chunked response also carries a "documents" field and would otherwise be misrouted to PreSignedUrlConvertResponse. * ArtifactType.CHUNKS, so the presigned-target path (where the chunks file comes back as a "chunks" artifact) deserializes instead of throwing on an unrecognized enum constant. Related to #821, #822. Assisted-By: Claude Code Signed-off-by: Eric Deandrea --- .../options/ConvertDocumentOptions.java | 17 ++++ .../convert/request/options/OutputFormat.java | 16 ++-- .../api/convert/response/ArtifactType.java | 33 ++++--- .../ChunkedConvertDocumentResponse.java | 91 +++++++++++++++++++ .../response/ConvertDocumentResponse.java | 4 +- .../api/convert/response/ResponseType.java | 35 ++++--- ...n2ConvertDocumentResponseDeserializer.java | 25 +++-- ...n3ConvertDocumentResponseDeserializer.java | 22 +++-- .../options/ConvertDocumentOptionsTests.java | 57 ++++++++++++ .../convert/response/ArtifactRefTests.java | 6 ++ .../ConvertDocumentResponseTests.java | 50 +++++++++- .../AbstractDoclingServeClientTests.java | 74 +++++++++++++++ docs/src/doc/docs/whats-new.md | 1 + 13 files changed, 376 insertions(+), 55 deletions(-) create mode 100644 docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java index 6e69600a..7776667e 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java @@ -14,6 +14,7 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import ai.docling.serve.api.chunk.request.options.ChunkerOptions; import ai.docling.serve.api.serialization.DurationSerializationFormat; import ai.docling.serve.api.serialization.Jackson2DurationSerializer; import ai.docling.serve.api.serialization.Jackson3DurationSerializer; @@ -429,6 +430,22 @@ public class ConvertDocumentOptions { @lombok.Singular("vlmPipelineCustomConfigEntry") private Map vlmPipelineCustomConfig; + /** + * Preset id for the chunker, for example {@code hybrid} or {@code hierarchical}. Mutually exclusive with {@link #getChunkingOptions()}. Only takes effect when + * {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}. + */ + @JsonProperty("chunking_preset") + @Nullable + private String chunkingPreset; + + /** + * Chunker configuration for convert-side chunking, performed in the same pass as the conversion. Mutually exclusive with {@link #getChunkingPreset()}. Only takes effect when + * {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}. + */ + @JsonProperty("chunking_options") + @Nullable + private ChunkerOptions chunkingOptions; + /** * Whether heading hierarchy inference is enabled. Derived from {@link #getHeadingHierarchyOptions()} * — {@code true} when options are present, {@code false} otherwise. diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java index b23bdfb9..32f7a2ca 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java @@ -7,27 +7,29 @@ */ public enum OutputFormat { - @JsonProperty("dclx") - DCLX, @JsonProperty("doctags") DOCTAGS, - @JsonProperty("doclang") - DOCLANG, @JsonProperty("html") HTML, @JsonProperty("html_split_page") HTML_SPLIT_PAGE, @JsonProperty("json") JSON, - @JsonProperty("latex") - LATEX, @JsonProperty("md") MARKDOWN, @JsonProperty("text") TEXT, + @JsonProperty("dclx") + DCLX, + @JsonProperty("doclang") + DOCLANG, + @JsonProperty("latex") + LATEX, @JsonProperty("vtt") VTT, @JsonProperty("yaml") - YAML + YAML, + @JsonProperty("chunks") + CHUNKS } diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ArtifactType.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ArtifactType.java index 7610d031..2977cb7f 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ArtifactType.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ArtifactType.java @@ -6,19 +6,28 @@ * Represents the output format of a converted-document artifact. * *
    - *
  • {@code JSON}: Serialized {@code DoclingDocument} JSON.
  • - *
  • {@code HTML}: HTML rendering of the document.
  • - *
  • {@code MARKDOWN}: Markdown rendering of the document.
  • - *
  • {@code TEXT}: Plain-text rendering of the document.
  • - *
  • {@code DOCTAGS}: DocTags rendering of the document.
  • - *
  • {@code RESOURCE_BUNDLE}: ZIP archive containing extracted images and supporting resources.
  • + *
  • {@code JSON}: Serialized {@code DoclingDocument} JSON.
  • + *
  • {@code HTML}: HTML rendering of the document.
  • + *
  • {@code MARKDOWN}: Markdown rendering of the document.
  • + *
  • {@code TEXT}: Plain-text rendering of the document.
  • + *
  • {@code DOCTAGS}: DocTags rendering of the document.
  • + *
  • {@code RESOURCE_BUNDLE}: ZIP archive containing extracted images and supporting resources.
  • + *
  • {@code CHUNKS}: Chunk records produced by convert-side chunking.
  • *
*/ public enum ArtifactType { - @JsonProperty("json") JSON, - @JsonProperty("html") HTML, - @JsonProperty("markdown") MARKDOWN, - @JsonProperty("text") TEXT, - @JsonProperty("doctags") DOCTAGS, - @JsonProperty("resource_bundle") RESOURCE_BUNDLE; + @JsonProperty("json") + JSON, + @JsonProperty("html") + HTML, + @JsonProperty("markdown") + MARKDOWN, + @JsonProperty("text") + TEXT, + @JsonProperty("doctags") + DOCTAGS, + @JsonProperty("resource_bundle") + RESOURCE_BUNDLE, + @JsonProperty("chunks") + CHUNKS; } diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java new file mode 100644 index 00000000..02fa89f6 --- /dev/null +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java @@ -0,0 +1,91 @@ +package ai.docling.serve.api.convert.response; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; + +import ai.docling.serve.api.chunk.response.Chunk; +import ai.docling.serve.api.chunk.response.Document; + +/** + * Response for document conversions that chunk the document as part of the conversion itself. + * + *

This response type is returned when the conversion request's {@code to_formats} includes + * {@link ai.docling.serve.api.convert.request.options.OutputFormat#CHUNKS} and the target is an + * {@link ai.docling.serve.api.convert.request.target.InBodyTarget}. Each source document's + * converted content is represented by a {@link Document} in {@link #getDocuments() documents}, + * and the chunk records produced from it are in {@link #getChunks() chunks}.

+ * + *

Serialization uses {@link JsonInclude.Include#NON_EMPTY}, so nulls and empty + * collections/strings are omitted from JSON output.

+ * + * @see ConvertDocumentResponse + * @see ResponseType#CHUNKED + * @see ai.docling.serve.api.convert.request.options.OutputFormat#CHUNKS + * @see Chunk + * @see Document + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +@lombok.extern.jackson.Jacksonized +@lombok.Builder(toBuilder = true) +@lombok.Getter +@lombok.ToString +public final class ChunkedConvertDocumentResponse extends ConvertDocumentResponse { + + /** + * List of document chunks produced by convert-side chunking. + * + * @param chunks the list of chunks + * @return the list of chunks + */ + @JsonProperty("chunks") + @JsonSetter(nulls = Nulls.AS_EMPTY) + @lombok.Singular + private List chunks; + + /** + * Per-source converted document content that was chunked. + * + * @param documents the list of converted documents + * @return the list of converted documents + */ + @JsonProperty("documents") + @JsonSetter(nulls = Nulls.AS_EMPTY) + @lombok.Singular + private List documents; + + /** + * Total processing time in seconds. + * + * @param processingTime the processing time in seconds + * @return the processing time in seconds + */ + @JsonProperty("processing_time") + private Double processingTime; + + @Override + @lombok.ToString.Include + public ResponseType getResponseType() { + return ResponseType.CHUNKED; + } + + /** + * Builder for creating {@link ChunkedConvertDocumentResponse} instances. + * Generated by Lombok's {@code @Builder} annotation. + * + *

Builder methods: + *

    + *
  • {@code chunk(Chunk)} - Add a single chunk (use with @Singular)
  • + *
  • {@code chunks(List)} - Set the list of chunks
  • + *
  • {@code document(Document)} - Add a single converted document (use with @Singular)
  • + *
  • {@code documents(List)} - Set the list of converted documents
  • + *
  • {@code processingTime(Double)} - Set the total processing time in seconds
  • + *
+ */ + public static class Builder { + } + +} diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java index 2172bbff..15104f93 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java @@ -21,8 +21,8 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = Jackson2ConvertDocumentResponseDeserializer.class) @tools.jackson.databind.annotation.JsonDeserialize(using = Jackson3ConvertDocumentResponseDeserializer.class) -public abstract sealed class ConvertDocumentResponse extends ProcessedDocumentResponse permits InBodyConvertDocumentResponse, - PreSignedUrlConvertDocumentResponse, PreSignedUrlConvertResponse, ZipArchiveConvertDocumentResponse { +public abstract sealed class ConvertDocumentResponse extends ProcessedDocumentResponse permits ChunkedConvertDocumentResponse, + InBodyConvertDocumentResponse, PreSignedUrlConvertDocumentResponse, PreSignedUrlConvertResponse, ZipArchiveConvertDocumentResponse { /** * Type of response * diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java index 4e7ad254..dd1692c1 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java @@ -9,16 +9,19 @@ * the converted document content is delivered to the client: * *
    - *
  • {@link #IN_BODY} - Content is embedded directly in the response body - * ({@link InBodyConvertDocumentResponse})
  • - *
  • {@link #ZIP_ARCHIVE} - Content is packaged and returned as a ZIP archive - * ({@link ZipArchiveConvertDocumentResponse})
  • - *
  • {@link #PRE_SIGNED_URL} - Content is uploaded to a client-supplied remote target and - * only aggregate processing statistics are returned. - * ({@link PreSignedUrlConvertDocumentResponse})
  • - *
  • {@link #PRE_SIGNED_URL_RESPONSE} - Each output artifact is uploaded to the server's - * configured object storage and returned as a time-limited presigned URL grouped by source document. - * ({@link PreSignedUrlConvertResponse})
  • + *
  • {@link #IN_BODY} - Content is embedded directly in the response body + * ({@link InBodyConvertDocumentResponse})
  • + *
  • {@link #ZIP_ARCHIVE} - Content is packaged and returned as a ZIP archive + * ({@link ZipArchiveConvertDocumentResponse})
  • + *
  • {@link #PRE_SIGNED_URL} - Content is uploaded to a client-supplied remote target and + * only aggregate processing statistics are returned. + * ({@link PreSignedUrlConvertDocumentResponse})
  • + *
  • {@link #PRE_SIGNED_URL_RESPONSE} - Each output artifact is uploaded to the server's + * configured object storage and returned as a time-limited presigned URL grouped by source document. + * ({@link PreSignedUrlConvertResponse})
  • + *
  • {@link #CHUNKED} - The document was chunked as part of the conversion itself and the + * chunk records are embedded directly in the response body. + * ({@link ChunkedConvertDocumentResponse})
  • *
* * @see ConvertDocumentResponse @@ -26,9 +29,10 @@ * @see ZipArchiveConvertDocumentResponse * @see PreSignedUrlConvertDocumentResponse * @see PreSignedUrlConvertResponse + * @see ChunkedConvertDocumentResponse */ public enum ResponseType { - + /** * Represents response type - {@link InBodyConvertDocumentResponse} * @@ -55,5 +59,12 @@ public enum ResponseType { * */ @JsonProperty("presigned_url_response") - PRE_SIGNED_URL_RESPONSE + PRE_SIGNED_URL_RESPONSE, + + /** + * Represents response type - {@link ChunkedConvertDocumentResponse} + * + */ + @JsonProperty("chunked") + CHUNKED } diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java index 1fcb2d99..aa14d572 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java @@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; +import ai.docling.serve.api.convert.response.ChunkedConvertDocumentResponse; import ai.docling.serve.api.convert.response.ConvertDocumentResponse; import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse; import ai.docling.serve.api.convert.response.PreSignedUrlConvertDocumentResponse; @@ -22,28 +23,32 @@ public class Jackson2ConvertDocumentResponseDeserializer extends JsonDeserialize public ConvertDocumentResponse deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { var codec = p.getCodec(); if (!(codec instanceof ObjectMapper mapper)) { - throw JsonMappingException.from(p, - "Expected ObjectMapper codec for ConvertDocumentResponse deserialization"); + throw JsonMappingException.from(p, "Expected ObjectMapper codec for ConvertDocumentResponse deserialization"); } JsonNode tree = mapper.readTree(p); if (!(tree instanceof ObjectNode node)) { - throw JsonMappingException.from(p, - "Expected a JSON object for ConvertDocumentResponse but got " + tree.getNodeType()); + throw JsonMappingException.from(p, "Expected a JSON object for ConvertDocumentResponse but got " + tree.getNodeType()); } - if (node.has("documents")) { + if (node.has("chunks")) { + return mapper.treeToValue(node, ChunkedConvertDocumentResponse.class); + } + else if (node.has("documents")) { return mapper.treeToValue(node, PreSignedUrlConvertResponse.class); - } else if (node.has("document")) { + } + else if (node.has("document")) { return mapper.treeToValue(node, InBodyConvertDocumentResponse.class); - } else if (node.has("file_name")) { + } + else if (node.has("file_name")) { return mapper.treeToValue(node, ZipArchiveConvertDocumentResponse.class); - } else if (node.has("num_converted")) { + } + else if (node.has("num_converted")) { return mapper.treeToValue(node, PreSignedUrlConvertDocumentResponse.class); } - throw JsonMappingException.from(p, - "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (documents, document, file_name, num_converted) found in JSON"); + throw JsonMappingException + .from(p, "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (chunks, documents, document, file_name, num_converted) found in JSON"); } } diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java index fc152ee8..76d04fc7 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java @@ -8,6 +8,7 @@ import tools.jackson.databind.ValueDeserializer; import tools.jackson.databind.node.ObjectNode; +import ai.docling.serve.api.convert.response.ChunkedConvertDocumentResponse; import ai.docling.serve.api.convert.response.ConvertDocumentResponse; import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse; import ai.docling.serve.api.convert.response.PreSignedUrlConvertDocumentResponse; @@ -21,21 +22,26 @@ public ConvertDocumentResponse deserialize(JsonParser p, DeserializationContext JsonNode tree = ctxt.readTree(p); if (!(tree instanceof ObjectNode node)) { - throw DatabindException.from(p, - "Expected a JSON object for ConvertDocumentResponse but got " + tree.getNodeType()); + throw DatabindException.from(p, "Expected a JSON object for ConvertDocumentResponse but got " + tree.getNodeType()); } - if (node.has("documents")) { + if (node.has("chunks")) { + return ctxt.readTreeAsValue(node, ChunkedConvertDocumentResponse.class); + } + else if (node.has("documents")) { return ctxt.readTreeAsValue(node, PreSignedUrlConvertResponse.class); - } else if (node.has("document")) { + } + else if (node.has("document")) { return ctxt.readTreeAsValue(node, InBodyConvertDocumentResponse.class); - } else if (node.has("file_name")) { + } + else if (node.has("file_name")) { return ctxt.readTreeAsValue(node, ZipArchiveConvertDocumentResponse.class); - } else if (node.has("num_converted")) { + } + else if (node.has("num_converted")) { return ctxt.readTreeAsValue(node, PreSignedUrlConvertDocumentResponse.class); } - throw DatabindException.from(p, - "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (documents, document, file_name, num_converted) found in JSON"); + throw DatabindException + .from(p, "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (chunks, documents, document, file_name, num_converted) found in JSON"); } } diff --git a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java index 1db3cc2a..b405fb75 100644 --- a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java +++ b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java @@ -10,6 +10,8 @@ import org.junit.jupiter.api.Test; +import ai.docling.serve.api.chunk.request.options.HybridChunkerOptions; + /** * Unit tests for {@link ConvertDocumentOptions}. */ @@ -184,6 +186,61 @@ void convertDocumentOptionsToBuilderKeepsPresetsAndCustomConfigs() { .containsExactly("easyocr", Map.of("kind", "docling_layout_default"), true, true, true); } + @Test + void convertDocumentOptionsWithChunkingPreset() { + var options = ConvertDocumentOptions.builder() + .toFormat(OutputFormat.CHUNKS) + .chunkingPreset("hybrid") + .build(); + + assertThat(options) + .extracting(ConvertDocumentOptions::getChunkingPreset, ConvertDocumentOptions::getChunkingOptions) + .containsExactly("hybrid", null); + assertThat(options.getToFormats()).containsExactly(OutputFormat.CHUNKS); + } + + @Test + void convertDocumentOptionsWithChunkingOptions() { + var chunkerOptions = HybridChunkerOptions.builder() + .useMarkdownTables(true) + .maxTokens(512) + .build(); + + var options = ConvertDocumentOptions.builder() + .toFormat(OutputFormat.CHUNKS) + .chunkingOptions(chunkerOptions) + .build(); + + assertThat(options) + .extracting(ConvertDocumentOptions::getChunkingPreset, ConvertDocumentOptions::getChunkingOptions) + .containsExactly(null, chunkerOptions); + } + + @Test + void convertDocumentOptionsChunkingDefaultsToNull() { + var options = ConvertDocumentOptions.builder().build(); + + assertThat(options) + .extracting(ConvertDocumentOptions::getChunkingPreset, ConvertDocumentOptions::getChunkingOptions) + .containsOnlyNulls(); + } + + @Test + void convertDocumentOptionsToBuilderKeepsChunkingOptions() { + var chunkerOptions = HybridChunkerOptions.builder().maxTokens(256).build(); + + var original = ConvertDocumentOptions.builder() + .toFormat(OutputFormat.CHUNKS) + .chunkingOptions(chunkerOptions) + .build(); + + var rebuilt = original.toBuilder().build(); + + assertThat(rebuilt) + .extracting(ConvertDocumentOptions::getChunkingPreset, ConvertDocumentOptions::getChunkingOptions) + .containsExactly(null, chunkerOptions); + } + @Test void convertDocumentOptionsToBuilderWithHeadingHierarchy() { var hierarchyOptions = HeadingHierarchyOptions.builder() diff --git a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ArtifactRefTests.java b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ArtifactRefTests.java index add672c6..2b56b6f8 100644 --- a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ArtifactRefTests.java +++ b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ArtifactRefTests.java @@ -57,4 +57,10 @@ void toBuilderRoundtripsToEqualInstance() { ArtifactRef roundtripped = FULL_REF.toBuilder().build(); assertThat(roundtripped).usingRecursiveComparison().isEqualTo(FULL_REF); } + + @Test + void supportsChunksArtifactType() { + ArtifactRef ref = FULL_REF.toBuilder().artifactType(ArtifactType.CHUNKS).build(); + assertThat(ref.getArtifactType()).isEqualTo(ArtifactType.CHUNKS); + } } diff --git a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java index 77ffd6b9..b6598246 100644 --- a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java +++ b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java @@ -11,6 +11,9 @@ import ai.docling.core.DoclingDocument; import ai.docling.core.DoclingDocument.TitleItem; +import ai.docling.serve.api.chunk.response.Chunk; +import ai.docling.serve.api.chunk.response.Document; +import ai.docling.serve.api.chunk.response.ExportDocumentResponse; /** * Unit tests for {@link ConvertDocumentResponse}. @@ -32,15 +35,14 @@ void createResponseWithAllFields() { .build(); List errors = List.of( - ErrorItem.builder().componentType("parser").errorMessage("Parse error").moduleName("pdf_module").build(), - ErrorItem.builder().componentType("converter").errorMessage("Conversion warning").moduleName("html_module").build() + ErrorItem.builder().componentType("parser").errorMessage("Parse error").moduleName("pdf_module").build(), ErrorItem.builder().componentType("converter") + .errorMessage("Conversion warning").moduleName("html_module").build() ); Double processingTime = 1.5; String status = "success"; Map timings = Map.of( - "parse_time", 0.8, - "convert_time", 0.7 + "parse_time", 0.8, "convert_time", 0.7 ); InBodyConvertDocumentResponse response = InBodyConvertDocumentResponse.builder() @@ -137,6 +139,46 @@ void createPreSignedUrlConvertResponseWithAllFields() { assertThat(response.getResponseType()).isEqualTo(ResponseType.PRE_SIGNED_URL_RESPONSE); } + @Test + void createChunkedConvertDocumentResponseWithNullFields() { + ChunkedConvertDocumentResponse response = ChunkedConvertDocumentResponse.builder().build(); + + assertThat(response.getChunks()).isNotNull().isEmpty(); + assertThat(response.getDocuments()).isNotNull().isEmpty(); + assertThat(response.getProcessingTime()).isNull(); + assertThat(response.getResponseType()).isEqualTo(ResponseType.CHUNKED); + } + + @Test + void createChunkedConvertDocumentResponseWithAllFields() { + ExportDocumentResponse content = ExportDocumentResponse.builder() + .filename("example.pdf") + .markdownContent("# Example") + .build(); + Document document = Document.builder() + .kind("ExportResult") + .content(content) + .status("success") + .build(); + Chunk chunk = Chunk.builder() + .filename("example.pdf") + .chunkIndex(0) + .text("Example chunk text") + .numTokens(42) + .build(); + + ChunkedConvertDocumentResponse response = ChunkedConvertDocumentResponse.builder() + .processingTime(1.23) + .document(document) + .chunk(chunk) + .build(); + + assertThat(response.getProcessingTime()).isEqualTo(1.23); + assertThat(response.getDocuments()).containsExactly(document); + assertThat(response.getChunks()).containsExactly(chunk); + assertThat(response.getResponseType()).isEqualTo(ResponseType.CHUNKED); + } + @Test void createResponseWithEmptyCollections() { DocumentResponse document = DocumentResponse.builder() diff --git a/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java b/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java index 0d25354a..b13a6e4a 100644 --- a/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java +++ b/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java @@ -99,6 +99,7 @@ import ai.docling.serve.api.convert.request.target.S3Target; import ai.docling.serve.api.convert.request.target.ZipTarget; import ai.docling.serve.api.convert.response.ArtifactType; +import ai.docling.serve.api.convert.response.ChunkedConvertDocumentResponse; import ai.docling.serve.api.convert.response.ConversionStatus; import ai.docling.serve.api.convert.response.ConvertDocumentResponse; import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse; @@ -1462,6 +1463,79 @@ void shouldConvertSourceWithPresignedUrlTargetAndMultipleDocuments() { ); } + @Test + void shouldConvertSourceWithInBodyTargetAndChunkingSuccessfully() { + var request = ConvertDocumentRequest.builder() + .source(HttpSource.builder().url(URI.create("https://arxiv.org/pdf/2408.09869")).build()) + .options( + ConvertDocumentOptions.builder() + .toFormat(OutputFormat.CHUNKS) + .chunkingPreset("hybrid") + .build() + ) + .build(); + + var wireMockServer = getWiremockServer(); + + wireMockServer.stubFor( + post("/v1/convert/source") + .withRequestBody(equalToJson(writeValueAsString(request))) + .withHeader("Content-Type", equalTo("application/json")) + .withHeader("Accept", equalTo("application/json")) + .willReturn(okJson(""" + { + "processing_time": 2.31, + "documents": [ + { + "kind": "ExportResult", + "status": "success", + "content": { + "filename": "2408.09869" + } + } + ], + "chunks": [ + { + "filename": "2408.09869", + "chunk_index": 0, + "text": "Example chunk text", + "num_tokens": 42 + } + ] + } + """)) + ); + + var response = getDoclingClient(false, true).convertSource(request); + assertThat(response).isNotNull(); + assertThat(response.getResponseType()).isEqualTo(ResponseType.CHUNKED); + assertThat(response).isInstanceOf(ChunkedConvertDocumentResponse.class); + + var chunkedResponse = (ChunkedConvertDocumentResponse) response; + assertThat(chunkedResponse.getProcessingTime()).isEqualTo(2.31); + + assertThat(chunkedResponse.getDocuments()).hasSize(1); + var document = chunkedResponse.getDocuments().get(0); + assertThat(document.getKind()).isEqualTo("ExportResult"); + assertThat(document.getStatus()).isEqualTo("success"); + assertThat(document.getContent().getFilename()).isEqualTo("2408.09869"); + + assertThat(chunkedResponse.getChunks()).hasSize(1); + var chunk = chunkedResponse.getChunks().get(0); + assertThat(chunk.getFilename()).isEqualTo("2408.09869"); + assertThat(chunk.getChunkIndex()).isZero(); + assertThat(chunk.getText()).isEqualTo("Example chunk text"); + assertThat(chunk.getNumTokens()).isEqualTo(42); + + wireMockServer.verify( + postRequestedFor(urlPathEqualTo("/v1/convert/source")) + .withRequestBody( + matchingJsonPath("$.options.to_formats[0]", equalTo("chunks")) + .and(matchingJsonPath("$.options.chunking_preset", equalTo("hybrid"))) + ) + ); + } + @Test void shouldConvertSingleHttpSourceWithDefaultTargetSuccessfully() { var request = ConvertDocumentRequest.builder() diff --git a/docs/src/doc/docs/whats-new.md b/docs/src/doc/docs/whats-new.md index 9819ab96..898ed275 100644 --- a/docs/src/doc/docs/whats-new.md +++ b/docs/src/doc/docs/whats-new.md @@ -27,6 +27,7 @@ Docling Java {{ gradle.project_version }} includes important breaking changes, a ### {{ gradle.project_version }} * **`OutputFormat` gains `YAML`, `VTT`, `DOCLANG`, `DCLX` and `LATEX`** — These were missing from the enum, so Docling Serve rejected `toFormats`/`toFormat` requests for them even though the server supports them. `DocumentResponse` also gains a `doclangContent` accessor, mirroring `doctagsContent`/`htmlContent`/etc., since Docling Serve returns `doclang_content` inline the same way it does for the existing formats. `DCLX` has no inline content field but is exported as a file, reachable through file-based targets such as a zip archive or a presigned URL. `YAML`, `VTT`, and `LATEX` are accepted by the server's request validation but currently have no implemented export at all, inline or file — requesting them succeeds but produces nothing for those formats. +* **Convert-side chunking** — Docling Serve can chunk a document in the same pass as the conversion, instead of converting and then sending the result to `/chunk`. `OutputFormat` gains `CHUNKS`, which must be included in `toFormats`/`toFormat` to activate it, and `ConvertDocumentOptions` gains `chunkingPreset` (`String`) and `chunkingOptions` (the existing `ChunkerOptions` used by the `/chunk` endpoint), mutually exclusive, configuring the chunker. With an `InBodyTarget`, the response comes back as a new `ChunkedConvertDocumentResponse` (`ResponseType.CHUNKED`), carrying `documents` (the converted content that was chunked, reusing the chunk API's `Document` type) and `chunks` (reusing the chunk API's `Chunk` type). With a presigned target, the chunks file comes back as a `chunks` artifact on a `DocumentArtifactItem`, which required adding `ArtifactType.CHUNKS`. Because a chunked in-body response and a `PreSignedUrlConvertResponse` both carry a `documents` field, the convert response deserializer now checks for `chunks` first to tell them apart. * **`docling-testcontainers` default image bumped to `v1.41.0`** — `DoclingServeContainerConfig.DOCLING_IMAGE` now pins `ghcr.io/docling-project/docling-serve:v1.41.0` (previously `v1.35.0`). `ConvertDocumentOptions` is unchanged across this range, but one behavioral difference will show up for consumers relying on the previous default: a single-file conversion with `ZipTarget` now names the archive after the source file (e.g. `2408.09869.zip`) instead of the generic `converted_docs.zip`; multi-file conversions are unaffected. Preset registration remains image-specific — see the warning in [Per-stage presets and custom configurations](docling-serve/serve-api.md#per-stage-presets-and-custom-configurations). * **Per-stage presets and custom configurations on `ConvertDocumentOptions`** — Eight pipeline stages (layout, OCR, table structure, picture description, picture classification, code & formula, chart extraction and the VLM pipeline) can now be tuned from Java, each through a `Preset` string or a `CustomConfig` map, for example `ocrPreset("easyocr")` or `layoutCustomConfigEntry("kind", "docling_layout_default")`. Presets are plain strings because the available ids are set by the Docling Serve deployment, so not even `"default"` is registered for every stage on every image. A custom config is a `Map` with a stage-specific schema, in one of two shapes: the kind-selected stages (layout, OCR, table structure, picture classification) pick an implementation through a `kind` entry, while the VLM-backed stages (picture description, code & formula, chart extraction, VLM pipeline) take `model_spec` and `engine_options` entries instead. The preset and the custom config are mutually exclusive per stage — a custom config replaces the preset rather than overriding it. These supersede `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi` and the `vlmPipelineModel*` options, which Docling Serve marks as deprecated. * **The options Docling Serve deprecates are now `@Deprecated` in Java** — `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi`, `vlmPipelineModel`, `vlmPipelineModelLocal` and `vlmPipelineModelApi` carry `@Deprecated(since = "0.7.3")`, which Lombok copies onto both the getter and the builder setter, so setting one produces a compiler warning pointing at the preset or custom-config replacement. They are deliberately **not** marked `forRemoval`: these options still work, and when they are removed is Docling Serve's decision rather than this library's. The four types that are only reachable through those options — `OcrEngine`, `VlmModelType`, `PictureDescriptionLocal` and `PictureDescriptionApi` — are marked `@Deprecated` as well, so the warning also appears at `PictureDescriptionApi.builder()` rather than only at the setter. From 6ae100b6b16c76084f5c4cedec5ad7c2996a5af8 Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Tue, 1 Dec 2026 15:34:32 -0500 Subject: [PATCH 2/3] fix(api): drop in-body chunked convert response, unreachable on the server Verified against a live docling-serve v1.41.0 container: when "chunks" is requested in to_formats together with a single-document InBodyTarget, the server silently omits chunk output entirely and returns a plain in-body document response instead. The {chunks, documents, processing_time} shape modeled by ChunkedConvertDocumentResponse is actually the response shape of the dedicated /chunk endpoints, not anything /convert/source ever returns, so the chunks-before-documents dispatch fix in both Jackson deserializers was never reachable from a real server response. The presigned-target chunking support (ArtifactType.CHUNKS, chunkingPreset/chunkingOptions on ConvertDocumentOptions) is unaffected and was confirmed against the same container to behave as implemented. Also corrects the chunkingPreset javadoc/test example: "hybrid" and "hierarchical" are the chunker discriminator used by ChunkerOptions, not registered chunking_preset ids. Related to #821, #822. Assisted-By: Claude Code Signed-off-by: Eric Deandrea --- .../options/ConvertDocumentOptions.java | 9 +- .../ChunkedConvertDocumentResponse.java | 91 ------------------- .../response/ConvertDocumentResponse.java | 4 +- .../api/convert/response/ResponseType.java | 13 +-- ...n2ConvertDocumentResponseDeserializer.java | 8 +- ...n3ConvertDocumentResponseDeserializer.java | 8 +- .../options/ConvertDocumentOptionsTests.java | 4 +- .../ConvertDocumentResponseTests.java | 43 --------- .../AbstractDoclingServeClientTests.java | 57 ++++-------- docs/src/doc/docs/whats-new.md | 2 +- 10 files changed, 34 insertions(+), 205 deletions(-) delete mode 100644 docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java index 7776667e..8bb3338f 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java @@ -431,8 +431,10 @@ public class ConvertDocumentOptions { private Map vlmPipelineCustomConfig; /** - * Preset id for the chunker, for example {@code hybrid} or {@code hierarchical}. Mutually exclusive with {@link #getChunkingOptions()}. Only takes effect when - * {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}. + * Preset id for the chunker, for example {@code granite_embedding_278m}, registered by the Docling Serve deployment's chunker manager. This is a deployment-specific identifier, + * not the {@code chunker} discriminator used by {@link ai.docling.serve.api.chunk.request.options.ChunkerOptions} (e.g. {@code hybrid}/{@code hierarchical}). Mutually exclusive + * with {@link #getChunkingOptions()}. Only takes effect when {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}, and only with a presigned target — Docling Serve + * silently omits chunk output when chunking is requested with a single-document in-body target. */ @JsonProperty("chunking_preset") @Nullable @@ -440,7 +442,8 @@ public class ConvertDocumentOptions { /** * Chunker configuration for convert-side chunking, performed in the same pass as the conversion. Mutually exclusive with {@link #getChunkingPreset()}. Only takes effect when - * {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}. + * {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}, and only with a presigned target — Docling Serve silently omits chunk output when chunking is requested with a + * single-document in-body target. */ @JsonProperty("chunking_options") @Nullable diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java deleted file mode 100644 index 02fa89f6..00000000 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java +++ /dev/null @@ -1,91 +0,0 @@ -package ai.docling.serve.api.convert.response; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; - -import ai.docling.serve.api.chunk.response.Chunk; -import ai.docling.serve.api.chunk.response.Document; - -/** - * Response for document conversions that chunk the document as part of the conversion itself. - * - *

This response type is returned when the conversion request's {@code to_formats} includes - * {@link ai.docling.serve.api.convert.request.options.OutputFormat#CHUNKS} and the target is an - * {@link ai.docling.serve.api.convert.request.target.InBodyTarget}. Each source document's - * converted content is represented by a {@link Document} in {@link #getDocuments() documents}, - * and the chunk records produced from it are in {@link #getChunks() chunks}.

- * - *

Serialization uses {@link JsonInclude.Include#NON_EMPTY}, so nulls and empty - * collections/strings are omitted from JSON output.

- * - * @see ConvertDocumentResponse - * @see ResponseType#CHUNKED - * @see ai.docling.serve.api.convert.request.options.OutputFormat#CHUNKS - * @see Chunk - * @see Document - */ -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@lombok.extern.jackson.Jacksonized -@lombok.Builder(toBuilder = true) -@lombok.Getter -@lombok.ToString -public final class ChunkedConvertDocumentResponse extends ConvertDocumentResponse { - - /** - * List of document chunks produced by convert-side chunking. - * - * @param chunks the list of chunks - * @return the list of chunks - */ - @JsonProperty("chunks") - @JsonSetter(nulls = Nulls.AS_EMPTY) - @lombok.Singular - private List chunks; - - /** - * Per-source converted document content that was chunked. - * - * @param documents the list of converted documents - * @return the list of converted documents - */ - @JsonProperty("documents") - @JsonSetter(nulls = Nulls.AS_EMPTY) - @lombok.Singular - private List documents; - - /** - * Total processing time in seconds. - * - * @param processingTime the processing time in seconds - * @return the processing time in seconds - */ - @JsonProperty("processing_time") - private Double processingTime; - - @Override - @lombok.ToString.Include - public ResponseType getResponseType() { - return ResponseType.CHUNKED; - } - - /** - * Builder for creating {@link ChunkedConvertDocumentResponse} instances. - * Generated by Lombok's {@code @Builder} annotation. - * - *

Builder methods: - *

    - *
  • {@code chunk(Chunk)} - Add a single chunk (use with @Singular)
  • - *
  • {@code chunks(List)} - Set the list of chunks
  • - *
  • {@code document(Document)} - Add a single converted document (use with @Singular)
  • - *
  • {@code documents(List)} - Set the list of converted documents
  • - *
  • {@code processingTime(Double)} - Set the total processing time in seconds
  • - *
- */ - public static class Builder { - } - -} diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java index 15104f93..2172bbff 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java @@ -21,8 +21,8 @@ @JsonInclude(JsonInclude.Include.NON_EMPTY) @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = Jackson2ConvertDocumentResponseDeserializer.class) @tools.jackson.databind.annotation.JsonDeserialize(using = Jackson3ConvertDocumentResponseDeserializer.class) -public abstract sealed class ConvertDocumentResponse extends ProcessedDocumentResponse permits ChunkedConvertDocumentResponse, - InBodyConvertDocumentResponse, PreSignedUrlConvertDocumentResponse, PreSignedUrlConvertResponse, ZipArchiveConvertDocumentResponse { +public abstract sealed class ConvertDocumentResponse extends ProcessedDocumentResponse permits InBodyConvertDocumentResponse, + PreSignedUrlConvertDocumentResponse, PreSignedUrlConvertResponse, ZipArchiveConvertDocumentResponse { /** * Type of response * diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java index dd1692c1..cc0f7a5b 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java @@ -19,9 +19,6 @@ *
  • {@link #PRE_SIGNED_URL_RESPONSE} - Each output artifact is uploaded to the server's * configured object storage and returned as a time-limited presigned URL grouped by source document. * ({@link PreSignedUrlConvertResponse})
  • - *
  • {@link #CHUNKED} - The document was chunked as part of the conversion itself and the - * chunk records are embedded directly in the response body. - * ({@link ChunkedConvertDocumentResponse})
  • * * * @see ConvertDocumentResponse @@ -29,7 +26,6 @@ * @see ZipArchiveConvertDocumentResponse * @see PreSignedUrlConvertDocumentResponse * @see PreSignedUrlConvertResponse - * @see ChunkedConvertDocumentResponse */ public enum ResponseType { @@ -59,12 +55,5 @@ public enum ResponseType { * */ @JsonProperty("presigned_url_response") - PRE_SIGNED_URL_RESPONSE, - - /** - * Represents response type - {@link ChunkedConvertDocumentResponse} - * - */ - @JsonProperty("chunked") - CHUNKED + PRE_SIGNED_URL_RESPONSE } diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java index aa14d572..064166aa 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java @@ -10,7 +10,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import ai.docling.serve.api.convert.response.ChunkedConvertDocumentResponse; import ai.docling.serve.api.convert.response.ConvertDocumentResponse; import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse; import ai.docling.serve.api.convert.response.PreSignedUrlConvertDocumentResponse; @@ -32,10 +31,7 @@ public ConvertDocumentResponse deserialize(JsonParser p, DeserializationContext throw JsonMappingException.from(p, "Expected a JSON object for ConvertDocumentResponse but got " + tree.getNodeType()); } - if (node.has("chunks")) { - return mapper.treeToValue(node, ChunkedConvertDocumentResponse.class); - } - else if (node.has("documents")) { + if (node.has("documents")) { return mapper.treeToValue(node, PreSignedUrlConvertResponse.class); } else if (node.has("document")) { @@ -49,6 +45,6 @@ else if (node.has("num_converted")) { } throw JsonMappingException - .from(p, "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (chunks, documents, document, file_name, num_converted) found in JSON"); + .from(p, "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (documents, document, file_name, num_converted) found in JSON"); } } diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java index 76d04fc7..efc732a1 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java @@ -8,7 +8,6 @@ import tools.jackson.databind.ValueDeserializer; import tools.jackson.databind.node.ObjectNode; -import ai.docling.serve.api.convert.response.ChunkedConvertDocumentResponse; import ai.docling.serve.api.convert.response.ConvertDocumentResponse; import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse; import ai.docling.serve.api.convert.response.PreSignedUrlConvertDocumentResponse; @@ -25,10 +24,7 @@ public ConvertDocumentResponse deserialize(JsonParser p, DeserializationContext throw DatabindException.from(p, "Expected a JSON object for ConvertDocumentResponse but got " + tree.getNodeType()); } - if (node.has("chunks")) { - return ctxt.readTreeAsValue(node, ChunkedConvertDocumentResponse.class); - } - else if (node.has("documents")) { + if (node.has("documents")) { return ctxt.readTreeAsValue(node, PreSignedUrlConvertResponse.class); } else if (node.has("document")) { @@ -42,6 +38,6 @@ else if (node.has("num_converted")) { } throw DatabindException - .from(p, "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (chunks, documents, document, file_name, num_converted) found in JSON"); + .from(p, "Cannot determine ConvertDocumentResponse subtype: none of the expected fields (documents, document, file_name, num_converted) found in JSON"); } } diff --git a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java index b405fb75..ec828480 100644 --- a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java +++ b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java @@ -190,12 +190,12 @@ void convertDocumentOptionsToBuilderKeepsPresetsAndCustomConfigs() { void convertDocumentOptionsWithChunkingPreset() { var options = ConvertDocumentOptions.builder() .toFormat(OutputFormat.CHUNKS) - .chunkingPreset("hybrid") + .chunkingPreset("granite_embedding_278m") .build(); assertThat(options) .extracting(ConvertDocumentOptions::getChunkingPreset, ConvertDocumentOptions::getChunkingOptions) - .containsExactly("hybrid", null); + .containsExactly("granite_embedding_278m", null); assertThat(options.getToFormats()).containsExactly(OutputFormat.CHUNKS); } diff --git a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java index b6598246..1f59c8bc 100644 --- a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java +++ b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java @@ -11,9 +11,6 @@ import ai.docling.core.DoclingDocument; import ai.docling.core.DoclingDocument.TitleItem; -import ai.docling.serve.api.chunk.response.Chunk; -import ai.docling.serve.api.chunk.response.Document; -import ai.docling.serve.api.chunk.response.ExportDocumentResponse; /** * Unit tests for {@link ConvertDocumentResponse}. @@ -139,46 +136,6 @@ void createPreSignedUrlConvertResponseWithAllFields() { assertThat(response.getResponseType()).isEqualTo(ResponseType.PRE_SIGNED_URL_RESPONSE); } - @Test - void createChunkedConvertDocumentResponseWithNullFields() { - ChunkedConvertDocumentResponse response = ChunkedConvertDocumentResponse.builder().build(); - - assertThat(response.getChunks()).isNotNull().isEmpty(); - assertThat(response.getDocuments()).isNotNull().isEmpty(); - assertThat(response.getProcessingTime()).isNull(); - assertThat(response.getResponseType()).isEqualTo(ResponseType.CHUNKED); - } - - @Test - void createChunkedConvertDocumentResponseWithAllFields() { - ExportDocumentResponse content = ExportDocumentResponse.builder() - .filename("example.pdf") - .markdownContent("# Example") - .build(); - Document document = Document.builder() - .kind("ExportResult") - .content(content) - .status("success") - .build(); - Chunk chunk = Chunk.builder() - .filename("example.pdf") - .chunkIndex(0) - .text("Example chunk text") - .numTokens(42) - .build(); - - ChunkedConvertDocumentResponse response = ChunkedConvertDocumentResponse.builder() - .processingTime(1.23) - .document(document) - .chunk(chunk) - .build(); - - assertThat(response.getProcessingTime()).isEqualTo(1.23); - assertThat(response.getDocuments()).containsExactly(document); - assertThat(response.getChunks()).containsExactly(chunk); - assertThat(response.getResponseType()).isEqualTo(ResponseType.CHUNKED); - } - @Test void createResponseWithEmptyCollections() { DocumentResponse document = DocumentResponse.builder() diff --git a/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java b/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java index b13a6e4a..17b39ae8 100644 --- a/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java +++ b/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java @@ -99,7 +99,6 @@ import ai.docling.serve.api.convert.request.target.S3Target; import ai.docling.serve.api.convert.request.target.ZipTarget; import ai.docling.serve.api.convert.response.ArtifactType; -import ai.docling.serve.api.convert.response.ChunkedConvertDocumentResponse; import ai.docling.serve.api.convert.response.ConversionStatus; import ai.docling.serve.api.convert.response.ConvertDocumentResponse; import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse; @@ -1464,13 +1463,15 @@ void shouldConvertSourceWithPresignedUrlTargetAndMultipleDocuments() { } @Test - void shouldConvertSourceWithInBodyTargetAndChunkingSuccessfully() { + void shouldConvertSourceWithInBodyTargetAndChunkingIgnoringChunks() { + // Docling Serve silently omits chunk output when "chunks" is requested alongside a + // single-document in-body target, returning a plain in-body document response instead. var request = ConvertDocumentRequest.builder() .source(HttpSource.builder().url(URI.create("https://arxiv.org/pdf/2408.09869")).build()) .options( ConvertDocumentOptions.builder() .toFormat(OutputFormat.CHUNKS) - .chunkingPreset("hybrid") + .chunkingPreset("granite_embedding_278m") .build() ) .build(); @@ -1484,54 +1485,32 @@ void shouldConvertSourceWithInBodyTargetAndChunkingSuccessfully() { .withHeader("Accept", equalTo("application/json")) .willReturn(okJson(""" { - "processing_time": 2.31, - "documents": [ - { - "kind": "ExportResult", - "status": "success", - "content": { - "filename": "2408.09869" - } - } - ], - "chunks": [ - { - "filename": "2408.09869", - "chunk_index": 0, - "text": "Example chunk text", - "num_tokens": 42 - } - ] + "document": { + "filename": "2408.09869", + "md_content": "# Example" + }, + "status": "success", + "processing_time": 2.31 } """)) ); var response = getDoclingClient(false, true).convertSource(request); assertThat(response).isNotNull(); - assertThat(response.getResponseType()).isEqualTo(ResponseType.CHUNKED); - assertThat(response).isInstanceOf(ChunkedConvertDocumentResponse.class); - - var chunkedResponse = (ChunkedConvertDocumentResponse) response; - assertThat(chunkedResponse.getProcessingTime()).isEqualTo(2.31); - - assertThat(chunkedResponse.getDocuments()).hasSize(1); - var document = chunkedResponse.getDocuments().get(0); - assertThat(document.getKind()).isEqualTo("ExportResult"); - assertThat(document.getStatus()).isEqualTo("success"); - assertThat(document.getContent().getFilename()).isEqualTo("2408.09869"); + assertThat(response.getResponseType()).isEqualTo(ResponseType.IN_BODY); + assertThat(response).isInstanceOf(InBodyConvertDocumentResponse.class); - assertThat(chunkedResponse.getChunks()).hasSize(1); - var chunk = chunkedResponse.getChunks().get(0); - assertThat(chunk.getFilename()).isEqualTo("2408.09869"); - assertThat(chunk.getChunkIndex()).isZero(); - assertThat(chunk.getText()).isEqualTo("Example chunk text"); - assertThat(chunk.getNumTokens()).isEqualTo(42); + var inBodyResponse = (InBodyConvertDocumentResponse) response; + assertThat(inBodyResponse.getProcessingTime()).isEqualTo(2.31); + assertThat(inBodyResponse.getStatus()).isEqualTo("success"); + assertThat(inBodyResponse.getDocument().getFilename()).isEqualTo("2408.09869"); + assertThat(inBodyResponse.getDocument().getMarkdownContent()).isEqualTo("# Example"); wireMockServer.verify( postRequestedFor(urlPathEqualTo("/v1/convert/source")) .withRequestBody( matchingJsonPath("$.options.to_formats[0]", equalTo("chunks")) - .and(matchingJsonPath("$.options.chunking_preset", equalTo("hybrid"))) + .and(matchingJsonPath("$.options.chunking_preset", equalTo("granite_embedding_278m"))) ) ); } diff --git a/docs/src/doc/docs/whats-new.md b/docs/src/doc/docs/whats-new.md index 898ed275..3a9e44a8 100644 --- a/docs/src/doc/docs/whats-new.md +++ b/docs/src/doc/docs/whats-new.md @@ -27,7 +27,7 @@ Docling Java {{ gradle.project_version }} includes important breaking changes, a ### {{ gradle.project_version }} * **`OutputFormat` gains `YAML`, `VTT`, `DOCLANG`, `DCLX` and `LATEX`** — These were missing from the enum, so Docling Serve rejected `toFormats`/`toFormat` requests for them even though the server supports them. `DocumentResponse` also gains a `doclangContent` accessor, mirroring `doctagsContent`/`htmlContent`/etc., since Docling Serve returns `doclang_content` inline the same way it does for the existing formats. `DCLX` has no inline content field but is exported as a file, reachable through file-based targets such as a zip archive or a presigned URL. `YAML`, `VTT`, and `LATEX` are accepted by the server's request validation but currently have no implemented export at all, inline or file — requesting them succeeds but produces nothing for those formats. -* **Convert-side chunking** — Docling Serve can chunk a document in the same pass as the conversion, instead of converting and then sending the result to `/chunk`. `OutputFormat` gains `CHUNKS`, which must be included in `toFormats`/`toFormat` to activate it, and `ConvertDocumentOptions` gains `chunkingPreset` (`String`) and `chunkingOptions` (the existing `ChunkerOptions` used by the `/chunk` endpoint), mutually exclusive, configuring the chunker. With an `InBodyTarget`, the response comes back as a new `ChunkedConvertDocumentResponse` (`ResponseType.CHUNKED`), carrying `documents` (the converted content that was chunked, reusing the chunk API's `Document` type) and `chunks` (reusing the chunk API's `Chunk` type). With a presigned target, the chunks file comes back as a `chunks` artifact on a `DocumentArtifactItem`, which required adding `ArtifactType.CHUNKS`. Because a chunked in-body response and a `PreSignedUrlConvertResponse` both carry a `documents` field, the convert response deserializer now checks for `chunks` first to tell them apart. +* **Convert-side chunking** — Docling Serve can chunk a document in the same pass as the conversion, instead of converting and then sending the result to `/chunk`. `OutputFormat` gains `CHUNKS`, which must be included in `toFormats`/`toFormat` to activate it, and `ConvertDocumentOptions` gains `chunkingPreset` (`String`, a deployment-registered preset id such as `granite_embedding_278m`) and `chunkingOptions` (the existing `ChunkerOptions` used by the `/chunk` endpoint), mutually exclusive, configuring the chunker. With a presigned target, the chunks file comes back as a `chunks` artifact on a `DocumentArtifactItem`, which required adding `ArtifactType.CHUNKS`. Docling Serve silently omits chunk output when `chunks` is requested together with a single-document in-body target, so this option only has an effect with a presigned target. * **`docling-testcontainers` default image bumped to `v1.41.0`** — `DoclingServeContainerConfig.DOCLING_IMAGE` now pins `ghcr.io/docling-project/docling-serve:v1.41.0` (previously `v1.35.0`). `ConvertDocumentOptions` is unchanged across this range, but one behavioral difference will show up for consumers relying on the previous default: a single-file conversion with `ZipTarget` now names the archive after the source file (e.g. `2408.09869.zip`) instead of the generic `converted_docs.zip`; multi-file conversions are unaffected. Preset registration remains image-specific — see the warning in [Per-stage presets and custom configurations](docling-serve/serve-api.md#per-stage-presets-and-custom-configurations). * **Per-stage presets and custom configurations on `ConvertDocumentOptions`** — Eight pipeline stages (layout, OCR, table structure, picture description, picture classification, code & formula, chart extraction and the VLM pipeline) can now be tuned from Java, each through a `Preset` string or a `CustomConfig` map, for example `ocrPreset("easyocr")` or `layoutCustomConfigEntry("kind", "docling_layout_default")`. Presets are plain strings because the available ids are set by the Docling Serve deployment, so not even `"default"` is registered for every stage on every image. A custom config is a `Map` with a stage-specific schema, in one of two shapes: the kind-selected stages (layout, OCR, table structure, picture classification) pick an implementation through a `kind` entry, while the VLM-backed stages (picture description, code & formula, chart extraction, VLM pipeline) take `model_spec` and `engine_options` entries instead. The preset and the custom config are mutually exclusive per stage — a custom config replaces the preset rather than overriding it. These supersede `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi` and the `vlmPipelineModel*` options, which Docling Serve marks as deprecated. * **The options Docling Serve deprecates are now `@Deprecated` in Java** — `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi`, `vlmPipelineModel`, `vlmPipelineModelLocal` and `vlmPipelineModelApi` carry `@Deprecated(since = "0.7.3")`, which Lombok copies onto both the getter and the builder setter, so setting one produces a compiler warning pointing at the preset or custom-config replacement. They are deliberately **not** marked `forRemoval`: these options still work, and when they are removed is Docling Serve's decision rather than this library's. The four types that are only reachable through those options — `OcrEngine`, `VlmModelType`, `PictureDescriptionLocal` and `PictureDescriptionApi` — are marked `@Deprecated` as well, so the warning also appears at `PictureDescriptionApi.builder()` rather than only at the setter. From 1e0bff6fbfff080cd9781f4fb37edbe71118c0df Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Tue, 1 Dec 2026 15:40:16 -0500 Subject: [PATCH 3/3] docs(api): correct chunking support scope to include ZIP targets The previous javadoc/whats-new.md fix overcorrected: chunk output is dropped only for a single-document InBodyTarget. Docling Serve also writes a *.chunks.jsonl file into the ZIP archive for ZipTarget and multi-document InBodyTarget requests, confirmed against the same docling-serve v1.41.0 container used to verify the earlier fix. Related to #821, #822. Assisted-By: Claude Code Signed-off-by: Eric Deandrea --- .../request/options/ConvertDocumentOptions.java | 11 +++++++---- docs/src/doc/docs/whats-new.md | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java index 8bb3338f..65980cfc 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java @@ -433,8 +433,10 @@ public class ConvertDocumentOptions { /** * Preset id for the chunker, for example {@code granite_embedding_278m}, registered by the Docling Serve deployment's chunker manager. This is a deployment-specific identifier, * not the {@code chunker} discriminator used by {@link ai.docling.serve.api.chunk.request.options.ChunkerOptions} (e.g. {@code hybrid}/{@code hierarchical}). Mutually exclusive - * with {@link #getChunkingOptions()}. Only takes effect when {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}, and only with a presigned target — Docling Serve - * silently omits chunk output when chunking is requested with a single-document in-body target. + * with {@link #getChunkingOptions()}. Only takes effect when {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}, and only with a presigned target or a target that + * produces a ZIP archive (a {@link ai.docling.serve.api.convert.request.target.ZipTarget}, or multiple source documents with an + * {@link ai.docling.serve.api.convert.request.target.InBodyTarget}) — Docling Serve silently omits chunk output when chunking is requested with a single-document in-body + * target. */ @JsonProperty("chunking_preset") @Nullable @@ -442,8 +444,9 @@ public class ConvertDocumentOptions { /** * Chunker configuration for convert-side chunking, performed in the same pass as the conversion. Mutually exclusive with {@link #getChunkingPreset()}. Only takes effect when - * {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}, and only with a presigned target — Docling Serve silently omits chunk output when chunking is requested with a - * single-document in-body target. + * {@link #getToFormats()} includes {@link OutputFormat#CHUNKS}, and only with a presigned target or a target that produces a ZIP archive (a + * {@link ai.docling.serve.api.convert.request.target.ZipTarget}, or multiple source documents with an {@link ai.docling.serve.api.convert.request.target.InBodyTarget}) — + * Docling Serve silently omits chunk output when chunking is requested with a single-document in-body target. */ @JsonProperty("chunking_options") @Nullable diff --git a/docs/src/doc/docs/whats-new.md b/docs/src/doc/docs/whats-new.md index 3a9e44a8..b9cb08ad 100644 --- a/docs/src/doc/docs/whats-new.md +++ b/docs/src/doc/docs/whats-new.md @@ -27,7 +27,7 @@ Docling Java {{ gradle.project_version }} includes important breaking changes, a ### {{ gradle.project_version }} * **`OutputFormat` gains `YAML`, `VTT`, `DOCLANG`, `DCLX` and `LATEX`** — These were missing from the enum, so Docling Serve rejected `toFormats`/`toFormat` requests for them even though the server supports them. `DocumentResponse` also gains a `doclangContent` accessor, mirroring `doctagsContent`/`htmlContent`/etc., since Docling Serve returns `doclang_content` inline the same way it does for the existing formats. `DCLX` has no inline content field but is exported as a file, reachable through file-based targets such as a zip archive or a presigned URL. `YAML`, `VTT`, and `LATEX` are accepted by the server's request validation but currently have no implemented export at all, inline or file — requesting them succeeds but produces nothing for those formats. -* **Convert-side chunking** — Docling Serve can chunk a document in the same pass as the conversion, instead of converting and then sending the result to `/chunk`. `OutputFormat` gains `CHUNKS`, which must be included in `toFormats`/`toFormat` to activate it, and `ConvertDocumentOptions` gains `chunkingPreset` (`String`, a deployment-registered preset id such as `granite_embedding_278m`) and `chunkingOptions` (the existing `ChunkerOptions` used by the `/chunk` endpoint), mutually exclusive, configuring the chunker. With a presigned target, the chunks file comes back as a `chunks` artifact on a `DocumentArtifactItem`, which required adding `ArtifactType.CHUNKS`. Docling Serve silently omits chunk output when `chunks` is requested together with a single-document in-body target, so this option only has an effect with a presigned target. +* **Convert-side chunking** — Docling Serve can chunk a document in the same pass as the conversion, instead of converting and then sending the result to `/chunk`. `OutputFormat` gains `CHUNKS`, which must be included in `toFormats`/`toFormat` to activate it, and `ConvertDocumentOptions` gains `chunkingPreset` (`String`, a deployment-registered preset id such as `granite_embedding_278m`) and `chunkingOptions` (the existing `ChunkerOptions` used by the `/chunk` endpoint), mutually exclusive, configuring the chunker. With a presigned target, the chunks file comes back as a `chunks` artifact on a `DocumentArtifactItem`, which required adding `ArtifactType.CHUNKS`. With a target that produces a ZIP archive (a `ZipTarget`, or multiple source documents with an `InBodyTarget`), the chunks come back as a `*.chunks.jsonl` file alongside the other per-document output files inside the archive. Docling Serve silently omits chunk output when `chunks` is requested together with a single-document in-body target, so this option has no effect in that one case. * **`docling-testcontainers` default image bumped to `v1.41.0`** — `DoclingServeContainerConfig.DOCLING_IMAGE` now pins `ghcr.io/docling-project/docling-serve:v1.41.0` (previously `v1.35.0`). `ConvertDocumentOptions` is unchanged across this range, but one behavioral difference will show up for consumers relying on the previous default: a single-file conversion with `ZipTarget` now names the archive after the source file (e.g. `2408.09869.zip`) instead of the generic `converted_docs.zip`; multi-file conversions are unaffected. Preset registration remains image-specific — see the warning in [Per-stage presets and custom configurations](docling-serve/serve-api.md#per-stage-presets-and-custom-configurations). * **Per-stage presets and custom configurations on `ConvertDocumentOptions`** — Eight pipeline stages (layout, OCR, table structure, picture description, picture classification, code & formula, chart extraction and the VLM pipeline) can now be tuned from Java, each through a `Preset` string or a `CustomConfig` map, for example `ocrPreset("easyocr")` or `layoutCustomConfigEntry("kind", "docling_layout_default")`. Presets are plain strings because the available ids are set by the Docling Serve deployment, so not even `"default"` is registered for every stage on every image. A custom config is a `Map` with a stage-specific schema, in one of two shapes: the kind-selected stages (layout, OCR, table structure, picture classification) pick an implementation through a `kind` entry, while the VLM-backed stages (picture description, code & formula, chart extraction, VLM pipeline) take `model_spec` and `engine_options` entries instead. The preset and the custom config are mutually exclusive per stage — a custom config replaces the preset rather than overriding it. These supersede `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi` and the `vlmPipelineModel*` options, which Docling Serve marks as deprecated. * **The options Docling Serve deprecates are now `@Deprecated` in Java** — `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi`, `vlmPipelineModel`, `vlmPipelineModelLocal` and `vlmPipelineModelApi` carry `@Deprecated(since = "0.7.3")`, which Lombok copies onto both the getter and the builder setter, so setting one produces a compiler warning pointing at the preset or custom-config replacement. They are deliberately **not** marked `forRemoval`: these options still work, and when they are removed is Docling Serve's decision rather than this library's. The four types that are only reachable through those options — `OcrEngine`, `VlmModelType`, `PictureDescriptionLocal` and `PictureDescriptionApi` — are marked `@Deprecated` as well, so the warning also appears at `PictureDescriptionApi.builder()` rather than only at the setter.