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

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

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['response'] = completions(messages, model='mistral-latest-small')

embeddings

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

Requirements:

  • pip install mistralai

Parameters:

Returns:

  • Array[(None,), Float]

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

fim_completions

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

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['response'] = completions(tbl.prompt, model='codestral-latest')