Table of Contents

Class ModelMetadataProvider

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

Fetches, caches, parses, and applies model metadata from LiteLLM's catalog. Fallback chain: fetched data -> cached data -> hardcoded record defaults.

public sealed class ModelMetadataProvider
Inheritance
ModelMetadataProvider
Inherited Members

Constructors

ModelMetadataProvider(IModelMetadataSource?)

public ModelMetadataProvider(IModelMetadataSource? source = null)

Parameters

source IModelMetadataSource

Properties

EntryCount

Number of parsed catalog entries.

public int EntryCount { get; }

Property Value

int

IsLoaded

Whether the catalog has been loaded.

public bool IsLoaded { get; }

Property Value

bool

LastFetched

When the catalog was last fetched (from meta file).

public DateTime? LastFetched { get; }

Property Value

DateTime?

Methods

Enrich(IReadOnlyList<ProviderModelInfo>)

Enriches a list of models with metadata from the loaded catalog. Unmatched models are returned unchanged.

public IReadOnlyList<ProviderModelInfo> Enrich(IReadOnlyList<ProviderModelInfo> models)

Parameters

models IReadOnlyList<ProviderModelInfo>

Returns

IReadOnlyList<ProviderModelInfo>

GetEntriesSnapshot()

Returns a copy of the currently loaded metadata entries keyed by LiteLLM model key. Returns an empty dictionary when metadata has not been loaded.

public IReadOnlyDictionary<string, ModelMetadataEntry> GetEntriesSnapshot()

Returns

IReadOnlyDictionary<string, ModelMetadataEntry>

LoadAsync(bool, CancellationToken)

Loads model metadata. Tries cache first (within TTL), then fetches, then falls back to stale cache. Never throws.

public Task LoadAsync(bool forceRefresh = false, CancellationToken ct = default)

Parameters

forceRefresh bool
ct CancellationToken

Returns

Task