Jido.AI.Provider (Jido AI v0.5.2)

View Source

Summary

Types

t()

An AI model provider

Functions

Returns the base directory path for provider-specific files.

Ensures the given value is an atom.

Gets an adapter module by provider ID.

Retrieves combined information for a model across all providers.

Gets a specific model from a provider by its ID or name.

Lists all cached models across all providers.

Standardizes a model name across providers by removing version numbers and dates. This helps match equivalent models from different providers.

Types

provider_id()

@type provider_id() :: atom()

provider_type()

@type provider_type() :: :direct | :proxy

t()

@type t() :: %Jido.AI.Provider{
  api_base_url: String.t() | nil,
  description: String.t() | nil,
  endpoints: map(),
  id: atom(),
  models: list(),
  name: String.t(),
  proxy_for: [String.t()] | nil,
  requires_api_key: boolean(),
  type: provider_type()
}

An AI model provider

Functions

base_dir()

Returns the base directory path for provider-specific files.

This is where provider configuration, models, and other data files are stored. The path is relative to the project root and expands to ./priv/provider/.

call_provider_callback(provider, callback, args)

ensure_atom(id)

@spec ensure_atom(atom() | String.t() | term()) :: atom() | term()

Ensures the given value is an atom.

get_adapter_by_id(provider_id)

Gets an adapter module by provider ID.

This is a helper function for getting the adapter module directly by ID.

get_adapter_module(provider)

get_combined_model_info(model_name)

Retrieves combined information for a model across all providers.

Parameters

  • model_name: The name of the model to search for

Returns

  • - Combined model information
  • - Error if model not found

get_model(provider, model, opts \\ [])

@spec get_model(t() | atom(), String.t(), keyword()) ::
  {:ok, map()} | {:error, String.t()}

Gets a specific model from a provider by its ID or name.

Parameters

  • provider - The provider struct or ID
  • model - The ID or name of the model to fetch
  • opts - Additional options for the request

Returns

  • {:ok, model} - The model was found
  • {:error, reason} - The model was not found or an error occurred

list()

list_all_cached_models()

Lists all cached models across all providers.

Returns

  • List of model maps, each containing provider information

models(provider, opts \\ [])

providers()

standardize_model_name(model)

Standardizes a model name across providers by removing version numbers and dates. This helps match equivalent models from different providers.

Examples

iex> standardize_model_name("claude-3.7-sonnet-20250219")
"claude-3.7-sonnet"
iex> standardize_model_name("gpt-4-0613")
"gpt-4"