Table of Contents

Class ApiKeyProviderDetectorBase

Namespace
JD.AI.Core.Providers
Assembly
JD.AI.Core.dll

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

config ProviderConfigurationManager
providerName string
providerKey string

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

IReadOnlyList<ProviderModelInfo>

MissingApiKeyMessage

protected virtual string MissingApiKeyMessage { get; }

Property Value

string

ProviderName

public string ProviderName { get; }

Property Value

string

Methods

BuildAuthenticatedStatus(int)

protected virtual string BuildAuthenticatedStatus(int modelCount)

Parameters

modelCount int

Returns

string

BuildKernel(ProviderModelInfo)

public Kernel BuildKernel(ProviderModelInfo model)

Parameters

model ProviderModelInfo

Returns

Kernel

ConfigureKernel(IKernelBuilder, ProviderModelInfo, string)

protected abstract void ConfigureKernel(IKernelBuilder builder, ProviderModelInfo model, string apiKey)

Parameters

builder IKernelBuilder
model ProviderModelInfo
apiKey string

DetectAsync(CancellationToken)

public Task<ProviderInfo> DetectAsync(CancellationToken ct = default)

Parameters

ct CancellationToken

Returns

Task<ProviderInfo>

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

apiKey string
ct CancellationToken

Returns

Task<IReadOnlyList<ProviderModelInfo>>