SuperPi.AI.Providers (super_pi v0.1.0)

Copy Markdown View Source

Provider registry. Selects the SuperPi.AI.Provider that serves a model.

Resolution order:

  1. In mock mode (config :super_pi, mock_llm: true) only SuperPi.AI.Providers.Mock is active. Mock mode is for tests and demos. It never turns on by itself.
  2. Otherwise the first provider in config :super_pi, :providers whose handles?/1 returns true serves the model. The default list is Gemini, Anthropic and OpenAI. A provider with no key is listed in the catalog as not available.
  3. If that provider is not configured, or no provider handles the model, the result is an error. There is no silent fallback.

Summary

Functions

Providers that can serve requests now.

Model catalog of all registered providers, with the provider id and availability.

Human-readable message for a resolution error.

Providers registered in the application environment.

Returns the provider for model and the model name to send to it.

Types

error()

@type error() ::
  {:no_provider, String.t()} | {:not_configured, provider_id :: String.t()}

Functions

active()

@spec active() :: [module()]

Providers that can serve requests now.

catalog()

@spec catalog() :: [map()]

Model catalog of all registered providers, with the provider id and availability.

format_error(arg)

@spec format_error(error()) :: String.t()

Human-readable message for a resolution error.

registered()

@spec registered() :: [module()]

Providers registered in the application environment.

resolve(model)

@spec resolve(String.t()) :: {:ok, module(), String.t()} | {:error, error()}

Returns the provider for model and the model name to send to it.