Aurelio Docs
Client Referenceencoders

semantic_router.encoders.mistral

This file contains the MistralEncoder class which is used to encode text using MistralAI

mistral_to_list

def mistral_to_list(embeds: EmbeddingResponse) -> list[list[float]]

Convert a Mistral embedding response to a list of embeddings.

Arguments:

  • embeds (EmbeddingResponse): The Mistral embedding response.

Returns:

list[list[float]]: One embedding per input document.

MistralEncoder Objects

class MistralEncoder(DenseEncoder, AsymmetricDenseMixin)

Class to encode text using MistralAI and SDK. Requires a MistralAI API key from https://console.mistral.ai/api-keys/

__init__

def __init__(name: str | None = None,
             mistralai_api_key: str | None = None,
             score_threshold: float = 0.4)

Initialize the MistralEncoder.

Arguments:

  • name (str): The name of the embedding model to use such as "mistral-embed".
  • mistralai_api_key (str): The MistralAI API key.
  • score_threshold: The score threshold for the embeddings.

__call__

def __call__(docs: list[Any], **kwargs) -> list[list[float]]

Encode a list of text documents into embeddings using MistralAI.

Arguments:

  • docs (list[Any]): List of text documents to encode.

Returns:

list[list[float]]: List of embeddings for each document.

acall

async def acall(docs: list[Any], **kwargs) -> list[list[float]]

Encode a list of text documents into embeddings using MistralAI asynchronously.

Arguments:

  • docs (list[Any]): List of text documents to encode.

Returns:

list[list[float]]: List of embeddings for each document.

On this page