Configuration

ell provides various configuration options to customize its behavior.

ell.init(store: Store | str | None = None, verbose: bool = False, autocommit: bool = True, lazy_versioning: bool = True, default_lm_params: Dict[str, Any] | None = None, default_openai_client: OpenAI | None = None) None

Initialize the ELL configuration with various settings.

Parameters:
  • verbose (bool) – Set verbosity of ELL operations.

  • store (Union[Store, str], optional) – Set the store for ELL. Can be a Store instance or a string path for SQLiteStore.

  • autocommit (bool) – Set autocommit for the store operations.

  • lazy_versioning (bool) – Enable or disable lazy versioning.

  • default_lm_params (Dict[str, Any], optional) – Set default parameters for language models.

  • default_openai_client (openai.Client, optional) – Set the default OpenAI client.

This init function is a convenience function that sets up the configuration for ell. It is a thin wrapper around the Config class, which is a Pydantic model.

You can modify the global configuration using the ell.config object which is an instance of Config:

pydantic model ell.Config
field autocommit: bool = False

If True, enables automatic committing of changes to the store.

field default_lm_params: Dict[str, Any] [Optional]

Default parameters for language models.

field lazy_versioning: bool = True

If True, enables lazy versioning for improved performance.

field override_wrapped_logging_width: int | None = None

If set, overrides the default width for wrapped logging.

field providers: Dict[Type, Type[Provider]] [Optional]

A dictionary mapping client types to provider classes.

field verbose: bool = False

If True, enables verbose logging.

field wrapped_logging: bool = True

If True, enables wrapped logging for better readability.

get_client_for(model_name: str) Tuple[Any | None, bool]

Get the OpenAI client for a specific model name.

Parameters:

model_name (str) – The name of the model to get the client for.

Returns:

The OpenAI client for the specified model, or None if not found.

Return type:

Optional[openai.Client]

get_provider_for(client: Any) Type[Provider] | None

Get the provider class for a specific client instance.

Parameters:

client (Any) – The client instance to get the provider for.

Returns:

The provider class for the specified client, or None if not found.

Return type:

Optional[Type[AbstractProvider]]

get_store() Store

Get the current store.

Returns:

The current store.

Return type:

Store

model_registry_override(overrides: Dict[str, Any])

Temporarily override the model registry with new client mappings.

Parameters:

overrides (Dict[str, openai.Client]) – A dictionary of model names to OpenAI clients to override.

register_model(model_name: str, client: Any) None

Register an OpenAI client for a specific model name.

Parameters:
  • model_name (str) – The name of the model to register.

  • client (openai.Client) – The OpenAI client to associate with the model.

register_provider(provider_class: Type[Provider]) None

Register a provider class for a specific client type.

Parameters:

provider_class (Type[AbstractProvider]) – The provider class to register.

reset() None

Reset the configuration to its initial state.

set_default_client(client: OpenAI) None

Set the default OpenAI client.

Parameters:

client (openai.Client) – The default OpenAI client to set.

set_default_lm_params(**params: Dict[str, Any]) None

Set default parameters for language models.

Parameters:

params (Dict[str, Any]) – Keyword arguments representing the default parameters.

set_store(store: Store | str, autocommit: bool = True) None

Set the store for the configuration.

Parameters:
  • store (Union[Store, str]) – The store to set. Can be a Store instance or a string path for SQLiteStore.

  • autocommit (bool) – Whether to enable autocommit for the store.