Class DoclingServeClient

java.lang.Object
org.apache.camel.component.docling.DoclingServeClient

public class DoclingServeClient extends Object
Client for interacting with Docling-Serve API.
  • Constructor Details

    • DoclingServeClient

      public DoclingServeClient(String baseUrl)
    • DoclingServeClient

      public DoclingServeClient(String baseUrl, AuthenticationScheme authenticationScheme, String authenticationToken, String apiKeyHeader)
    • DoclingServeClient

      public DoclingServeClient(String baseUrl, AuthenticationScheme authenticationScheme, String authenticationToken, String apiKeyHeader, String convertEndpoint)
    • DoclingServeClient

      public DoclingServeClient(String baseUrl, AuthenticationScheme authenticationScheme, String authenticationToken, String apiKeyHeader, String convertEndpoint, long asyncPollInterval, long asyncTimeout)
    • DoclingServeClient

      public DoclingServeClient(String baseUrl, AuthenticationScheme authenticationScheme, String authenticationToken, String apiKeyHeader, String convertEndpoint, long asyncPollInterval, long asyncTimeout, int maxTotalConnections, int maxConnectionsPerRoute, int connectionTimeout, int socketTimeout, int connectionRequestTimeout, long connectionTimeToLive, int validateAfterInactivity, boolean evictIdleConnections, long maxIdleTime)
  • Method Details

    • convertDocument

      public String convertDocument(String inputSource, String outputFormat) throws IOException
      Convert a document using the docling-serve API.
      Parameters:
      inputSource - File path or URL to the document
      outputFormat - Output format (md, json, html, text)
      Returns:
      Converted document content
      Throws:
      IOException - If the API call fails
    • convertDocumentAsync

      public String convertDocumentAsync(String inputSource, String outputFormat) throws IOException
      Convert a document using the docling-serve async API and return the task ID.
      Parameters:
      inputSource - File path or URL to the document
      outputFormat - Output format (md, json, html, text)
      Returns:
      Task ID for the async conversion
      Throws:
      IOException - If the API call fails
    • checkConversionStatus

      public ConversionStatus checkConversionStatus(String taskId) throws IOException
      Check the status of an async conversion task.
      Parameters:
      taskId - The task ID returned from convertDocumentAsync
      Returns:
      ConversionStatus object with current status
      Throws:
      IOException - If the API call fails
    • convertDocumentAsyncAndWait

      public String convertDocumentAsyncAndWait(String inputSource, String outputFormat) throws IOException
      Convert a document asynchronously and wait for completion by polling.
      Parameters:
      inputSource - File path or URL to the document
      outputFormat - Output format (md, json, html, text)
      Returns:
      Converted document content
      Throws:
      IOException - If the API call fails or timeout occurs
    • convertDocumentsBatch

      public BatchProcessingResults convertDocumentsBatch(List<String> inputSources, String outputFormat, int batchSize, int parallelism, boolean failOnFirstError, boolean useAsync, long batchTimeout)
      Convert multiple documents in batch using parallel processing.
      Parameters:
      inputSources - List of file paths or URLs to documents
      outputFormat - Output format (md, json, html, text)
      batchSize - Maximum number of documents in this batch
      parallelism - Number of parallel threads to use
      failOnFirstError - Whether to fail entire batch on first error
      useAsync - Whether to use async mode for individual conversions
      batchTimeout - Maximum time to wait for batch completion in milliseconds
      Returns:
      BatchProcessingResults containing all conversion results
    • extractMetadata

      public DocumentMetadata extractMetadata(String inputSource, boolean extractAll, boolean includeRawMetadata) throws IOException
      Extract metadata from a document using the docling-serve API.
      Parameters:
      inputSource - File path or URL to the document
      extractAll - Whether to extract all available metadata fields
      includeRawMetadata - Whether to include raw metadata in the response
      Returns:
      DocumentMetadata object with extracted metadata
      Throws:
      IOException - If the API call fails
    • close

      public void close() throws IOException
      Throws:
      IOException
    • getPoolStats

      public String getPoolStats()
      Get connection pool statistics for monitoring.
      Returns:
      Connection pool statistics as a formatted string