Class DecisionDocumentReranker.Builder

java.lang.Object
org.springframework.ai.rag.postretrieval.document.DecisionDocumentReranker.Builder
Enclosing class:
DecisionDocumentReranker

public static final class DecisionDocumentReranker.Builder extends Object
Since:
2.1.0
  • Field Details

    • DEFAULT_CONCURRENCY

      public static final int DEFAULT_CONCURRENCY
      How many documents are judged at once unless an executor is given.
      See Also:
    • DEFAULT_TIMEOUT

      public static final Duration DEFAULT_TIMEOUT
      The timeout unless one is given.
  • Method Details

    • question

      public DecisionDocumentReranker.Builder question(YesNoQuestion question)
      Replaces the relevance question. Write it about query and passage, which are the two fields of the input.
      Parameters:
      question - the question
      Returns:
      this builder
    • options

      public DecisionDocumentReranker.Builder options(@Nullable DecisionOptions options)
      Options sent with every prompt, such as the model to use.
      Parameters:
      options - the options, or null for the model's defaults
      Returns:
      this builder
    • topK

      public DecisionDocumentReranker.Builder topK(int topK)
      Parameters:
      topK - how many documents to keep after reordering
      Returns:
      this builder
    • minimumScore

      public DecisionDocumentReranker.Builder minimumScore(double minimumScore)
      Drops documents whose score is below this value. At zero nothing is dropped and the reranker only reorders. Unscored documents are never dropped by it.
      Parameters:
      minimumScore - the lowest score worth keeping, between 0 and 1
      Returns:
      this builder
    • timeout

      public DecisionDocumentReranker.Builder timeout(Duration timeout)
      How long one request waits for all its documents to be judged, no matter how many there are. Documents still unjudged when the time is up are kept unscored, after the scored ones. Calls already running finish; calls still waiting in the queue are skipped. If you supply your own executor, it must not block when a call is submitted, because that blocked time cannot be cut short.
      Parameters:
      timeout - the timeout, positive
      Returns:
      this builder
    • concurrency

      public DecisionDocumentReranker.Builder concurrency(int concurrency)
      How many documents to judge at the same time. The limit is per instance, so it caps the calls in flight across all requests going through this reranker, which is what a provider rate limit needs. Ignored when an executor is given; the executor then sets its own limit.
      Parameters:
      concurrency - the number of calls in flight together, at least 1
      Returns:
      this builder
    • virtualThreads

      public DecisionDocumentReranker.Builder virtualThreads(boolean virtualThreads)
      Runs the per-document calls on virtual threads instead of platform threads, keeping the concurrency limit. Needs JDK 21 or later; on an older JDK build() fails. Ignored when an executor is given.
      Parameters:
      virtualThreads - whether to use virtual threads
      Returns:
      this builder
    • executor

      public DecisionDocumentReranker.Builder executor(Executor executor)
      Where the per-document calls run, for example a pool shared with the rest of the application or one backed by virtual threads.
      Parameters:
      executor - the executor
      Returns:
      this builder
    • build

      public DecisionDocumentReranker build()