yera.ui.settings_state

Load and persist the configuration state exposed through Yera Settings.

Symbols

class InvalidSettingsState — Invalid global configuration state shown by Settings.
def load_settings_state — Load the configuration state required by the Settings UI.
def save_default_models — Persist model defaults for the active profile.
def save_model_inference — Persist default inference parameters for an existing model.
def save_profile_settings — Persist editable settings belonging to the active profile.
def save_provider_connection — Persist changes to an existing provider connection.
class SettingsConflictError — Configuration changed while a Settings form was open.
class SettingsState — Configuration state required by the Settings UI.
class UnconfiguredSettingsState — Global configuration state before a profile has been configured.

InvalidSettingsState

Invalid global configuration state shown by Settings.

load_settings_state

load_settings_state() → SettingsState | InvalidSettingsState | UnconfiguredSettingsState

Load the configuration state required by the Settings UI.

Returns

type: SettingsState | InvalidSettingsState | UnconfiguredSettingsState

A complete editable Settings state when configuration is valid, an invalid state containing diagnostics when the TOML is malformed or schema-invalid, or an unconfigured state when no profiles exist.

Raises

ProfileNotSpecifiedError

If profiles exist but no active profile can be resolved.

save_default_models

save_default_models(
    state: SettingsState,
    model_defaults: ProfileModelDefaults,
) → None

Persist model defaults for the active profile.

Parameters

state
type: SettingsState

Settings state containing the active profile and available model catalogue.

model_defaults
type: ProfileModelDefaults

Model identifiers to store as defaults for each model type.

Returns

type: None

None.

Raises

SettingsConflictError

If the configuration changed after the state was loaded.

ValueError

If a selected model is unavailable to the active profile.

save_model_inference

save_model_inference(
    state: SettingsState,
    model_type: str,
    model_id: str,
    inference: LLMInference,
) → None

Persist default inference parameters for an existing model.

Parameters

state
type: SettingsState

Settings state containing the active model catalogue.

model_type
type: str

Catalogue type containing the model.

model_id
type: str

Yera identifier of the model to update.

inference
type: LLMInference

Validated inference configuration to persist.

Returns

type: None

None.

Raises

SettingsConflictError

If the configuration changed after the state was loaded.

ValueError

If the model type or model is unavailable, the model has no editable inference settings, or the inference type is incorrect.

save_profile_settings

save_profile_settings(
    state: SettingsState,
    description: str | None,
    providers: ProfileProviderConnections,
) → None

Persist editable settings belonging to the active profile.

Parameters

state
type: SettingsState

Settings state containing the active profile and configured providers.

description
type: str | None

Optional description to store on the active profile.

providers
type: ProfileProviderConnections

Provider connections selected by the active profile.

Returns

type: None

None.

Raises

SettingsConflictError

If the configuration changed after the state was loaded.

ValueError

If a selected provider connection does not exist.

save_provider_connection

save_provider_connection(
    state: SettingsState,
    provider_type: str,
    connection_name: str,
    connection: BaseConnection,
) → None

Persist changes to an existing provider connection.

Parameters

state
type: SettingsState

Settings state containing the configured provider connection.

provider_type
type: str

Provider key containing the connection.

connection_name
type: str

Name of the connection to update.

connection
type: BaseConnection

Validated connection configuration to persist.

Returns

type: None

None.

Raises

SettingsConflictError

If the configuration changed after the state was loaded.

ValueError

If the connection does not exist or its configuration type differs from the existing connection.

SettingsConflictError

Inherits: RuntimeError

Configuration changed while a Settings form was open.

SettingsState

Configuration state required by the Settings UI.

UnconfiguredSettingsState

Global configuration state before a profile has been configured.