Class WatsonxGatewayStreamingChatModel.Builder

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

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

    • serviceTier

      protected com.ibm.watsonx.ai.gateway.chat.ModelGatewayParameters.ServiceTier serviceTier
    • reasoningEffort

      protected com.ibm.watsonx.ai.gateway.chat.ModelGatewayParameters.ReasoningEffort reasoningEffort
    • router

      protected com.ibm.watsonx.ai.gateway.chat.ModelGatewayParameters.Router router
    • modalities

      protected List<String> modalities
    • store

      protected Boolean store
    • parallelToolCalls

      protected Boolean parallelToolCalls
    • user

      protected String user
    • metadata

      protected Map<String,String> metadata
    • modelName

      protected String modelName
    • temperature

      protected Double temperature
    • topP

      protected Double topP
    • frequencyPenalty

      protected Double frequencyPenalty
    • presencePenalty

      protected Double presencePenalty
    • maxOutputTokens

      protected Integer maxOutputTokens
    • stopSequences

      protected List<String> stopSequences
    • toolChoice

      protected ToolChoice toolChoice
    • responseFormat

      protected ResponseFormat responseFormat
    • strictJsonSchema

      protected Boolean strictJsonSchema
    • toolSpecifications

      protected List<ToolSpecification> toolSpecifications
    • listeners

      protected List<ChatModelListener> listeners
    • defaultRequestParameters

      protected ChatRequestParameters defaultRequestParameters
    • supportedCapabilities

      protected Set<Capability> supportedCapabilities
    • logitBias

      protected Map<String,Integer> logitBias
    • logprobs

      protected Boolean logprobs
    • topLogprobs

      protected Integer topLogprobs
    • seed

      protected Integer seed
    • toolChoiceName

      protected String toolChoiceName
    • baseUrl

      protected URI baseUrl
    • version

      protected String version
    • apiKey

      protected String apiKey
    • 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

    • build

    • modelName

      public WatsonxGatewayStreamingChatModel.Builder modelName(String modelName)
      Sets the gateway model id, e.g. "gpt-4o".
      Parameters:
      modelName - the model id
      Returns:
      this
    • serviceTier

      public WatsonxGatewayStreamingChatModel.Builder serviceTier(com.ibm.watsonx.ai.gateway.chat.ModelGatewayParameters.ServiceTier serviceTier)
      Sets the service tier used to process the request.
      Parameters:
      serviceTier - the ModelGatewayParameters.ServiceTier
      Returns:
      this
    • reasoningEffort

      public WatsonxGatewayStreamingChatModel.Builder reasoningEffort(com.ibm.watsonx.ai.gateway.chat.ModelGatewayParameters.ReasoningEffort reasoningEffort)
      Sets the reasoning effort constraint for reasoning models.
      Parameters:
      reasoningEffort - the ModelGatewayParameters.ReasoningEffort
      Returns:
      this
    • router

      public WatsonxGatewayStreamingChatModel.Builder router(com.ibm.watsonx.ai.gateway.chat.ModelGatewayParameters.Router router)
      Sets the model routing configuration for the request.
      Parameters:
      router - the ModelGatewayParameters.Router
      Returns:
      this
    • cache

      public WatsonxGatewayStreamingChatModel.Builder cache(com.ibm.watsonx.ai.gateway.chat.ModelGatewayParameters.Cache cache)
      Convenience for router(new Router(cache)). Caching is only honored on non-streaming requests.
      Parameters:
      cache - the ModelGatewayParameters.Cache configuration
      Returns:
      this
    • modalities

      public WatsonxGatewayStreamingChatModel.Builder modalities(List<String> modalities)
      Sets the requested output modalities (e.g. ["text"]).
      Parameters:
      modalities - the modalities
      Returns:
      this
    • store

      Sets whether the output should be stored for model distillation or evals.
      Parameters:
      store - true to store the output
      Returns:
      this
    • parallelToolCalls

      public WatsonxGatewayStreamingChatModel.Builder parallelToolCalls(Boolean parallelToolCalls)
      Enables or disables parallel function calling during tool use.
      Parameters:
      parallelToolCalls - true to enable, false to disable
      Returns:
      this
    • user

      Sets the end-user identifier for abuse monitoring.
      Parameters:
      user - the user identifier
      Returns:
      this
    • metadata

      Sets developer-defined tags and values used for filtering completions.
      Parameters:
      metadata - the metadata map
      Returns:
      this
    • temperature

      public WatsonxGatewayStreamingChatModel.Builder temperature(Double temperature)
      Sets the sampling temperature in the range [0.0, 2.0].
      Parameters:
      temperature - the sampling temperature
      Returns:
      this
    • topP

      Sets the nucleus sampling probability in the range (0.0, 1.0]
      Parameters:
      topP - the nucleus sampling threshold
      Returns:
      this
    • frequencyPenalty

      public WatsonxGatewayStreamingChatModel.Builder frequencyPenalty(Double frequencyPenalty)
      Sets the frequency penalty in the range [-2.0, 2.0].
      Parameters:
      frequencyPenalty - the frequency penalty
      Returns:
      this
    • presencePenalty

      public WatsonxGatewayStreamingChatModel.Builder presencePenalty(Double presencePenalty)
      Sets the presence penalty in the range [-2.0, 2.0].
      Parameters:
      presencePenalty - the presence penalty
      Returns:
      this
    • maxOutputTokens

      public WatsonxGatewayStreamingChatModel.Builder maxOutputTokens(Integer maxOutputTokens)
      Sets the maximum number of tokens to generate in the response.
      Parameters:
      maxOutputTokens - the maximum number of output tokens
      Returns:
      this
    • stopSequences

      public WatsonxGatewayStreamingChatModel.Builder stopSequences(List<String> stopSequences)
      Sets the sequences that will stop generation when encountered.
      Parameters:
      stopSequences - the stop sequences
      Returns:
      this
    • stopSequences

      public WatsonxGatewayStreamingChatModel.Builder stopSequences(String... stopSequences)
      Sets the sequences that will stop generation when encountered.
      Parameters:
      stopSequences - the stop sequences
      Returns:
      this
    • toolChoice

      public WatsonxGatewayStreamingChatModel.Builder toolChoice(ToolChoice toolChoice)
      Sets how the model selects tools. Controls whether tool use is automatic, forced, or disabled.
      Parameters:
      toolChoice - the tool choice mode
      Returns:
      this
    • responseFormat

      public WatsonxGatewayStreamingChatModel.Builder responseFormat(ResponseFormat responseFormat)
      Sets the response format to control structured output, e.g. JSON mode.
      Parameters:
      responseFormat - the response format
      Returns:
      this
    • strictJsonSchema

      public WatsonxGatewayStreamingChatModel.Builder strictJsonSchema(Boolean strictJsonSchema)
      Enables the strict mode for the JSON Schema used by structured outputs. Defaults to true.

      In strict mode the model is required to adhere to the schema, every property is marked as required and additionalProperties is set to false. Set it to false to let the model treat the schema as a hint instead of a constraint.

      Parameters:
      strictJsonSchema - true to enable the strict mode
      Returns:
      this
    • toolSpecifications

      public WatsonxGatewayStreamingChatModel.Builder toolSpecifications(List<ToolSpecification> toolSpecifications)
      Sets the tool definitions available to the model for function calling.
      Parameters:
      toolSpecifications - the list of tool specifications
      Returns:
      this
    • toolSpecifications

      public WatsonxGatewayStreamingChatModel.Builder toolSpecifications(ToolSpecification... toolSpecifications)
      Sets the tool definitions available to the model for function calling.
      Parameters:
      toolSpecifications - the tool specifications
      Returns:
      this
    • listeners

      Sets the list of ChatModelListener instances for observing chat model interactions.
      Parameters:
      listeners - the listeners to register
      Returns:
      this
    • defaultRequestParameters

      public WatsonxGatewayStreamingChatModel.Builder defaultRequestParameters(ChatRequestParameters defaultRequestParameters)
      Sets default request parameters that are merged into every chat request.
      Parameters:
      defaultRequestParameters - the default request parameters
      Returns:
      this
    • supportedCapabilities

      public WatsonxGatewayStreamingChatModel.Builder supportedCapabilities(Set<Capability> supportedCapabilities)
      Declares the capabilities supported by this model instance.
      Parameters:
      supportedCapabilities - the set of supported capabilities
      Returns:
      this
    • supportedCapabilities

      public WatsonxGatewayStreamingChatModel.Builder supportedCapabilities(Capability... supportedCapabilities)
      Declares the capabilities supported by this model instance.
      Parameters:
      supportedCapabilities - the supported capabilities
      Returns:
      this
    • logitBias

      Sets per-token logit biases to increase or decrease the likelihood of specific tokens. Keys are token IDs; values are bias offsets in the range [-100, 100].
      Parameters:
      logitBias - the logit bias map
      Returns:
      this
    • logprobs

      Enables returning log probabilities of the output tokens.
      Parameters:
      logprobs - true to include log probabilities in the response
      Returns:
      this
    • topLogprobs

      public WatsonxGatewayStreamingChatModel.Builder topLogprobs(Integer topLogprobs)
      Sets the number of most likely tokens to return log probabilities for at each position. Requires logprobs to be true. Value must be between 0 and 20.
      Parameters:
      topLogprobs - the number of top log probabilities to return
      Returns:
      this
    • seed

      Sets the random seed for deterministic sampling. Using the same seed and parameters should produce the same output across calls.
      Parameters:
      seed - the random seed
      Returns:
      this
    • toolChoiceName

      public WatsonxGatewayStreamingChatModel.Builder toolChoiceName(String toolChoiceName)
      Sets the name of the specific tool to force when toolChoice is set to force a particular tool.
      Parameters:
      toolChoiceName - the tool name to force
      Returns:
      this
    • baseUrl

      public WatsonxGatewayStreamingChatModel.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

      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 a URI.
      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

      public WatsonxGatewayStreamingChatModel.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 WatsonxGatewayStreamingChatModel.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

      Sets the HTTP request timeout. Defaults to 60 seconds.
      Parameters:
      timeout - the request timeout
      Returns:
      this
    • authenticator

      public WatsonxGatewayStreamingChatModel.Builder authenticator(com.ibm.watsonx.ai.core.auth.Authenticator authenticator)
      Sets a custom Authenticator for generating bearer tokens.
      Parameters:
      authenticator - the authenticator
      Returns:
      this
    • httpClient

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

      public WatsonxGatewayStreamingChatModel.Builder verifySsl(boolean verifySsl)
      Controls whether SSL certificate verification is performed. Defaults to true.
      Parameters:
      verifySsl - false to disable SSL verification
      Returns:
      this