Class HuggingFaceProvider
java.lang.Object
uno.anahata.asi.agi.event.BasicPropertyChangeSource
uno.anahata.asi.agi.provider.AbstractAiProvider
uno.anahata.asi.openai.compatible.OpenAiChatCompletionsProvider
uno.anahata.asi.huggingface.HuggingFaceProvider
- All Implemented Interfaces:
PropertyChangeSource, Rebindable
A specialized provider for the Hugging Face Inference API that performs deep
model inspection by fetching metadata directly from the HF Hub.
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe base URL for the Hugging Face Hub metadata API.static final HttpClientA specialized HTTP client for fetching model configuration files from the Hub.Fields inherited from class AbstractAiProvider
MARKUP_TABLE_HEADERFields inherited from class BasicPropertyChangeSource
propertyChangeSupport -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new Hugging Face provider with the stable UUID 'HuggingFace' and pre-configured endpoint and acquisition URIs. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisRetryable(int statusCode, String responseBody) Determines if an HTTP status code or response body indicates a transient failure that should trigger a retry or rotation.List<? extends AbstractModel> Fetches the list of all models available from the provider's remote API.Methods inherited from class OpenAiChatCompletionsProvider
createHttpClient, createModel, createRequestBuilder, getApiKeyHintMethods inherited from class AbstractAiProvider
addModel, addModels, ensureKeysFileExists, findModels, getAllDisplayModels, getAllSupportedActions, getCachedApiModel, getCurrentKey, getEnabledModels, getKeyPoolSize, getKeysAcquisitionUri, getKeysFilePath, getModel, getModels, getModelsDirectory, getProviderDirectory, getProviderId, getUnloadableModelsDirectory, hasKeys, hokusPocus, initialize, isEffectivelyEnabled, loadModelsFromDisk, persist, refreshCachedApiModels, reloadKeyPool, reloadKeyPoolIfNeeded, remove, removeModel, testConnection, toMarkupRow, toMarkupRowMethods inherited from class BasicPropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, rebind, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PropertyChangeSource
getPropertyChangeSupport
-
Field Details
-
HF_HUB_BASE
The base URL for the Hugging Face Hub metadata API.- See Also:
-
HUB_CLIENT
A specialized HTTP client for fetching model configuration files from the Hub. Uses connection pooling and follows redirects to the Hub's CDN. Configured with HTTP/1.1 to prevent HTTP/2 multiplexed stream exhaustion.
-
-
Constructor Details
-
HuggingFaceProvider
public HuggingFaceProvider()Constructs a new Hugging Face provider with the stable UUID 'HuggingFace' and pre-configured endpoint and acquisition URIs.
-
-
Method Details
-
listModels
Fetches the list of all models available from the provider's remote API.Implementation details: Performs a GET request to the
/modelsendpoint of the configuredgetBaseUrl(). Parses the standard OpenAI list-response and wraps each ID in anOpenAiCompatibleModelinstance.Implementation details: Fetches basic models from the router and orchestrates parallel deep self-inspection across all models without artificial timeouts. Resolves the API key upfront to prevent thread-monitor lock contention.
- Overrides:
listModelsin classOpenAiChatCompletionsProvider- Returns:
- A list of provider-specific
AbstractModelobjects.
-
isRetryable
Determines if an HTTP status code or response body indicates a transient failure that should trigger a retry or rotation.Checks for common OpenAI-compatible error codes (429, 503, 500, 499, 408).
Implementation details: Adds specific handling for Hugging Face credit-related errors (HTTP 402).
- Overrides:
isRetryablein classOpenAiChatCompletionsProvider- Parameters:
statusCode- The HTTP status code.responseBody- The raw response body.- Returns:
- true if retryable, false otherwise.
-

