Skip to content

mistralai

pixeltable.functions.mistralai

Pixeltable UDFs that wrap various endpoints from the Mistral AI API. In order to use them, you must first pip install mistralai and configure your Mistral AI credentials, as described in the Working with Mistral AI tutorial.

chat_completions async

chat_completions(
    messages: Json,
    *,
    model: String,
    temperature: Optional[Float] = 0.7,
    top_p: Optional[Float] = 1.0,
    max_tokens: Optional[Int] = None,
    stop: Optional[Json] = None,
    random_seed: Optional[Int] = None,
    response_format: Optional[Json] = None,
    safe_prompt: Optional[Bool] = False
) -> Json

Chat Completion API.

Equivalent to the Mistral AI chat/completions API endpoint. For additional details, see: https://docs.mistral.ai/api/#tag/chat

Request throttling: Applies the rate limit set in the config (section mistral, key rate_limit). If no rate limit is configured, uses a default of 600 RPM.

Requirements:

  • pip install mistralai

Parameters:

For details on the other parameters, see: https://docs.mistral.ai/api/#tag/chat

Returns:

  • Json

    A dictionary containing the response and other metadata.

Examples:

Add a computed column that applies the model mistral-latest-small to an existing Pixeltable column tbl.prompt of the table tbl:

>>> messages = [{'role': 'user', 'content': tbl.prompt}]
... tbl.add_computed_column(response=completions(messages, model='mistral-latest-small'))

embeddings async

embeddings(input: String, *, model: String) -> Array[(None,), Float]

Embeddings API.

Equivalent to the Mistral AI embeddings API endpoint. For additional details, see: https://docs.mistral.ai/api/#tag/embeddings

Request throttling: Applies the rate limit set in the config (section mistral, key rate_limit). If no rate limit is configured, uses a default of 600 RPM.

Requirements:

  • pip install mistralai

Parameters:

Returns:

  • Array[(None,), Float]

    An array representing the application of the given embedding to input.

fim_completions async

fim_completions(
    prompt: String,
    *,
    model: String,
    temperature: Optional[Float] = 0.7,
    top_p: Optional[Float] = 1.0,
    max_tokens: Optional[Int] = None,
    min_tokens: Optional[Int] = None,
    stop: Optional[Json] = None,
    random_seed: Optional[Int] = None,
    suffix: Optional[String] = None
) -> Json

Fill-in-the-middle Completion API.

Equivalent to the Mistral AI fim/completions API endpoint. For additional details, see: https://docs.mistral.ai/api/#tag/fim

Request throttling: Applies the rate limit set in the config (section mistral, key rate_limit). If no rate limit is configured, uses a default of 600 RPM.

Requirements:

  • pip install mistralai

Parameters:

For details on the other parameters, see: https://docs.mistral.ai/api/#tag/fim

Returns:

  • Json

    A dictionary containing the response and other metadata.

Examples:

Add a computed column that applies the model codestral-latest to an existing Pixeltable column tbl.prompt of the table tbl:

>>> tbl.add_computed_column(response=completions(tbl.prompt, model='codestral-latest'))