Package ai.docling.serve.api
Interface DoclingServeConvertApi
- All Known Subinterfaces:
DoclingServeApi
public interface DoclingServeConvertApi
Interface representing the Docling Serve Convert API.
This API is responsible for processing and converting document source(s) into
a structured or processed document format based on the specified conversion options.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ConvertDocumentResponseconvertFiles(@Nullable ConvertDocumentRequest request, Path... files) Converts the specified files into a processed document based on the options provided in the request.default ConvertDocumentResponseconvertFiles(Path... files) Converts the specified files into a processed document using default options.default CompletionStage<ConvertDocumentResponse>convertFilesAsync(@Nullable ConvertDocumentRequest request, Path... files) Initiates an asynchronous conversion of the specified files into a processed document using the provided conversion request options.default CompletionStage<ConvertDocumentResponse>convertFilesAsync(Path... files) Initiates an asynchronous conversion of the provided files into a processed document using default conversion options.convertSource(ConvertDocumentRequest request) Converts the provided document source(s) into a processed document based on the specified options.convertSourceAsync(ConvertDocumentRequest request) Initiates an asynchronous conversion of the provided document source(s) and returns aCompletionStagethat completes when the conversion is done.Submits a batch conversion request for processing multiple document sources asynchronously.Submits a batch conversion request and automatically polls for completion.
-
Method Details
-
convertSource
Converts the provided document source(s) into a processed document based on the specified options.- Parameters:
request- theConvertDocumentRequestcontaining the source(s), conversion options, and optional target.- Returns:
- a
ConvertDocumentResponsedescribing the convert document response. - Throws:
ValidationException- If request validation fails for any reason.
-
convertFiles
Converts the specified files into a processed document using default options. This is a convenience method that delegates toconvertFiles(ConvertDocumentRequest, Path...)with a null request.- Parameters:
files- an array ofPathobjects representing the file paths to be converted- Returns:
- a
ConvertDocumentResponsecontaining the processed document data, metadata, and any errors - Throws:
ValidationException- If request validation fails for any reason.
-
convertFiles
default ConvertDocumentResponse convertFiles(@Nullable ConvertDocumentRequest request, Path... files) Converts the specified files into a processed document based on the options provided in the request. If the request is null, default conversion options are applied.- Parameters:
request- an optionalConvertDocumentRequestspecifying conversion settings and parametersfiles- an array ofPathobjects representing the file paths to be converted- Returns:
- a
ConvertDocumentResponsecontaining the processed document data, any errors encountered, and additional processing metadata - Throws:
ValidationException- If request validation fails for any reason.
-
convertSourceAsync
Initiates an asynchronous conversion of the provided document source(s) and returns aCompletionStagethat completes when the conversion is done.This method starts the conversion, polls the status in the background, and completes the future with the result when the conversion finishes.
Example usage:
client.convertSourceAsync(request) .thenApply(response -> response.getDocument().getMarkdownContent()) .thenAccept(markdown -> System.out.println(markdown)) .exceptionally(ex -> { ex.printStackTrace(); return null; });- Parameters:
request- theConvertDocumentRequestcontaining the source(s) and conversion options.- Returns:
- a
CompletionStagethat completes with theConvertDocumentResponsewhen the conversion is finished, or completes exceptionally if the conversion fails or times out. - Throws:
ValidationException- If request validation fails for any reason.
-
convertFilesAsync
Initiates an asynchronous conversion of the provided files into a processed document using default conversion options.- Parameters:
files- an array ofPathobjects representing the file paths to be converted- Returns:
- a
CompletionStagethat completes with theConvertDocumentResponsewhen the conversion finishes, or completes exceptionally if the conversion fails or times out - Throws:
ValidationException- If request validation fails for any reason.
-
convertFilesAsync
default CompletionStage<ConvertDocumentResponse> convertFilesAsync(@Nullable ConvertDocumentRequest request, Path... files) Initiates an asynchronous conversion of the specified files into a processed document using the provided conversion request options. If the request is null, default conversion options are applied.- Parameters:
request- an optionalConvertDocumentRequestcontaining conversion settings and parameters, or null to use default optionsfiles- an array ofPathobjects representing the file paths to be converted- Returns:
- a
CompletionStagethat completes with theConvertDocumentResponsewhen the conversion finishes, or completes exceptionally if the conversion fails or times out - Throws:
ValidationException- If request validation fails for any reason.
-
convertSourceBatch
Submits a batch conversion request for processing multiple document sources asynchronously.This method posts the batch request to the server, which returns a task status containing a task ID. The caller can then use
DoclingServeTaskApi.pollTaskStatus(ai.docling.serve.api.task.request.TaskStatusPollRequest)andDoclingServeTaskApi.convertTaskResult(ai.docling.serve.api.task.request.TaskResultRequest)to track and retrieve results.- Parameters:
request- theBatchConvertDocumentRequestcontaining the sources, target, conversion options, and optional callbacks.- Returns:
- a
TaskStatusPollResponsecontaining the task ID and initial status. - Throws:
ValidationException- If request validation fails for any reason.
-
convertSourceBatchAsync
CompletionStage<ConvertDocumentResponse> convertSourceBatchAsync(BatchConvertDocumentRequest request) Submits a batch conversion request and automatically polls for completion.This method submits the batch request, polls the task status in the background, and completes the returned future with the conversion result when all documents have been processed.
Example usage:
client.convertSourceBatchAsync(request) .thenAccept(response -> System.out.println("Batch complete")) .exceptionally(ex -> { ex.printStackTrace(); return null; });- Parameters:
request- theBatchConvertDocumentRequestcontaining the sources, target, conversion options, and optional callbacks.- Returns:
- a
CompletionStagethat completes with theConvertDocumentResponsewhen all documents have been processed, or completes exceptionally if the batch conversion fails or times out. - Throws:
ValidationException- If request validation fails for any reason.
-