Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.phidata.com/llms.txt

Use this file to discover all available pages before exploring further.

The MistralEmbedder class is used to embed text data into vectors using the Mistral API. Get your key from here.

Usage

cookbook/embedders/mistral_embedder.py
from phi.agent import AgentKnowledge
from phi.vectordb.pgvector import PgVector
from phi.embedder.mistral import MistralEmbedder

embeddings = MistralEmbedder().get_embedding("The quick brown fox jumps over the lazy dog.")

# Print the embeddings and their dimensions
print(f"Embeddings: {embeddings[:5]}")
print(f"Dimensions: {len(embeddings)}")

# Example usage:
knowledge_base = AgentKnowledge(
    vector_db=PgVector(
        db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
        table_name="mistral_embeddings",
        embedder=MistralEmbedder(),
    ),
    num_documents=2,
)

Params

ParameterTypeDefaultDescription
modelstr"mistral-embed"The name of the model used for generating embeddings.
dimensionsint1024The dimensionality of the embeddings generated by the model.
request_paramsOptional[Dict[str, Any]]-Additional parameters to include in the API request. Optional.
api_keystr-The API key used for authenticating requests.
endpointstr-The endpoint URL for the API requests.
max_retriesOptional[int]-The maximum number of retries for API requests. Optional.
timeoutOptional[int]-The timeout duration for API requests. Optional.
client_paramsOptional[Dict[str, Any]]-Additional parameters for configuring the API client. Optional.
mistral_clientOptional[MistralClient]-An instance of the MistralClient to use for making API requests. Optional.