Class ApiKeyProviderDetectorBase
Shared template for API-key based provider detectors. Subclasses supply a static KnownModels catalog as a fallback and may override DiscoverModelsAsync(string, CancellationToken) to query their API for the current model list at detection time.
public abstract class ApiKeyProviderDetectorBase : IProviderDetector
- Inheritance
-
ApiKeyProviderDetectorBase
- Implements
- Derived
- Inherited Members
Constructors
ApiKeyProviderDetectorBase(ProviderConfigurationManager, string, string)
protected ApiKeyProviderDetectorBase(ProviderConfigurationManager config, string providerName, string providerKey)
Parameters
configProviderConfigurationManagerproviderNamestringproviderKeystring
Properties
KnownModels
Static fallback catalog used when DiscoverModelsAsync(string, CancellationToken) is not overridden or when live discovery fails.
protected abstract IReadOnlyList<ProviderModelInfo> KnownModels { get; }
Property Value
MissingApiKeyMessage
protected virtual string MissingApiKeyMessage { get; }
Property Value
ProviderName
public string ProviderName { get; }
Property Value
Methods
BuildAuthenticatedStatus(int)
protected virtual string BuildAuthenticatedStatus(int modelCount)
Parameters
modelCountint
Returns
BuildKernel(ProviderModelInfo)
public Kernel BuildKernel(ProviderModelInfo model)
Parameters
modelProviderModelInfo
Returns
- Kernel
ConfigureKernel(IKernelBuilder, ProviderModelInfo, string)
protected abstract void ConfigureKernel(IKernelBuilder builder, ProviderModelInfo model, string apiKey)
Parameters
builderIKernelBuildermodelProviderModelInfoapiKeystring
DetectAsync(CancellationToken)
public Task<ProviderInfo> DetectAsync(CancellationToken ct = default)
Parameters
Returns
DiscoverModelsAsync(string, CancellationToken)
Override to query the provider's API for its current model list. The default implementation returns KnownModels. Implementations should catch transport errors and return KnownModels as the fallback.
protected virtual Task<IReadOnlyList<ProviderModelInfo>> DiscoverModelsAsync(string apiKey, CancellationToken ct)
Parameters
apiKeystringctCancellationToken