Class MistralAiEmbeddingModel

java.lang.Object
dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dev.langchain4j.model.mistralai.MistralAiEmbeddingModel
All Implemented Interfaces:
EmbeddingModel

public class MistralAiEmbeddingModel extends DimensionAwareEmbeddingModel
Represents a Mistral AI embedding model, such as mistral-embed. You can find description of parameters here.
  • Constructor Details

    • MistralAiEmbeddingModel

      public MistralAiEmbeddingModel(String baseUrl, String apiKey, String modelName, Duration timeout, Boolean logRequests, Boolean logResponses, Integer maxRetries)
      Constructs a new MistralAiEmbeddingModel instance.
      Parameters:
      baseUrl - the base URL of the Mistral AI API. It use a default value if not specified
      apiKey - the API key for authentication
      modelName - the name of the embedding model. It uses a default value if not specified
      timeout - the timeout duration for API requests. It uses a default value of 60 seconds if not specified

      The default value is 60 seconds

      logRequests - a flag indicating whether to log API requests
      logResponses - a flag indicating whether to log API responses
      maxRetries - the maximum number of retries for API requests. It uses a default value of 3 if not specified
  • Method Details

    • withApiKey

      public static MistralAiEmbeddingModel withApiKey(String apiKey)
      Creates a new MistralAiEmbeddingModel instance with the specified API key.
      Parameters:
      apiKey - the Mistral AI API key for authentication
      Returns:
      a new MistralAiEmbeddingModel instance
    • embedAll

      public Response<List<Embedding>> embedAll(List<TextSegment> textSegments)
      Embeds a list of text segments using the Mistral AI embedding model.
      Parameters:
      textSegments - the list of text segments to embed
      Returns:
      a Response object containing the embeddings and token usage information
    • builder