Class VoyageAiScoringModel.Builder

java.lang.Object
dev.langchain4j.model.voyageai.VoyageAiScoringModel.Builder
Enclosing class:
VoyageAiScoringModel

public static class VoyageAiScoringModel.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • httpClientBuilder

      public VoyageAiScoringModel.Builder httpClientBuilder(HttpClientBuilder httpClientBuilder)
      Sets a custom HTTP client builder, allowing fine-grained control over the HTTP client configuration such as timeouts and proxy settings.
      Parameters:
      httpClientBuilder - the HTTP client builder
      Returns:
      this
    • customHeaders

      public VoyageAiScoringModel.Builder customHeaders(Map<String,String> customHeaders)
      Sets custom HTTP headers.
    • customHeaders

      public VoyageAiScoringModel.Builder customHeaders(Supplier<Map<String,String>> customHeadersSupplier)
      Sets a supplier for custom HTTP headers. The supplier is called before each request, allowing dynamic header values. For example, this is useful for OAuth2 tokens that expire and need refreshing.
    • baseUrl

      public VoyageAiScoringModel.Builder baseUrl(String baseUrl)
      Sets the base URL of the Voyage AI API. Defaults to "https://api.voyageai.com/v1/".
      Parameters:
      baseUrl - the base URL
      Returns:
      this
    • timeout

      public VoyageAiScoringModel.Builder timeout(Duration timeout)
      Sets the HTTP request timeout. Defaults to 60 seconds.
      Parameters:
      timeout - the request timeout
      Returns:
      this
    • maxRetries

      public VoyageAiScoringModel.Builder maxRetries(Integer maxRetries)
      Sets the maximum number of retries on transient errors. Defaults to 3.
      Parameters:
      maxRetries - the maximum number of retries
      Returns:
      this
    • apiKey

      public VoyageAiScoringModel.Builder apiKey(String apiKey)
      Sets the Voyage AI API key used to authenticate requests. See Voyage AI dashboard to obtain a key.
      Parameters:
      apiKey - the Voyage AI API key
      Returns:
      this
    • modelName

      Name of the model.
      Parameters:
      modelName - Name of the model.
      See Also:
    • modelName

      public VoyageAiScoringModel.Builder modelName(String modelName)
      Name of the model.
      Parameters:
      modelName - Name of the model.
      See Also:
    • topK

      The number of most relevant documents to return. If not specified, the reranking results of all documents will be returned.
      Parameters:
      topK - the number of most relevant documents to return.
    • truncation

      public VoyageAiScoringModel.Builder truncation(Boolean truncation)
      Whether to truncate the input to satisfy the "context length limit" on the query and the documents. Defaults to true.
      • If true, the query and documents will be truncated to fit within the context length limit, before processed by the reranker model.
      • If false, an error will be raised when the query exceeds 1000 tokens for rerank-lite-1 and 2000 tokens for rerank-1, or the sum of the number of tokens in the query and the number of tokens in any single document exceeds 4000 for rerank-lite-1 and 8000 for rerank-1.
      Parameters:
      truncation - Whether to truncate the input to satisfy the "context length limit" on the query and the documents.
    • logRequests

      public VoyageAiScoringModel.Builder logRequests(Boolean logRequests)
      Enables debug logging of request bodies sent to the Voyage AI API.
      Parameters:
      logRequests - true to enable request logging
      Returns:
      this
    • logResponses

      public VoyageAiScoringModel.Builder logResponses(Boolean logResponses)
      Enables debug logging of response bodies received from the Voyage AI API.
      Parameters:
      logResponses - true to enable response logging
      Returns:
      this
    • logger

      public VoyageAiScoringModel.Builder logger(org.slf4j.Logger logger)
      Parameters:
      logger - an alternate Logger to be used instead of the default one provided by Langchain4J for logging requests and responses.
      Returns:
      this.
    • build

      public VoyageAiScoringModel build()