Class AiModelsPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class AiModelsPanel extends JPanel
A high-fidelity visual registry for exploring, configuring, and registering AI models.

This panel utilizes a JXTable and rich filter controls (provider dropdown with icons, keyword/regex query field, response modality toggles, and effectively-enabled state filter) to provide advanced discovery and lifecycle management. Models can be enabled/disabled, added from API discovery caches to local persistent storage, deleted, or reset when discrepancies occur.

Author:
anahata
See Also:
  • Field Details

    • table

      private final JXTable table
      The advanced SwingX table instance for model discovery.
    • tableModel

      private final AiModelTableModel tableModel
      The technical data model powering the table.
    • filterField

      private final JTextField filterField
      The real-time search and filter input field.
    • providerLabel

      private final JLabel providerLabel
      The label for the provider combo box.
    • providerComboBox

      private final JComboBox<AbstractAiProvider> providerComboBox
      The dropdown combo box for selecting/filtering by AI provider.
    • textToggle

      private final JToggleButton textToggle
      Toggle button for filtering by TEXT response modality.
    • imageToggle

      private final JToggleButton imageToggle
      Toggle button for filtering by IMAGE response modality.
    • audioToggle

      private final JToggleButton audioToggle
      Toggle button for filtering by AUDIO response modality.
    • videoToggle

      private final JToggleButton videoToggle
      Toggle button for filtering by VIDEO response modality.
    • effectivelyEnabledCheckbox

      private final JCheckBox effectivelyEnabledCheckbox
      Checkbox to filter models to only effectively enabled providers.
    • refreshButton

      private final JButton refreshButton
      Refresh button to reload models from providers' live APIs.
    • addNewModelsButton

      private final JButton addNewModelsButton
      Button to add all unregistered API models to the local database in a single batch.
    • removeSelectedButton

      private final JButton removeSelectedButton
      Button to remove selected models from local storage.
    • resetSelectedButton

      private final JButton resetSelectedButton
      Button to reset selected models with discrepancies back to API specifications.
    • statusLabel

      private final JLabel statusLabel
      Bottom status bar label showing active model counts and operations feedback.
    • progressBar

      private final JProgressBar progressBar
      Bottom status bar indeterminate progress bar for async background tasks.
    • asiContainer

      private final AbstractAsiContainer asiContainer
      Container reference for background model fetching and executor pooling.
    • modelSelectionCallback

      private final Consumer<AbstractModel> modelSelectionCallback
      Reactive callback for notifying the system of a user's model selection.
    • targetProvider

      private AbstractAiProvider targetProvider
      Target provider lock when embedded in a single provider configuration panel.
  • Constructor Details

    • AiModelsPanel

      public AiModelsPanel(List<AbstractModel> models, @NonNull @NonNull AbstractAsiContainer asiContainer, Consumer<AbstractModel> modelSelectionCallback)
      Constructs a new AiModelsPanel with container-aware refresh capabilities.
      Parameters:
      models - The initial list of models to display.
      asiContainer - The parent ASI container providing thread pools and provider registries.
      modelSelectionCallback - A callback for when a model is double-clicked.
  • Method Details

    • formatModelToolTip

      private String formatModelToolTip(AbstractModel m)
      Formats a clean, bounded HTML tooltip card for a model without overflowing the monitor.
      Parameters:
      m - The model entity.
      Returns:
      Bounded HTML tooltip string, or null.
    • selectModel

      private void selectModel(AbstractModel model)
      Dispatches the model selection callback. If the selected model is not yet registered in local storage, it is automatically registered and persisted without prompting. If registration fails, an ExceptionDialog is displayed to the user and selection does not proceed.
      Parameters:
      model - The model entity to select.
    • showTableContextMenu

      private void showTableContextMenu(MouseEvent e)
      Displays a context menu on right-click allowing quick copying of the model ID or inspecting full raw metadata in the environment's native code viewer.
      Parameters:
      e - The mouse event.
    • setTargetProvider

      public void setTargetProvider(AbstractAiProvider provider)
      Locks and targets this panel to a specific provider (used when embedding in AiProviderPanel).
      Parameters:
      provider - The target provider to lock to.
    • updateAddNewModelsButton

      private void updateAddNewModelsButton()
      Updates the text and visibility of the "Add X New Models" button based on unregistered API models.
    • getUnregisteredApiModelsCount

      private int getUnregisteredApiModelsCount()
      Calculates the count of models discovered from API that are not yet persisted locally.
      Returns:
      The count of unregistered API models.
    • addAllNewModels

      private void addAllNewModels()
      Adds all newly discovered API models to the local database in a single batch.
    • refreshTableData

      private void refreshTableData()
      Refreshes the table view with current models from providers.
    • updateSelectionActionButtons

      private void updateSelectionActionButtons()
      Updates the enabled state of the 'Remove Selected' and 'Reset Selected' buttons based on active table selection.
    • removeSelectedModels

      private void removeSelectedModels()
      Removes all selected registered models from local storage in a single batch.
    • resetSelectedModels

      private void resetSelectedModels()
      Resets all selected registered models with discrepancies back to API specifications.
    • applyFilter

      private void applyFilter()
      Evaluates all active filters (provider, search query regex, response modalities, and enabled status) and updates the table row filter accordingly.
    • refreshModelsFromProviders

      private void refreshModelsFromProviders()
      Refreshes models asynchronously from providers using a SwingTask, updating the table progressively.