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

java.lang.Object
io.helidon.integrations.langchain4j.providers.ollama.OllamaLanguageModelConfig.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:
OllamaLanguageModelConfig.Builder
Enclosing interface:
OllamaLanguageModelConfig

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

    • BuilderBase

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

    • from

      public BUILDER from(OllamaLanguageModelConfig 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(OllamaLanguageModelConfig.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 OllamaLanguageModelConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends OllamaLanguageModelConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • 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:
    • clearTopK

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

      public BUILDER topK(int topK)
      The maximum number of top-probability tokens to consider when generating text. Limits the token pool to the topK highest-probability tokens, controlling the balance between deterministic and diverse outputs.

      A smaller topK (e.g., 1) results in deterministic output, while a larger value (e.g., 50) allows for more variability and creativity.

      Parameters:
      topK - an Optional containing the topK value
      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:
    • clearRepeatPenalty

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

      public BUILDER repeatPenalty(double repeatPenalty)
      The penalty applied to repeated tokens during text generation. Higher values discourage the model from generating the same token multiple times, promoting more varied and natural output.

      A value of 1.0 applies no penalty (default behavior), while values greater than 1.0 reduce the likelihood of repetition. Excessively high values may overly penalize common phrases, leading to unnatural results.

      Parameters:
      repeatPenalty - an Optional containing the repeat penalty
      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:
    • clearNumPredict

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

      public BUILDER numPredict(int numPredict)
      The number of tokens to generate during text prediction. This parameter determines the length of the output generated by the model.
      Parameters:
      numPredict - an Optional containing the numPredicts 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:
    • clearFormat

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

      public BUILDER format(String format)
      The format of the generated output. This parameter specifies the structure or style of the text produced by the model, such as plain text, JSON, or a custom format.

      Common examples:

      • "plain": Generates unstructured plain text.
      • "json": Produces output formatted as a JSON object.
      • Custom values may be supported depending on the model's capabilities.
      Parameters:
      format - an Optional containing the response format
      Returns:
      updated builder instance
      See Also:
    • enabled

      public BUILDER enabled(boolean enabled)
      If set to false (default), Ollama model will not be available even if configured.
      Parameters:
      enabled - whether Ollama 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 Ollama API.
      Parameters:
      baseUrl - the base URL
      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:
    • 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:
    • clearModelName

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

      public BUILDER modelName(String modelName)
      The name of the Ollama model to use. This parameter determines which pre-trained model will process the input prompt and produce the output.

      Examples of valid model names:

      • "llama-2": Utilizes the LLaMA 2 model.
      • "alpaca": Uses a fine-tuned LLaMA model for conversational tasks.
      • "custom-model": A user-defined model trained for specific use cases.
      Parameters:
      modelName - an Optional containing the model name
      Returns:
      updated builder instance
      See Also:
    • 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
    • topK

      public Optional<Integer> topK()
      The maximum number of top-probability tokens to consider when generating text. Limits the token pool to the topK highest-probability tokens, controlling the balance between deterministic and diverse outputs.

      A smaller topK (e.g., 1) results in deterministic output, while a larger value (e.g., 50) allows for more variability and creativity.

      Returns:
      the top k
    • 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
    • repeatPenalty

      public Optional<Double> repeatPenalty()
      The penalty applied to repeated tokens during text generation. Higher values discourage the model from generating the same token multiple times, promoting more varied and natural output.

      A value of 1.0 applies no penalty (default behavior), while values greater than 1.0 reduce the likelihood of repetition. Excessively high values may overly penalize common phrases, leading to unnatural results.

      Returns:
      the repeat penalty
    • seed

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

      public Optional<Integer> numPredict()
      The number of tokens to generate during text prediction. This parameter determines the length of the output generated by the model.
      Returns:
      the num predict
    • stop

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

      public Optional<String> format()
      The format of the generated output. This parameter specifies the structure or style of the text produced by the model, such as plain text, JSON, or a custom format.

      Common examples:

      • "plain": Generates unstructured plain text.
      • "json": Produces output formatted as a JSON object.
      • Custom values may be supported depending on the model's capabilities.
      Returns:
      the format
    • enabled

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

      public Optional<String> baseUrl()
      The base URL for the Ollama API.
      Returns:
      the base url
    • 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
    • maxRetries

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

      public Optional<String> modelName()
      The name of the Ollama model to use. This parameter determines which pre-trained model will process the input prompt and produce the output.

      Examples of valid model names:

      • "llama-2": Utilizes the LLaMA 2 model.
      • "alpaca": Uses a fine-tuned LLaMA model for conversational tasks.
      • "custom-model": A user-defined model trained for specific use cases.
      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.