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.
-
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
ConvertDocumentResponsecontaining the processed document data, processing details, and any errors. - 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.
-