Class OllamaAiProviderPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
uno.anahata.asi.swing.components.ScrollablePanel
uno.anahata.asi.swing.AbstractAiProviderPanel<OllamaAiProvider>
uno.anahata.asi.swing.provider.OpenAiChatCompletionsProviderPanel<OllamaAiProvider>
uno.anahata.asi.swing.provider.OllamaAiProviderPanel
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JButtonButton to download and install a new model from ollama.com or custom tag.private JProgressBarProgress bar displaying download percentage and bytes.private JPanelVisual container for in-flight model download progress.private JLabelLabel showing the status text of the active model pull.private JButtonButton to refresh the active VRAM / running models list.private JTableTable displaying models currently loaded in host memory and GPU VRAM.private DefaultTableModelData model backing the running models table.private JButtonButton to unload the selected model from GPU memory.private JLabelLabel displaying the detected Ollama server version.private JLabelLabel displaying active models count in memory or idle notice.Fields inherited from class AbstractAiProviderPanel
acquisitionLinkLabel, apiKeyRequiredCheck, autoRegisterCheck, baseUrlField, classField, container, currentApiKeysPath, descriptionField, displayNameField, enabledCheck, folderLabel, folderRow, formPanel, headerLeft, keyPoolLabel, keysContainer, keysFileLabel, promoBannerContainer, provider, registryViewer, removeCallback, testConnectionBtn, textArea, tokenizerCombo, uuidLabelModifier and TypeFieldDescriptionprotected JLabelLink to the API key acquisition page.protected JCheckBoxDetermines if the key pool must be populated for this provider to function.protected JCheckBoxCheckbox to toggle automatically registering newly discovered models.protected JTextFieldThe endpoint root for Chat Completion API calls.protected JTextFieldReadonly field displaying the concrete provider class FQN.protected AbstractSwingAsiContainerThe parent ASI container instance.protected StringThe pending custom API keys file path selected by the user.protected JTextFieldEditable description for this provider instance.protected JTextFieldUser-facing name for this provider instance.protected JCheckBoxMaster switch to enable/disable the provider globally.protected JLabelVisual indicator of where this provider's data is stored on the host FS.protected JPanelRow panel containing the keys file path label and choose/open buttons.protected JPanelThe main scrollable form panel container.protected JPanelVisual container for provider logo icon in the top header row.protected JLabelLabel for the API Key Pool section.protected JPanelContainer panel for the API key pool text area.protected JLabelLabel for the API Keys File row.protected JPanelVisual container hosting promo banner, dynamically updated per provider.protected OllamaAiProviderThe domain entity representing the AI provider being configured.protected AiModelsPanelEmbedded models explorer panel.protected RunnableThe callback invoked when the user requests provider deletion.protected JButtonTriggers an immediate model discovery probe to verify the URL and Auth.protected JTextAreaMonospace editor for the 'api_keys.txt' file, supporting multiple keys.protected JComboBox<TokenizerType> Selector for the tokenizer used for pre-flight metabolic estimations.protected JLabelReadonly label displaying the active provider UUID.Fields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new uninitialized OllamaAiProviderPanel. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidChecks the running Ollama server version viaOllamaAiProvider.getServerVersion()in a background task.private voidexecutePull(String modelTag) Initiates the asynchronous model pull and binds live progress topullProgressBar.private static StringformatBytes(long bytes) Formats bytes into human-readable representation using commons-io.private static StringformatExpiry(String expiresAt) Formats an ISO expiration timestamp into relative remaining time.voidinit(@NonNull AbstractSwingAsiContainer container, @NonNull OllamaAiProvider provider, Runnable removeCallback) Initializes all UI components, listeners, and models table bound to the specified provider.private booleanisModelInstalled(String modelTag) Checks if a model tag is already installed on the Ollama server by comparing against live discovered models from/api/tagsand registered local models.private voidopenPullDialog(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.private voidRefreshes the running models loaded in memory viaOllamaAiProvider.getRunningModels()in a background task.private voidQueries ollama.com tags and displays the model pulling dialog with autocompletion.private voidUnloads the selected model from memory by sendingkeep_alive: 0.Methods inherited from class OpenAiChatCompletionsProviderPanel
isModified, syncToProviderModifier and TypeMethodDescriptionbooleanChecks if any settings or API key text in the UI have been modified compared to the domain entity.voidSynchronizes the UI state back to the provider domain and flushes the key pool to disk.Methods inherited from class AbstractAiProviderPanel
loadKeys, setProvider, updateHeaderIcon, updateKeySectionVisibility, updatePromoBannerModifier and TypeMethodDescriptionprotected voidloadKeys()Loads the raw key pool text.voidsetProvider(OllamaAiProvider newProvider) Re-binds this panel to a different provider instance dynamically.protected voidUpdates the provider icon in the top-left header.protected voidToggles visibility of the key pool and keys file rows based on whether an API key is required.protected voidUpdates the promo banner in the promo container based on active provider.Methods inherited from class ScrollablePanel
getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, setScrollableTracksViewportHeight, setScrollableTracksViewportWidthModifier and TypeMethodDescriptionintgetScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) booleanbooleanintgetScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) voidsetScrollableTracksViewportHeight(boolean scrollableTracksViewportHeight) Sets whether this panel should track the viewport's height.voidsetScrollableTracksViewportWidth(boolean scrollableTracksViewportWidth) Sets whether this panel should track the viewport's width.Methods inherited from class JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
versionLabel
Label displaying the detected Ollama server version. -
vramStatusLabel
Label displaying active models count in memory or idle notice. -
runningModelsTable
Table displaying models currently loaded in host memory and GPU VRAM. -
runningModelsTableModel
Data model backing the running models table. -
refreshRunningBtn
Button to refresh the active VRAM / running models list. -
unloadModelBtn
Button to unload the selected model from GPU memory. -
pullModelBtn
Button to download and install a new model from ollama.com or custom tag. -
pullProgressPanel
Visual container for in-flight model download progress. -
pullStatusLabel
Label showing the status text of the active model pull. -
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:
initin classOpenAiChatCompletionsProviderPanel<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 viaOllamaAiProvider.getServerVersion()in a background task. -
refreshRunningModels
private void refreshRunningModels()Refreshes the running models loaded in memory viaOllamaAiProvider.getRunningModels()in a background task. -
unloadSelectedModel
private void unloadSelectedModel()Unloads the selected model from memory by sendingkeep_alive: 0. -
showPullModelDialog
private void showPullModelDialog()Queries ollama.com tags and displays the model pulling dialog with autocompletion. -
openPullDialog
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
Checks if a model tag is already installed on the Ollama server by comparing against live discovered models from/api/tagsand registered local models.- Parameters:
modelTag- the model tag to check- Returns:
- true if installed on the server
-
executePull
Initiates the asynchronous model pull and binds live progress topullProgressBar.- Parameters:
modelTag- the model name and tag to pull
-
formatBytes
Formats bytes into human-readable representation using commons-io.- Parameters:
bytes- the raw byte count- Returns:
- formatted string
-
formatExpiry
-

