def __init__(
      self,
      model_name: str,
      *,
      api_key: str | None = None,
      use_codestral_for_choices: bool = False,
      measurements: measurements_lib.Measurements | None = None,
      channel: str = language_model.DEFAULT_STATS_CHANNEL,
  ):
    """Initializes the instance.

    Args:
      model_name: The language model to use. For more details, see
        https://docs.mistral.ai/getting-started/models/.
      api_key: The API key to use when accessing the OpenAI API, if None will
        use the MISTRAL_API_KEY environment variable.
      use_codestral_for_choices: When enabled, use codestral for multiple choice
        questions. Otherwise, use the model specified in the param `model_name`.
      measurements: The measurements object to log usage statistics to.
      channel: The channel to write the statistics to.
    """
    if api_key is None:
      api_key = os.environ['MISTRAL_API_KEY']
    self._api_key = api_key
    self._text_model_name = model_name
    self._measurements = measurements
    self._channel = channel
    self._client = mistralai.Mistral(api_key=self._api_key)

    self._choice_model_name = self._text_model_name
    if use_codestral_for_choices:
      self._choice_model_name = 'codestral-latest'

    self._completion_for_text = False
    if self._text_model_name in COMPLETION_MODELS:
      self._completion_for_text = True

    self._completion_for_choice = False
    if self._choice_model_name in COMPLETION_MODELS:
      self._completion_for_choice = True
Initializes the instance.

    Args:
      model_name: The language model to use. For more details, see
        https://docs.mistral.ai/getting-started/models/.
      api_key: The API key to use when accessing the OpenAI API, if None will
        use the MISTRAL_API_KEY environment variable.
      use_codestral_for_choices: When enabled, use codestral for multiple choice
        questions. Otherwise, use the model specified in the param `model_name`.
      measurements: The measurements object to log usage statistics to.
      channel: The channel to write the statistics to.
    
concordia/language_model/mistral_model.py