Skip to main content
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. View source on GitHub

UDFs


chat_completions() udf

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
Signature:
chat_completions(
    messages: Json,
    model: String,
    model_kwargs: Optional[Json]
)-> Json
Parameters: Returns:
  • Json: A dictionary containing the response and other metadata.
Example: 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() udf

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
Signature:
embeddings(
    input: String,
    model: String
)-> Array[(None,), Float]
Parameters: Returns:
  • Array[(None,), Float]: An array representing the application of the given embedding to input.

fim_completions() udf

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
Signature:
fim_completions(
    prompt: String,
    model: String,
    model_kwargs: Optional[Json]
)-> Json
Parameters: Returns:
  • Json: A dictionary containing the response and other metadata.
Example: 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'))
I