Skip to content

mistral_common.experimental.app.models

EngineBackend

Bases: str, Enum

The engine backend to use.

Attributes:

Name Type Description
llama_cpp

The llama.cpp backend.

OpenAIChatCompletionRequest(**data)

Bases: BaseModel

OpenAI chat completion request.

This class is used to parse the request body for the OpenAI chat completion endpoint.

Attributes:

Name Type Description
messages List[dict[str, Union[str, List[dict[str, Union[str, dict[str, Any]]]]]]]

The messages to use for the chat completion.

tools Optional[List[dict[str, Any]]]

The tools to use for the chat completion.

Note

This class accepts extra fields that are not validated.

Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
def __init__(self, /, **data: Any) -> None:
    """Create a new model by parsing and validating input data from keyword arguments.

    Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
    validated to form a valid model.

    `self` is explicitly positional-only to allow `self` as a field name.
    """
    # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    __tracebackhide__ = True
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    if self is not validated_self:
        warnings.warn(
            'A custom validator is returning a value other than `self`.\n'
            "Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\n"
            'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
            stacklevel=2,
        )

drop_extra_fields()

Drop extra fields from the model.

This method is used to drop extra fields from the model, which are not defined in the model fields.

Returns:

Type Description
dict[str, Any]

The extra fields that were dropped from the model.

Source code in src/mistral_common/experimental/app/models.py
def drop_extra_fields(self) -> dict[str, Any]:
    r"""Drop extra fields from the model.

    This method is used to drop extra fields from the model, which are not defined in the model fields.

    Returns:
        The extra fields that were dropped from the model.
    """
    extra_fields = {
        field: value for field, value in self.model_dump().items() if field not in type(self).model_fields
    }

    self.__dict__ = {k: v for k, v in self.__dict__.items() if k not in extra_fields}
    return extra_fields

Settings

Bases: BaseSettings

Settings for the Mistral-common API.

Attributes:

Name Type Description
app_name str

The name of the application.

app_version str

The version of the application.

engine_url str

The URL of the engine.

engine_backend EngineBackend

The backend to use for the engine.

timeout int

The timeout to use for the engine API.

get_settings()

Get the settings for the Mistral-common API.

Source code in src/mistral_common/experimental/app/models.py
def get_settings() -> Settings:
    r"""Get the settings for the Mistral-common API."""
    return Settings()