Class WatsonxModerationModel.Builder

java.lang.Object
dev.langchain4j.model.watsonx.WatsonxModerationModel.Builder
Enclosing class:
WatsonxModerationModel

public static class WatsonxModerationModel.Builder extends Object
Builder class for constructing WatsonxModerationModel instances with configurable parameters.
  • Field Details

    • baseUrl

      protected URI baseUrl
    • version

      protected String version
    • apiKey

      protected String apiKey
    • projectId

      protected String projectId
    • spaceId

      protected String spaceId
    • logRequests

      protected Boolean logRequests
    • logResponses

      protected Boolean logResponses
    • timeout

      protected Duration timeout
    • authenticator

      protected com.ibm.watsonx.ai.core.auth.Authenticator authenticator
    • httpClient

      protected HttpClient httpClient
    • verifySsl

      protected boolean verifySsl
  • Method Details

    • detectors

      public WatsonxModerationModel.Builder detectors(List<com.ibm.watsonx.ai.detection.detector.BaseDetector> detectors)
      Sets the list of detectors to use.
      Parameters:
      detectors - the list of detectors
    • detectors

      public WatsonxModerationModel.Builder detectors(com.ibm.watsonx.ai.detection.detector.BaseDetector... detectors)
      Sets the list of detectors to use.
      Parameters:
      detectors - the list of detectors
    • listeners

      Sets the listeners for this moderation model.
      Parameters:
      listeners - the listeners.
      Returns:
      this.
    • build

      public WatsonxModerationModel build()
    • baseUrl

      public WatsonxModerationModel.Builder baseUrl(com.ibm.watsonx.ai.CloudRegion baseUrl)
      Sets the IBM watsonx.ai endpoint from a predefined CloudRegion.
      Parameters:
      baseUrl - the IBM Cloud region whose ML endpoint will be used
      Returns:
      this
    • baseUrl

      public WatsonxModerationModel.Builder baseUrl(String url)
      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

      public WatsonxModerationModel.Builder baseUrl(URI url)
      Sets the base URL of the IBM watsonx.ai API as a URI.
      Parameters:
      url - the base URL URI
      Returns:
      this
    • version

      public WatsonxModerationModel.Builder version(String version)
      Sets the watsonx.ai API version date, e.g. "2024-05-31".
      Parameters:
      version - the API version date string
      Returns:
      this
    • projectId

      public WatsonxModerationModel.Builder projectId(String projectId)
      Sets the IBM Cloud project ID that owns the watsonx.ai resources. Exactly one of projectId or spaceId must be set.
      Parameters:
      projectId - the IBM Cloud project ID
      Returns:
      this
    • spaceId

      public WatsonxModerationModel.Builder spaceId(String spaceId)
      Sets the IBM Cloud deployment space ID. Exactly one of projectId or spaceId must be set.
      Parameters:
      spaceId - the IBM Cloud deployment space ID
      Returns:
      this
    • apiKey

      public WatsonxModerationModel.Builder apiKey(String 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

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

      public WatsonxModerationModel.Builder logResponses(Boolean logResponses)
      Enables debug logging of response bodies received from the watsonx.ai API.
      Parameters:
      logResponses - true to enable response logging
      Returns:
      this
    • timeout

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

      public WatsonxModerationModel.Builder authenticator(com.ibm.watsonx.ai.core.auth.Authenticator authenticator)
      Sets a custom Authenticator for generating bearer tokens. Use this instead of apiKey when you need a non-standard authentication flow.
      Parameters:
      authenticator - the authenticator
      Returns:
      this
    • httpClient

      public WatsonxModerationModel.Builder httpClient(HttpClient httpClient)
      Sets a custom HttpClient to use for all API calls.
      Parameters:
      httpClient - the HTTP client
      Returns:
      this
    • verifySsl

      public WatsonxModerationModel.Builder verifySsl(boolean verifySsl)
      Controls whether SSL certificate verification is performed. Defaults to true. Set to false only in non-production environments.
      Parameters:
      verifySsl - false to disable SSL verification
      Returns:
      this