Class OpenAiChatModelConfig.BuilderBase<BUILDER extends OpenAiChatModelConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends OpenAiChatModelConfig>

java.lang.Object
io.helidon.integrations.langchain4j.providers.openai.OpenAiChatModelConfig.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER,PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
OpenAiChatModelConfig.Builder
Enclosing interface:
OpenAiChatModelConfig

public abstract static class OpenAiChatModelConfig.BuilderBase<BUILDER extends OpenAiChatModelConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends OpenAiChatModelConfig> extends Object implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
Fluent API builder base for OpenAiChatModelConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(OpenAiChatModelConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(OpenAiChatModelConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface ConfigBuilderSupport.ConfiguredBuilder<BUILDER extends OpenAiChatModelConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends OpenAiChatModelConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • clearMaxRetries

      public BUILDER clearMaxRetries()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • maxRetries

      public BUILDER maxRetries(int maxRetries)
      The maximum number of retries for failed API requests.
      Parameters:
      maxRetries - an Optional containing the maximum number of retries
      Returns:
      updated builder instance
      See Also:
    • clearTemperature

      public BUILDER clearTemperature()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • temperature

      public BUILDER temperature(double temperature)
      The sampling temperature to use, between 0 and 2. Higher values make the output more random, while lower values make it more focused and deterministic.
      Parameters:
      temperature - an Optional containing the sampling temperature
      Returns:
      updated builder instance
      See Also:
    • clearTopP

      public BUILDER clearTopP()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • topP

      public BUILDER topP(double topP)
      The nucleus sampling value, where the model considers the results of the tokens with top_p probability mass.
      Parameters:
      topP - an Optional containing the nucleus sampling value
      Returns:
      updated builder instance
      See Also:
    • stop

      public BUILDER stop(List<String> stop)
      The list of sequences where the API will stop generating further tokens.
      Parameters:
      stop - the list of stop sequences
      Returns:
      updated builder instance
      See Also:
    • addStop

      public BUILDER addStop(List<String> stop)
      The list of sequences where the API will stop generating further tokens.
      Parameters:
      stop - the list of stop sequences
      Returns:
      updated builder instance
      See Also:
    • clearMaxTokens

      public BUILDER clearMaxTokens()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • maxTokens

      public BUILDER maxTokens(int maxTokens)
      The maximum number of tokens to generate in the completion.
      Parameters:
      maxTokens - an Optional containing the maximum number of tokens
      Returns:
      updated builder instance
      See Also:
    • clearMaxCompletionTokens

      public BUILDER clearMaxCompletionTokens()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • maxCompletionTokens

      public BUILDER maxCompletionTokens(int maxCompletionTokens)
      The maximum number of tokens allowed for the model's response.
      Parameters:
      maxCompletionTokens - an Optional containing the maximum number of completion tokens
      Returns:
      updated builder instance
      See Also:
    • clearPresencePenalty

      public BUILDER clearPresencePenalty()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • presencePenalty

      public BUILDER presencePenalty(double presencePenalty)
      The presence penalty, between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, encouraging the model to use new words.
      Parameters:
      presencePenalty - an Optional containing the presence penalty
      Returns:
      updated builder instance
      See Also:
    • clearFrequencyPenalty

      public BUILDER clearFrequencyPenalty()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • frequencyPenalty

      public BUILDER frequencyPenalty(double frequencyPenalty)
      The frequency penalty, between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line.
      Parameters:
      frequencyPenalty - an Optional containing the frequency penalty
      Returns:
      updated builder instance
      See Also:
    • logitBias

      public BUILDER logitBias(Map<String,Integer> logitBias)
      This method replaces all values with the new ones.
      Parameters:
      logitBias - a logitBias map
      Returns:
      updated builder instance
      See Also:
    • addLogitBias

      public BUILDER addLogitBias(Map<String,Integer> logitBias)
      This method keeps existing values, then puts all new values into the map.
      Parameters:
      logitBias - a logitBias map
      Returns:
      updated builder instance
      See Also:
    • putLogitBia

      public BUILDER putLogitBia(String key, Integer logitBia)
      This method adds a new value to the map, or replaces it if the key already exists.
      Parameters:
      key - key to add or replace
      logitBia - new value for the key
      Returns:
      updated builder instance
      See Also:
    • clearResponseFormat

      public BUILDER clearResponseFormat()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • responseFormat

      public BUILDER responseFormat(String responseFormat)
      The format in which the model should return the response.
      Parameters:
      responseFormat - an Optional containing the response format
      Returns:
      updated builder instance
      See Also:
    • clearStrictJsonSchema

      public BUILDER clearStrictJsonSchema()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • strictJsonSchema

      public BUILDER strictJsonSchema(boolean strictJsonSchema)
      Whether to enforce a strict JSON schema for the model's output.
      Parameters:
      strictJsonSchema - an Optional containing true if strict JSON schema is enforced, false otherwise
      Returns:
      updated builder instance
      See Also:
    • clearSeed

      public BUILDER clearSeed()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • seed

      public BUILDER seed(int seed)
      The seed for the random number generator used by the model.
      Parameters:
      seed - an Optional containing the seed
      Returns:
      updated builder instance
      See Also:
    • clearUser

      public BUILDER clearUser()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • user

      public BUILDER user(String user)
      The user ID associated with the API requests.
      Parameters:
      user - an Optional containing the user ID
      Returns:
      updated builder instance
      See Also:
    • clearStrictTools

      public BUILDER clearStrictTools()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • strictTools

      public BUILDER strictTools(boolean strictTools)
      Whether to enforce strict validation of tools used by the model.
      Parameters:
      strictTools - an Optional containing true if strict tools are enforced, false otherwise
      Returns:
      updated builder instance
      See Also:
    • clearParallelToolCalls

      public BUILDER clearParallelToolCalls()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • parallelToolCalls

      public BUILDER parallelToolCalls(boolean parallelToolCalls)
      Whether to allow parallel calls to tools.
      Parameters:
      parallelToolCalls - an Optional containing true if parallel tool calls are allowed, false otherwise
      Returns:
      updated builder instance
      See Also:
    • clearTokenizer

      public BUILDER clearTokenizer()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • tokenizer

      public BUILDER tokenizer(dev.langchain4j.model.Tokenizer tokenizer)
      Tokenizer to use.
      Parameters:
      tokenizer - an Optional containing the tokenizer
      Returns:
      updated builder instance
      See Also:
    • enabled

      public BUILDER enabled(boolean enabled)
      If set to false (default), OpenAI model will not be available even if configured.
      Parameters:
      enabled - whether OpenAI model is enabled, defaults to false
      Returns:
      updated builder instance
      See Also:
    • clearBaseUrl

      public BUILDER clearBaseUrl()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • baseUrl

      public BUILDER baseUrl(String baseUrl)
      The base URL for the OpenAI API.
      Parameters:
      baseUrl - the base URL
      Returns:
      updated builder instance
      See Also:
    • clearApiKey

      public BUILDER clearApiKey()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • apiKey

      public BUILDER apiKey(String apiKey)
      The API key used to authenticate requests to the OpenAI API.
      Parameters:
      apiKey - an Optional containing the API key
      Returns:
      updated builder instance
      See Also:
    • clearLogRequests

      public BUILDER clearLogRequests()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • logRequests

      public BUILDER logRequests(boolean logRequests)
      Whether to log API requests.
      Parameters:
      logRequests - an Optional containing true if requests should be logged, false otherwise
      Returns:
      updated builder instance
      See Also:
    • clearLogResponses

      public BUILDER clearLogResponses()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • logResponses

      public BUILDER logResponses(boolean logResponses)
      Whether to log API responses.
      Parameters:
      logResponses - an Optional containing true if responses should be logged, false otherwise
      Returns:
      updated builder instance
      See Also:
    • customHeaders

      public BUILDER customHeaders(Map<String,String> customHeaders)
      This method replaces all values with the new ones.
      Parameters:
      customHeaders - custom headers map
      Returns:
      updated builder instance
      See Also:
    • addCustomHeaders

      public BUILDER addCustomHeaders(Map<String,String> customHeaders)
      This method keeps existing values, then puts all new values into the map.
      Parameters:
      customHeaders - custom headers map
      Returns:
      updated builder instance
      See Also:
    • putCustomHeader

      public BUILDER putCustomHeader(String key, String customHeader)
      This method adds a new value to the map, or replaces it if the key already exists.
      Parameters:
      key - key to add or replace
      customHeader - new value for the key
      Returns:
      updated builder instance
      See Also:
    • clearTimeout

      public BUILDER clearTimeout()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • timeout

      public BUILDER timeout(Duration timeout)
      The timeout setting for API requests.
      Parameters:
      timeout - the timeout setting in Duration.parse(java.lang.CharSequence) format
      Returns:
      updated builder instance
      See Also:
    • clearProxy

      public BUILDER clearProxy()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • proxy

      public BUILDER proxy(Proxy proxy)
      Proxy to use.
      Parameters:
      proxy - an Optional containing HTTP proxy to use
      Returns:
      updated builder instance
      See Also:
    • clearOrganizationId

      public BUILDER clearOrganizationId()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • organizationId

      public BUILDER organizationId(String organizationId)
      The ID of the organization for API requests.
      Parameters:
      organizationId - organization ID
      Returns:
      updated builder instance
      See Also:
    • clearModelName

      public BUILDER clearModelName()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • modelName

      public BUILDER modelName(String modelName)
      The model name to use (e.g., "gpt-3.5-turbo").
      Parameters:
      modelName - the model name
      Returns:
      updated builder instance
      See Also:
    • maxRetries

      public Optional<Integer> maxRetries()
      The maximum number of retries for failed API requests.
      Returns:
      the max retries
    • temperature

      public Optional<Double> temperature()
      The sampling temperature to use, between 0 and 2. Higher values make the output more random, while lower values make it more focused and deterministic.
      Returns:
      the temperature
    • topP

      public Optional<Double> topP()
      The nucleus sampling value, where the model considers the results of the tokens with top_p probability mass.
      Returns:
      the top p
    • stop

      public List<String> stop()
      The list of sequences where the API will stop generating further tokens.
      Returns:
      the stop
    • maxTokens

      public Optional<Integer> maxTokens()
      The maximum number of tokens to generate in the completion.
      Returns:
      the max tokens
    • maxCompletionTokens

      public Optional<Integer> maxCompletionTokens()
      The maximum number of tokens allowed for the model's response.
      Returns:
      the max completion tokens
    • presencePenalty

      public Optional<Double> presencePenalty()
      The presence penalty, between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, encouraging the model to use new words.
      Returns:
      the presence penalty
    • frequencyPenalty

      public Optional<Double> frequencyPenalty()
      The frequency penalty, between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line.
      Returns:
      the frequency penalty
    • logitBias

      public Map<String,Integer> logitBias()
      LogitBias adjusts the likelihood of specific tokens appearing in a model's response. A map of token IDs to bias values (-100 to 100). Positive values increase the chance of the token, while negative values reduce it, allowing fine control over token preferences in the output.
      Returns:
      the logit bias
    • responseFormat

      public Optional<String> responseFormat()
      The format in which the model should return the response.
      Returns:
      the response format
    • strictJsonSchema

      public Optional<Boolean> strictJsonSchema()
      Whether to enforce a strict JSON schema for the model's output.
      Returns:
      the strict json schema
    • seed

      public Optional<Integer> seed()
      The seed for the random number generator used by the model.
      Returns:
      the seed
    • user

      public Optional<String> user()
      The user ID associated with the API requests.
      Returns:
      the user
    • strictTools

      public Optional<Boolean> strictTools()
      Whether to enforce strict validation of tools used by the model.
      Returns:
      the strict tools
    • parallelToolCalls

      public Optional<Boolean> parallelToolCalls()
      Whether to allow parallel calls to tools.
      Returns:
      the parallel tool calls
    • tokenizer

      public Optional<dev.langchain4j.model.Tokenizer> tokenizer()
      Tokenizer to use.
      Returns:
      the tokenizer
    • enabled

      public boolean enabled()
      If set to false (default), OpenAI model will not be available even if configured.
      Returns:
      the enabled
    • baseUrl

      public Optional<String> baseUrl()
      The base URL for the OpenAI API.
      Returns:
      the base url
    • apiKey

      public Optional<String> apiKey()
      The API key used to authenticate requests to the OpenAI API.
      Returns:
      the api key
    • logRequests

      public Optional<Boolean> logRequests()
      Whether to log API requests.
      Returns:
      the log requests
    • logResponses

      public Optional<Boolean> logResponses()
      Whether to log API responses.
      Returns:
      the log responses
    • customHeaders

      public Map<String,String> customHeaders()
      A map containing custom headers.
      Returns:
      the custom headers
    • timeout

      public Optional<Duration> timeout()
      The timeout setting for API requests.
      Returns:
      the timeout
    • proxy

      public Optional<Proxy> proxy()
      Proxy to use.
      Returns:
      the proxy
    • organizationId

      public Optional<String> organizationId()
      The ID of the organization for API requests.
      Returns:
      the organization id
    • modelName

      public Optional<String> modelName()
      The model name to use (e.g., "gpt-3.5-turbo").
      Returns:
      the model name
    • config

      public Optional<Config> config()
      If this instance was configured, this would be the config instance used.
      Returns:
      config node used to configure this builder, or empty if not configured
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.