LemonAgent.ModelRuntime.ModelCatalog (lemon_agent v0.1.0)

View Source

Consumer-facing "what can I pick from right now" model catalog.

Centralizes the provider-alias credential-fallback rules, health blocklist, and picker sort order that model-picker-style consumers need, so callers don't have to reach into LemonAi.Models and the provider config table themselves. This mirrors (and replaces) logic that used to be duplicated across Telegram transport modules in lemon_channels.

Summary

Types

A single selectable model entry.

Models grouped by provider, in picker display order.

Functions

Returns the catalog of models available for selection, grouped by provider and filtered down to providers with usable credentials, in picker display order (each provider's models sorted newest/most-relevant first).

Model at a given index for a provider within a catalog, or nil.

Human-readable label for a model map.

Formats a model map as a provider:id spec string.

Models for a given provider within a catalog, or [] if unknown.

Provider ids present in a catalog, in display order.

Types

model_map()

@type model_map() :: %{provider: String.t(), id: String.t(), name: String.t()}

A single selectable model entry.

provider_group()

@type provider_group() :: %{provider: String.t(), models: [model_map()]}

Models grouped by provider, in picker display order.

Functions

available_catalog()

@spec available_catalog() :: [provider_group()]

Returns the catalog of models available for selection, grouped by provider and filtered down to providers with usable credentials, in picker display order (each provider's models sorted newest/most-relevant first).

Falls back to a small built-in catalog if the model registry is unavailable or errors.

model_at_index(catalog, provider, index)

@spec model_at_index([provider_group()], String.t(), integer()) :: model_map() | nil

Model at a given index for a provider within a catalog, or nil.

model_label(other)

@spec model_label(model_map()) :: String.t()

Human-readable label for a model map.

model_spec(arg1)

@spec model_spec(model_map()) :: String.t() | nil

Formats a model map as a provider:id spec string.

models_for_provider(catalog, provider)

@spec models_for_provider([provider_group()], String.t()) :: [model_map()]

Models for a given provider within a catalog, or [] if unknown.

providers(catalog)

@spec providers([provider_group()]) :: [String.t()]

Provider ids present in a catalog, in display order.