Skip to main content

ducto.config module

Pricing config loading with pydantic validation and expression validation.

exception ducto.config.ConfigError

Bases: Exception

Raised on config parsing or validation failures.

class ducto.config.PricingConfig(*, version: ~typing.Literal[1] = 1, models: dict[str, str], tools: dict[str, str] = , search: dict[str, str] = , cache: dict[str, str] = , min_balance: ~typing.Annotated[int, ~annotated_types.Ge(ge=0)] = 5, fixed: dict[str, ~typing.Annotated[int, ~annotated_types.Ge(ge=0)]] = , plans: dict[str, ~ducto.interface.models.PlanDefinition] | None = None)

Bases: BaseModel

Validated pricing configuration.

version must be 1 (current/latest). Optional plans key carries subscription-plan definitions for allowance-based features.

cache : dict[str, str]

fixed : dict[str, Annotated[int, Ge(ge=0)]]

min_balance : int

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

models : dict[str, str]

plans : dict[str, PlanDefinition] | None

search : dict[str, str]

tools : dict[str, str]

validate_expressions() → PricingConfig

Validate all expression strings in the config.

classmethod validate_structure(data: Any) → Any

Validate top-level structure before field validation.

version : Literal[1]

ducto.config.load_config_from_dict(data: dict) → PricingConfig

Load and validate a pricing config from a dictionary.

Args: : data: Dictionary representation of a pricing config.

Returns: : Validated PricingConfig instance.

Raises: : ConfigError: If the config structure or expressions are invalid.