Class OpenAiChatCompletionsProviderPanel<P extends OpenAiChatCompletionsProvider>
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<P>
uno.anahata.asi.swing.provider.OpenAiChatCompletionsProviderPanel<P>
- 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:
-
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 JTextAreaText area for multi-line custom HTTP header configuration.private JCheckBoxToggle for forcing HTTP/1.1 on local inference servers and routers.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 PThe 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 OpenAiChatCompletionsProviderPanel. -
Method Summary
Modifier and TypeMethodDescriptionvoidinit(@NonNull AbstractSwingAsiContainer container, P provider, Runnable removeCallback) Initializes all UI components, listeners, and models table bound to the specified provider.booleanChecks if any settings or API key text in the UI have been modified compared to the domain entity.Parses the raw lines incustomHeadersAreainto a key-value header map.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(P 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
-
customHeadersArea
Text area for multi-line custom HTTP header configuration. -
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:
initin classAbstractAiProviderPanel<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:
isModifiedin classAbstractAiProviderPanel<P extends OpenAiChatCompletionsProvider>- Returns:
- true if there are unsaved modifications.
-
syncToProvider
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:
syncToProviderin classAbstractAiProviderPanel<P extends OpenAiChatCompletionsProvider>- Throws:
IOException- If writing the keys file or syncing the provider state fails.
-
parseHeaders
Parses the raw lines incustomHeadersAreainto a key-value header map.- Returns:
- The parsed header map.
-

