Class ChatConfig
java.lang.Object
uno.anahata.ai.config.ChatConfig
- Direct Known Subclasses:
SwingChatConfig
Base configuration class for a Gemini AI chat session.
This class defines the core settings, available tools, and context providers for a session. It also manages user preferences for tool execution (ALWAYS/NEVER).
Subclasses should provide the specific sessionId and can override
tool or provider lists as needed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<ContextProvider> The list of context providers registered for this configuration. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new ChatConfig and initializes the default set of context providers. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearFunctionConfirmation(com.google.genai.types.FunctionCall fc) Clears any stored user preferences for a specific tool call.getApi()Gets the Gemini API adapter associated with this configuration.longGets the initial delay for exponential backoff on API retries.Gets the name of the file where Gemini API keys are stored.longGets the maximum delay for exponential backoff on API retries.intGets the maximum number of retries for API calls.Gets the file used for automatic session backups.Gets the list of context providers.intGets the maximum number of consecutive failures allowed for a tool before it is blocked.longGets the time window within which failures are tracked for blocking.getFunctionConfirmation(com.google.genai.types.FunctionCall fc) Retrieves the stored user preference for a specific tool call.abstract StringGets the unique identifier for the chat session.com.google.genai.types.ContentGets the startup content to be sent to the model when the session is initialized.List<com.google.genai.types.Part> Reads startup instructions from astartup.mdfile in the working directory.Gets the list of Java classes containing methods annotated with@AIToolMethod.Deprecated.getWorkingFolder(String name) Deprecated.UseAnahataConfig.getWorkingFolder(String)directly.voidsetFunctionConfirmation(com.google.genai.types.FunctionCall fc, FunctionConfirmation confirmation) Stores a user preference for a specific tool call.
-
Field Details
-
providers
The list of context providers registered for this configuration.
-
-
Constructor Details
-
ChatConfig
public ChatConfig()Constructs a new ChatConfig and initializes the default set of context providers.
-
-
Method Details
-
getApi
Gets the Gemini API adapter associated with this configuration.- Returns:
- The GeminiAPI instance.
-
getSessionId
Gets the unique identifier for the chat session.- Returns:
- The session ID.
-
getAutobackupFile
Gets the file used for automatic session backups.- Returns:
- The autobackup File.
-
getContextProviders
Gets the list of context providers.- Returns:
- The list of ContextProvider instances.
-
getStartupContent
public com.google.genai.types.Content getStartupContent()Gets the startup content to be sent to the model when the session is initialized.- Returns:
- A Content object containing startup instructions.
-
getStartupParts
Reads startup instructions from astartup.mdfile in the working directory.- Returns:
- A list of Parts containing the startup text.
-
getToolClasses
-
getWorkingFolder
Deprecated.UseAnahataConfig.getWorkingFolder(String)directly.Gets a subfolder within the application's working directory.- Parameters:
name- The name of the subfolder.- Returns:
- The subfolder File.
-
getWorkingFolder
Deprecated.UseAnahataConfig.getWorkingFolder()directly.Gets the application's root working directory.- Returns:
- The working directory File.
-
getFunctionConfirmation
Retrieves the stored user preference for a specific tool call.- Parameters:
fc- The function call to check.- Returns:
- The stored FunctionConfirmation (ALWAYS/NEVER), or
nullif no preference exists.
-
setFunctionConfirmation
public void setFunctionConfirmation(com.google.genai.types.FunctionCall fc, FunctionConfirmation confirmation) Stores a user preference for a specific tool call. OnlyALWAYSandNEVERpreferences are persisted.- Parameters:
fc- The function call.confirmation- The preference to store.
-
clearFunctionConfirmation
public void clearFunctionConfirmation(com.google.genai.types.FunctionCall fc) Clears any stored user preferences for a specific tool call.- Parameters:
fc- The function call to clear preferences for.
-
getApiKeyFileName
Gets the name of the file where Gemini API keys are stored.- Returns:
- The API key file name.
-
getFailureTrackerMaxFailures
public int getFailureTrackerMaxFailures()Gets the maximum number of consecutive failures allowed for a tool before it is blocked.- Returns:
- The maximum failure count.
-
getFailureTrackerTimeWindowMs
public long getFailureTrackerTimeWindowMs()Gets the time window within which failures are tracked for blocking.- Returns:
- The time window in milliseconds.
-
getApiMaxRetries
public int getApiMaxRetries()Gets the maximum number of retries for API calls.- Returns:
- The maximum retry count.
-
getApiInitialDelayMillis
public long getApiInitialDelayMillis()Gets the initial delay for exponential backoff on API retries.- Returns:
- The initial delay in milliseconds.
-
getApiMaxDelayMillis
public long getApiMaxDelayMillis()Gets the maximum delay for exponential backoff on API retries.- Returns:
- The maximum delay in milliseconds.
-

AnahataConfig.getWorkingFolder()directly.