Class ChatConfig

java.lang.Object
uno.anahata.ai.config.ChatConfig
Direct Known Subclasses:
SwingChatConfig

public abstract class ChatConfig extends Object
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 Details

    • providers

      protected final List<ContextProvider> 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

      public GeminiAPI getApi()
      Gets the Gemini API adapter associated with this configuration.
      Returns:
      The GeminiAPI instance.
    • getSessionId

      public abstract String getSessionId()
      Gets the unique identifier for the chat session.
      Returns:
      The session ID.
    • getAutobackupFile

      public File getAutobackupFile()
      Gets the file used for automatic session backups.
      Returns:
      The autobackup File.
    • getContextProviders

      public List<ContextProvider> 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

      public List<com.google.genai.types.Part> getStartupParts()
      Reads startup instructions from a startup.md file in the working directory.
      Returns:
      A list of Parts containing the startup text.
    • getToolClasses

      public List<Class<?>> getToolClasses()
      Gets the list of Java classes containing methods annotated with @AIToolMethod. These classes define the tools available to the model.
      Returns:
      A list of tool classes.
    • getWorkingFolder

      @Deprecated public File getWorkingFolder(String name)
      Deprecated.
      Gets a subfolder within the application's working directory.
      Parameters:
      name - The name of the subfolder.
      Returns:
      The subfolder File.
    • getWorkingFolder

      @Deprecated public File getWorkingFolder()
      Deprecated.
      Gets the application's root working directory.
      Returns:
      The working directory File.
    • getFunctionConfirmation

      public FunctionConfirmation getFunctionConfirmation(com.google.genai.types.FunctionCall fc)
      Retrieves the stored user preference for a specific tool call.
      Parameters:
      fc - The function call to check.
      Returns:
      The stored FunctionConfirmation (ALWAYS/NEVER), or null if no preference exists.
    • setFunctionConfirmation

      public void setFunctionConfirmation(com.google.genai.types.FunctionCall fc, FunctionConfirmation confirmation)
      Stores a user preference for a specific tool call. Only ALWAYS and NEVER preferences 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

      public String 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.