mistral_common.tokens.tokenizers.model_settings_builder
EnumBuilder(**data)
Bases: FieldBuilder[E]
Builder for enum fields.
This class validates that enum fields contain only authorized values. It rejects duplicate values during initialization and ensures the allowed values list is non-empty when None is not accepted.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
ValidatorType
|
The type of validator (always ENUM for this class). |
values |
list[E]
|
List of allowed enum values. |
Source code in .venv/lib/python3.14/site-packages/pydantic/main.py
validate_default()
Ensure the default value, if set, is among the allowed values.
Source code in src/mistral_common/tokens/tokenizers/model_settings_builder.py
validate_empty_list()
Ensure the allowed values list is non-empty when None is not accepted.
Source code in src/mistral_common/tokens/tokenizers/model_settings_builder.py
validate_unique_values()
Ensure no duplicate values are present in the allowed values list.
Source code in src/mistral_common/tokens/tokenizers/model_settings_builder.py
FieldBuilder(**data)
Bases: MistralBase, Generic[T]
Base class for field builders.
This class serves as the base for all field builders in the validation framework. It ensures that all builders have a type attribute that specifies the kind of validation being performed.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
ValidatorType
|
The type of validator (e.g., ENUM). |
accepts_none |
bool
|
Whether the field accepts None as a valid value in the request. |
default |
T | None
|
The default value to use when the field is None, if accepts_none is True. |
Source code in .venv/lib/python3.14/site-packages/pydantic/main.py
build_value(field_name, value)
Resolve and validate a field value, returning the final built result.
Raises:
| Type | Description |
|---|---|
InvalidRequestException
|
If the value is invalid or missing when required. |
Source code in src/mistral_common/tokens/tokenizers/model_settings_builder.py
validate_built_value(field_name, value)
Validate a fully built value, including None checks.
Raises:
| Type | Description |
|---|---|
InvalidRequestException
|
If value is None when not permitted, or fails subclass validation. |
Source code in src/mistral_common/tokens/tokenizers/model_settings_builder.py
validate_default_accept_none()
Ensure a default value is only set when accepts_none is True.
Source code in src/mistral_common/tokens/tokenizers/model_settings_builder.py
ModelSettingsBuilder(**data)
Bases: MistralBase
Builder for ModelSettings to ensure only authorized values are used.
This class validates that model settings contain only authorized values for each field. It enforces a strict field matching approach where: - All fields in model settings must have corresponding builder fields. - All builder fields must have corresponding model settings fields. - Validation is performed only on matching fields. - Clear error messages are provided for field mismatches.
Attributes:
| Name | Type | Description |
|---|---|---|
reasoning_effort |
EnumBuilder[ReasoningEffort] | None
|
Builder for the allowed ReasoningEffort values, or None if unsupported. |
Source code in .venv/lib/python3.14/site-packages/pydantic/main.py
build_settings(request)
Build and validate a ModelSettings instance from a raw request.
Iterates over all known fields, applies the corresponding builder, and constructs a validated ModelSettings object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ChatCompletionRequest
|
The incoming chat completion request. |
required |
Returns:
| Type | Description |
|---|---|
ModelSettings
|
A validated ModelSettings instance. |
Raises:
| Type | Description |
|---|---|
InvalidRequestException
|
If any field value is invalid or unsupported. |
Source code in src/mistral_common/tokens/tokenizers/model_settings_builder.py
none()
staticmethod
Return a ModelSettingsBuilder with no field builders configured.
validate_settings(settings)
Validate that all fields in a ModelSettings instance match the configured builders.
Ensures that fields without a builder are unset, and fields with a builder hold a value that passes validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
ModelSettings
|
The ModelSettings instance to validate. |
required |
Raises:
| Type | Description |
|---|---|
InvalidRequestException
|
If a field is set but has no builder, or fails its builder. |