pyseekdb.utils.embedding_functions.MistralEmbeddingFunction

class pyseekdb.utils.embedding_functions.MistralEmbeddingFunction(model_name: str = 'mistral-embed', api_key_env: str | None = None, api_base: str | None = None, dimensions: int | None = None, **kwargs: Any)[source]

Bases: OpenAIBaseEmbeddingFunction

A convenient embedding function for Mistral text embedding models.

This class provides a simplified interface to Mistral text embeddings using the OpenAI-compatible API.

Note: The embeddings API only accepts the model name and input texts.

For more information about Mistral embeddings, see: https://docs.mistral.ai/capabilities/embeddings/text_embeddings

Example

pip install pyseekdb openai

__init__(model_name: str = 'mistral-embed', api_key_env: str | None = None, api_base: str | None = None, dimensions: int | None = None, **kwargs: Any)[source]

Initialize MistralEmbeddingFunction.

Parameters:
  • model_name (str, optional) – Name of the Mistral embedding model. Defaults to “mistral-embed”.

  • api_key_env (str, optional) – Name of the environment variable containing the Mistral API key. Defaults to “MISTRAL_API_KEY” if not provided.

  • api_base (str, optional) – Base URL for the Mistral API endpoint. Defaults to “https://api.mistral.ai/v1” if not provided.

  • dimensions (int, optional) – This parameter is not supported by the Mistral embeddings API. If provided, a warning will be issued and the parameter will be ignored.

  • **kwargs – Additional arguments to pass to the OpenAI client. Common options include: - timeout: Request timeout in seconds - max_retries: Maximum number of retries - See https://github.com/openai/openai-python for more options

Methods

__init__([model_name, api_key_env, ...])

Initialize MistralEmbeddingFunction.

build_from_config(config)

get_config()

Get the configuration dictionary for the OpenAIBaseEmbeddingFunction.

name()

support_persistence(embedding_function)

Check if the embedding function supports persistence.

Attributes

dimension

Get the dimension of embeddings produced by this function.

get_config() dict[str, Any][source]

Get the configuration dictionary for the OpenAIBaseEmbeddingFunction.

Subclasses should override the name() method to provide the correct name for routing.

Returns:

Dictionary containing configuration needed to restore this embedding function