Package io.github.jbastgen.stemma.app.ai
Record Class AiConfig
java.lang.Object
java.lang.Record
io.github.jbastgen.stemma.app.ai.AiConfig
- Record Components:
enabled- the master switch; off by defaultprovider- which kind of serviceendpoint- base URL of the web service (empty: the service's usual one)model- the model name sent with every requestaccountId- the account (Settings → Accounts) that holds the API key; empty for nonemaxPromptChars- the longest prompt that is sent; longer text is cutmaxTokens- the longest answer asked fortimeoutSeconds- how long a request may take, tries included per tryretries- how often a failed try (network error, 429, 5xx) is repeatedlocalOnly- only the local terminal tool and local URLs are allowedexcludePatterns- 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;$PROMPTis replaced by the prompt, else it goes to stdintoolWorkDir- 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 nonecustomHeaders-Name: valuelines for the custom service;$API_KEYis replacedcustomBody- request body template of the custom service;$PROMPT,$SYSTEM,$MODELare 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe patterns that are excluded unless the user changes them. -
Constructor Summary
ConstructorsConstructorDescriptionAiConfig(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 aAiConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theaccountIdrecord component.booleanWhether 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).Returns the value of thecustomAnswerPathrecord component.Returns the value of thecustomBodyrecord component.Returns the value of thecustomHeadersrecord component.booleanenabled()Returns the value of theenabledrecord component.endpoint()Returns the value of theendpointrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexcludePatternsrecord component.final inthashCode()Returns a hash code value for this object.booleanReturns the value of thelocalOnlyrecord component.intReturns the value of themaxPromptCharsrecord component.intReturns the value of themaxTokensrecord component.model()Returns the value of themodelrecord component.parsePatterns(String text) Splits a comma or line separated list of patterns.provider()Returns the value of theproviderrecord component.booleanReturns the value of theredactSecretsrecord component.intretries()Returns the value of theretriesrecord component.intReturns the value of thetimeoutSecondsrecord component.Returns the value of thetoolCommandrecord component.Returns the value of thetoolWorkDirrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
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 aAiConfigrecord class.- Parameters:
enabled- the value for theenabledrecord componentprovider- the value for theproviderrecord componentendpoint- the value for theendpointrecord componentmodel- the value for themodelrecord componentaccountId- the value for theaccountIdrecord componentmaxPromptChars- the value for themaxPromptCharsrecord componentmaxTokens- the value for themaxTokensrecord componenttimeoutSeconds- the value for thetimeoutSecondsrecord componentretries- the value for theretriesrecord componentlocalOnly- the value for thelocalOnlyrecord componentexcludePatterns- the value for theexcludePatternsrecord componentredactSecrets- the value for theredactSecretsrecord componenttoolCommand- the value for thetoolCommandrecord componenttoolWorkDir- the value for thetoolWorkDirrecord componentcustomHeaders- the value for thecustomHeadersrecord componentcustomBody- the value for thecustomBodyrecord componentcustomAnswerPath- the value for thecustomAnswerPathrecord 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
Splits a comma or line separated list of patterns. -
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
enabled
public boolean enabled()Returns the value of theenabledrecord component.- Returns:
- the value of the
enabledrecord component
-
provider
Returns the value of theproviderrecord component.- Returns:
- the value of the
providerrecord component
-
endpoint
Returns the value of theendpointrecord component.- Returns:
- the value of the
endpointrecord component
-
model
Returns the value of themodelrecord component.- Returns:
- the value of the
modelrecord component
-
accountId
Returns the value of theaccountIdrecord component.- Returns:
- the value of the
accountIdrecord component
-
maxPromptChars
public int maxPromptChars()Returns the value of themaxPromptCharsrecord component.- Returns:
- the value of the
maxPromptCharsrecord component
-
maxTokens
public int maxTokens()Returns the value of themaxTokensrecord component.- Returns:
- the value of the
maxTokensrecord component
-
timeoutSeconds
public int timeoutSeconds()Returns the value of thetimeoutSecondsrecord component.- Returns:
- the value of the
timeoutSecondsrecord component
-
retries
public int retries()Returns the value of theretriesrecord component.- Returns:
- the value of the
retriesrecord component
-
localOnly
public boolean localOnly()Returns the value of thelocalOnlyrecord component.- Returns:
- the value of the
localOnlyrecord component
-
excludePatterns
Returns the value of theexcludePatternsrecord component.- Returns:
- the value of the
excludePatternsrecord component
-
redactSecrets
public boolean redactSecrets()Returns the value of theredactSecretsrecord component.- Returns:
- the value of the
redactSecretsrecord component
-
toolCommand
Returns the value of thetoolCommandrecord component.- Returns:
- the value of the
toolCommandrecord component
-
toolWorkDir
Returns the value of thetoolWorkDirrecord component.- Returns:
- the value of the
toolWorkDirrecord component
-
customHeaders
Returns the value of thecustomHeadersrecord component.- Returns:
- the value of the
customHeadersrecord component
-
customBody
Returns the value of thecustomBodyrecord component.- Returns:
- the value of the
customBodyrecord component
-
customAnswerPath
Returns the value of thecustomAnswerPathrecord component.- Returns:
- the value of the
customAnswerPathrecord component
-