Record Class AiConfig

java.lang.Object
java.lang.Record
io.github.jbastgen.stemma.app.ai.AiConfig
Record Components:
enabled - the master switch; off by default
provider - which kind of service
endpoint - base URL of the web service (empty: the service's usual one)
model - the model name sent with every request
accountId - the account (Settings → Accounts) that holds the API key; empty for none
maxPromptChars - the longest prompt that is sent; longer text is cut
maxTokens - the longest answer asked for
timeoutSeconds - how long a request may take, tries included per try
retries - how often a failed try (network error, 429, 5xx) is repeated
localOnly - only the local terminal tool and local URLs are allowed
excludePatterns - paths that are never sent (glob patterns on the path or the file name)
redactSecrets - replace obvious tokens and keys in outgoing text by ***
toolCommand - command line of the local tool; $PROMPT is replaced by the prompt, else it goes to stdin
toolWorkDir - working directory of the tool; empty, . or ./ = the repository the request is about (a relative path is taken from there); Stemma's configuration folder when there is none
customHeaders - Name: value lines for the custom service; $API_KEY is replaced
customBody - request body template of the custom service; $PROMPT, $SYSTEM, $MODEL are replaced by JSON strings (with quotes)
customAnswerPath - where in the JSON answer the text is, e.g. choices.0.message.content; empty = all

public record AiConfig(boolean enabled, AiProviderKind provider, String endpoint, String model, String accountId, int maxPromptChars, int maxTokens, int timeoutSeconds, int retries, boolean localOnly, List<String> excludePatterns, boolean redactSecrets, String toolCommand, String toolWorkDir, String customHeaders, String customBody, String customAnswerPath) extends Record
Everything the AI connection needs, as one immutable snapshot of the settings.
  • Field Details

    • DEFAULT_EXCLUDES

      public static final String DEFAULT_EXCLUDES
      The patterns that are excluded unless the user changes them.
      See Also:
  • Constructor Details

    • AiConfig

      public AiConfig(boolean enabled, AiProviderKind provider, String endpoint, String model, String accountId, int maxPromptChars, int maxTokens, int timeoutSeconds, int retries, boolean localOnly, List<String> excludePatterns, boolean redactSecrets, String toolCommand, String toolWorkDir, String customHeaders, String customBody, String customAnswerPath)
      Creates an instance of a AiConfig record class.
      Parameters:
      enabled - the value for the enabled record component
      provider - the value for the provider record component
      endpoint - the value for the endpoint record component
      model - the value for the model record component
      accountId - the value for the accountId record component
      maxPromptChars - the value for the maxPromptChars record component
      maxTokens - the value for the maxTokens record component
      timeoutSeconds - the value for the timeoutSeconds record component
      retries - the value for the retries record component
      localOnly - the value for the localOnly record component
      excludePatterns - the value for the excludePatterns record component
      redactSecrets - the value for the redactSecrets record component
      toolCommand - the value for the toolCommand record component
      toolWorkDir - the value for the toolWorkDir record component
      customHeaders - the value for the customHeaders record component
      customBody - the value for the customBody record component
      customAnswerPath - the value for the customAnswerPath record component
  • Method Details

    • configured

      public boolean configured()
      Whether the connection is set up enough to be tried: switched on, and what the kind of service needs is entered (a model name for a web service, the command line for a tool, the address for a custom service). It does not say that the connection works.
    • parsePatterns

      public static List<String> parsePatterns(String text)
      Splits a comma or line separated list of patterns.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component
    • provider

      public AiProviderKind provider()
      Returns the value of the provider record component.
      Returns:
      the value of the provider record component
    • endpoint

      public String endpoint()
      Returns the value of the endpoint record component.
      Returns:
      the value of the endpoint record component
    • model

      public String model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • accountId

      public String accountId()
      Returns the value of the accountId record component.
      Returns:
      the value of the accountId record component
    • maxPromptChars

      public int maxPromptChars()
      Returns the value of the maxPromptChars record component.
      Returns:
      the value of the maxPromptChars record component
    • maxTokens

      public int maxTokens()
      Returns the value of the maxTokens record component.
      Returns:
      the value of the maxTokens record component
    • timeoutSeconds

      public int timeoutSeconds()
      Returns the value of the timeoutSeconds record component.
      Returns:
      the value of the timeoutSeconds record component
    • retries

      public int retries()
      Returns the value of the retries record component.
      Returns:
      the value of the retries record component
    • localOnly

      public boolean localOnly()
      Returns the value of the localOnly record component.
      Returns:
      the value of the localOnly record component
    • excludePatterns

      public List<String> excludePatterns()
      Returns the value of the excludePatterns record component.
      Returns:
      the value of the excludePatterns record component
    • redactSecrets

      public boolean redactSecrets()
      Returns the value of the redactSecrets record component.
      Returns:
      the value of the redactSecrets record component
    • toolCommand

      public String toolCommand()
      Returns the value of the toolCommand record component.
      Returns:
      the value of the toolCommand record component
    • toolWorkDir

      public String toolWorkDir()
      Returns the value of the toolWorkDir record component.
      Returns:
      the value of the toolWorkDir record component
    • customHeaders

      public String customHeaders()
      Returns the value of the customHeaders record component.
      Returns:
      the value of the customHeaders record component
    • customBody

      public String customBody()
      Returns the value of the customBody record component.
      Returns:
      the value of the customBody record component
    • customAnswerPath

      public String customAnswerPath()
      Returns the value of the customAnswerPath record component.
      Returns:
      the value of the customAnswerPath record component