Class OllamaAiProviderPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class OllamaAiProviderPanel extends OpenAiChatCompletionsProviderPanel<OllamaAiProvider>
Specialized Swing configuration panel for Ollama AI providers.

In addition to standard OpenAI-compatible base URL and custom headers, this panel exposes Ollama-native diagnostics including server version detection, an active GPU VRAM and loaded model monitor (/api/ps), and on-demand VRAM unloading (keep_alive: 0).

Author:
anahata
See Also:
  • Field Details

    • versionLabel

      private JLabel versionLabel
      Label displaying the detected Ollama server version.
    • vramStatusLabel

      private JLabel vramStatusLabel
      Label displaying active models count in memory or idle notice.
    • runningModelsTable

      private JTable runningModelsTable
      Table displaying models currently loaded in host memory and GPU VRAM.
    • runningModelsTableModel

      private DefaultTableModel runningModelsTableModel
      Data model backing the running models table.
    • refreshRunningBtn

      private JButton refreshRunningBtn
      Button to refresh the active VRAM / running models list.
    • unloadModelBtn

      private JButton unloadModelBtn
      Button to unload the selected model from GPU memory.
    • pullModelBtn

      private JButton pullModelBtn
      Button to download and install a new model from ollama.com or custom tag.
    • pullProgressPanel

      private JPanel pullProgressPanel
      Visual container for in-flight model download progress.
    • pullStatusLabel

      private JLabel pullStatusLabel
      Label showing the status text of the active model pull.
    • pullProgressBar

      private JProgressBar pullProgressBar
      Progress bar displaying download percentage and bytes.
  • Constructor Details

    • OllamaAiProviderPanel

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

    • init

      public void init(@NonNull @NonNull AbstractSwingAsiContainer container, @NonNull @NonNull OllamaAiProvider 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.

      Enhances the panel with Ollama server version diagnostics and a live VRAM process monitor.

      Overrides:
      init in class OpenAiChatCompletionsProviderPanel<OllamaAiProvider>
      Parameters:
      container - The parent ASI container instance.
      provider - The provider instance to bind to.
      removeCallback - Callback to trigger when the user deletes the provider.
    • checkServerVersion

      private void checkServerVersion()
      Checks the running Ollama server version via OllamaAiProvider.getServerVersion() in a background task.
    • refreshRunningModels

      private void refreshRunningModels()
      Refreshes the running models loaded in memory via OllamaAiProvider.getRunningModels() in a background task.
    • unloadSelectedModel

      private void unloadSelectedModel()
      Unloads the selected model from memory by sending keep_alive: 0.
    • showPullModelDialog

      private void showPullModelDialog()
      Queries ollama.com tags and displays the model pulling dialog with autocompletion.
    • openPullDialog

      private void openPullDialog(List<OllamaRemoteModel> remoteModels)
      Constructs and opens the model pull dialog with an alphabetically sorted list showing model sizes, release dates, and installed status from the live server.
      Parameters:
      remoteModels - the list of remote models fetched from ollama.com
    • isModelInstalled

      private boolean isModelInstalled(String modelTag)
      Checks if a model tag is already installed on the Ollama server by comparing against live discovered models from /api/tags and registered local models.
      Parameters:
      modelTag - the model tag to check
      Returns:
      true if installed on the server
    • executePull

      private void executePull(String modelTag)
      Initiates the asynchronous model pull and binds live progress to pullProgressBar.
      Parameters:
      modelTag - the model name and tag to pull
    • formatBytes

      private static String formatBytes(long bytes)
      Formats bytes into human-readable representation using commons-io.
      Parameters:
      bytes - the raw byte count
      Returns:
      formatted string
    • formatExpiry

      private static String formatExpiry(String expiresAt)
      Formats an ISO expiration timestamp into relative remaining time.
      Parameters:
      expiresAt - the ISO timestamp
      Returns:
      formatted relative string