Class OpenAiChatCompletionsProviderPanel<P extends OpenAiChatCompletionsProvider>

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
Direct Known Subclasses:
OllamaAiProviderPanel

public class OpenAiChatCompletionsProviderPanel<P extends OpenAiChatCompletionsProvider> extends AbstractAiProviderPanel<P>
Specialized Swing configuration panel for OpenAI-compatible providers.

Exposes custom HTTP request headers and HTTP/1.1 protocol preference toggles.

Author:
anahata
See Also:
  • Field Details

    • customHeadersArea

      private JTextArea customHeadersArea
      Text area for multi-line custom HTTP header configuration.
    • preferHttp11Check

      private JCheckBox preferHttp11Check
      Toggle for forcing HTTP/1.1 on local inference servers and routers.
  • Constructor Details

    • OpenAiChatCompletionsProviderPanel

      public OpenAiChatCompletionsProviderPanel()
      Constructs a new uninitialized OpenAiChatCompletionsProviderPanel.
  • Method Details

    • init

      public void init(@NonNull @NonNull AbstractSwingAsiContainer container, @NonNull P provider, Runnable removeCallback)
      Initializes all UI components, listeners, and models table bound to the specified provider.

      Adds custom headers multi-line editor and prefer HTTP/1.1 checkbox.

      Overrides:
      init in class AbstractAiProviderPanel<P extends OpenAiChatCompletionsProvider>
      Parameters:
      container - The parent ASI container instance.
      provider - The provider instance to bind to.
      removeCallback - Callback to trigger when the user deletes the provider.
    • isModified

      public boolean isModified()
      Checks if any settings or API key text in the UI have been modified compared to the domain entity.

      Checks custom headers and prefer HTTP/1.1 modifications.

      Overrides:
      isModified in class AbstractAiProviderPanel<P extends OpenAiChatCompletionsProvider>
      Returns:
      true if there are unsaved modifications.
    • syncToProvider

      public void syncToProvider() throws IOException
      Synchronizes the UI state back to the provider domain and flushes the key pool to disk.

      Synchronizes custom headers and HTTP/1.1 preference.

      Overrides:
      syncToProvider in class AbstractAiProviderPanel<P extends OpenAiChatCompletionsProvider>
      Throws:
      IOException - If writing the keys file or syncing the provider state fails.
    • parseHeaders

      private Map<String,String> parseHeaders()
      Parses the raw lines in customHeadersArea into a key-value header map.
      Returns:
      The parsed header map.