Class WatsonxGatewayEmbeddingModel.Builder
java.lang.Object
dev.langchain4j.model.watsonx.WatsonxGatewayEmbeddingModel.Builder
- Enclosing class:
WatsonxGatewayEmbeddingModel
Builder class for constructing
WatsonxGatewayEmbeddingModel instances with configurable parameters.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionSets the IBM Cloud API key used to generate IAM access tokens for authentication.authenticator(com.ibm.watsonx.ai.core.auth.Authenticator authenticator) Sets a customAuthenticatorfor generating bearer tokens.baseUrl(com.ibm.watsonx.ai.CloudRegion baseUrl) Sets the IBM watsonx.ai endpoint from a predefinedCloudRegion.Sets the base URL of the IBM watsonx.ai API.Sets the base URL of the IBM watsonx.ai API as aURI.build()dimensions(Integer dimensions) Sets the number of dimensions of the returned embeddings.encodingFormat(com.ibm.watsonx.ai.gateway.embedding.ModelGatewayEmbeddingParameters.EncodingFormat encodingFormat) Sets the wire format of the returned embeddings.encodingFormat(String encodingFormat) Sets the wire format of the returned embeddings as a raw string, for the formats thatModelGatewayEmbeddingParameters.EncodingFormatdoes not cover yet.httpClient(HttpClient httpClient) Sets a customHttpClientto use for all API calls.listeners(List<EmbeddingModelListener> listeners) Sets theEmbeddingModelListeners notified around every embedding request.logRequests(Boolean logRequests) Enables debug logging of request bodies sent to the watsonx.ai API.logResponses(Boolean logResponses) Enables debug logging of response bodies received from the watsonx.ai API.Sets the gateway embedding model id, e.g.Sets the HTTP request timeout.Sets the identifier of the end user, used for abuse monitoring.verifySsl(boolean verifySsl) Controls whether SSL certificate verification is performed.Sets the watsonx.ai API version date, e.g.
-
Field Details
-
baseUrl
-
version
-
apiKey
-
logRequests
-
logResponses
-
timeout
-
authenticator
protected com.ibm.watsonx.ai.core.auth.Authenticator authenticator -
httpClient
-
verifySsl
protected boolean verifySsl
-
-
Method Details
-
modelName
Sets the gateway embedding model id, e.g."text-embedding-3-small".- Parameters:
modelName- the model id- Returns:
this
-
dimensions
Sets the number of dimensions of the returned embeddings. Only the models that support it accept this value.- Parameters:
dimensions- the number of dimensions- Returns:
this
-
encodingFormat
public WatsonxGatewayEmbeddingModel.Builder encodingFormat(com.ibm.watsonx.ai.gateway.embedding.ModelGatewayEmbeddingParameters.EncodingFormat encodingFormat) Sets the wire format of the returned embeddings. The SDK decodesModelGatewayEmbeddingParameters.EncodingFormat.BASE64for you, so both formats give the same vectors.- Parameters:
encodingFormat- theModelGatewayEmbeddingParameters.EncodingFormat- Returns:
this
-
encodingFormat
Sets the wire format of the returned embeddings as a raw string, for the formats thatModelGatewayEmbeddingParameters.EncodingFormatdoes not cover yet.- Parameters:
encodingFormat- the encoding format- Returns:
this
-
user
Sets the identifier of the end user, used for abuse monitoring.- Parameters:
user- the user identifier- Returns:
this
-
listeners
Sets theEmbeddingModelListeners notified around every embedding request.- Parameters:
listeners- the listeners to register- Returns:
this
-
build
-
baseUrl
Sets the IBM watsonx.ai endpoint from a predefinedCloudRegion.- Parameters:
baseUrl- the IBM Cloud region whose ML endpoint will be used- Returns:
this
-
baseUrl
Sets the base URL of the IBM watsonx.ai API.- Parameters:
url- the base URL string, e.g."https://us-south.ml.cloud.ibm.com"- Returns:
this
-
baseUrl
Sets the base URL of the IBM watsonx.ai API as aURI.- Parameters:
url- the base URL URI- Returns:
this
-
version
Sets the watsonx.ai API version date, e.g."2024-05-31".- Parameters:
version- the API version date string- Returns:
this
-
apiKey
Sets the IBM Cloud API key used to generate IAM access tokens for authentication.- Parameters:
apiKey- the IBM Cloud API key- Returns:
this
-
logRequests
Enables debug logging of request bodies sent to the watsonx.ai API.- Parameters:
logRequests-trueto enable request logging- Returns:
this
-
logResponses
Enables debug logging of response bodies received from the watsonx.ai API.- Parameters:
logResponses-trueto enable response logging- Returns:
this
-
timeout
Sets the HTTP request timeout. Defaults to 60 seconds.- Parameters:
timeout- the request timeout- Returns:
this
-
authenticator
public WatsonxGatewayEmbeddingModel.Builder authenticator(com.ibm.watsonx.ai.core.auth.Authenticator authenticator) Sets a customAuthenticatorfor generating bearer tokens.- Parameters:
authenticator- the authenticator- Returns:
this
-
httpClient
Sets a customHttpClientto use for all API calls.- Parameters:
httpClient- the HTTP client- Returns:
this
-
verifySsl
Controls whether SSL certificate verification is performed. Defaults totrue.- Parameters:
verifySsl-falseto disable SSL verification- Returns:
this
-