Class VoyageAiScoringModel.Builder
java.lang.Object
dev.langchain4j.model.voyageai.VoyageAiScoringModel.Builder
- Enclosing class:
VoyageAiScoringModel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the Voyage AI API key used to authenticate requests.Sets the base URL of the Voyage AI API.build()customHeaders(Supplier<Map<String, String>> customHeadersSupplier) Sets a supplier for custom HTTP headers.customHeaders(Map<String, String> customHeaders) Sets custom HTTP headers.httpClientBuilder(HttpClientBuilder httpClientBuilder) Sets a custom HTTP client builder, allowing fine-grained control over the HTTP client configuration such as timeouts and proxy settings.logger(org.slf4j.Logger logger) logRequests(Boolean logRequests) Enables debug logging of request bodies sent to the Voyage AI API.logResponses(Boolean logResponses) Enables debug logging of response bodies received from the Voyage AI API.maxRetries(Integer maxRetries) Sets the maximum number of retries on transient errors.modelName(VoyageAiScoringModelName modelName) Name of the model.Name of the model.Sets the HTTP request timeout.The number of most relevant documents to return.truncation(Boolean truncation) Whether to truncate the input to satisfy the "context length limit" on the query and the documents.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
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
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
Sets the base URL of the Voyage AI API. Defaults to"https://api.voyageai.com/v1/".- Parameters:
baseUrl- the base URL- Returns:
this
-
timeout
Sets the HTTP request timeout. Defaults to 60 seconds.- Parameters:
timeout- the request timeout- Returns:
this
-
maxRetries
Sets the maximum number of retries on transient errors. Defaults to3.- Parameters:
maxRetries- the maximum number of retries- Returns:
this
-
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
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
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
Enables debug logging of request bodies sent to the Voyage AI API.- Parameters:
logRequests-trueto enable request logging- Returns:
this
-
logResponses
Enables debug logging of response bodies received from the Voyage AI API.- Parameters:
logResponses-trueto enable response logging- Returns:
this
-
logger
- Parameters:
logger- an alternateLoggerto be used instead of the default one provided by Langchain4J for logging requests and responses.- Returns:
this.
-
build
-