Class OpenAiEmbeddingClient

java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingClient
org.springframework.ai.openai.OpenAiEmbeddingClient
All Implemented Interfaces:
EmbeddingClient, ModelClient<EmbeddingRequest,EmbeddingResponse>

public class OpenAiEmbeddingClient extends AbstractEmbeddingClient
Open AI Embedding Client implementation.
Author:
Christian Tzolov
  • Constructor Details

    • OpenAiEmbeddingClient

      public OpenAiEmbeddingClient(OpenAiApi openAiApi)
      Constructor for the OpenAiEmbeddingClient class.
      Parameters:
      openAiApi - The OpenAiApi instance to use for making API requests.
    • OpenAiEmbeddingClient

      public OpenAiEmbeddingClient(OpenAiApi openAiApi, MetadataMode metadataMode)
      Initializes a new instance of the OpenAiEmbeddingClient class.
      Parameters:
      openAiApi - The OpenAiApi instance to use for making API requests.
      metadataMode - The mode for generating metadata.
    • OpenAiEmbeddingClient

      public OpenAiEmbeddingClient(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions openAiEmbeddingOptions)
      Initializes a new instance of the OpenAiEmbeddingClient class.
      Parameters:
      openAiApi - The OpenAiApi instance to use for making API requests.
      metadataMode - The mode for generating metadata.
      openAiEmbeddingOptions - The options for OpenAi embedding.
    • OpenAiEmbeddingClient

      public OpenAiEmbeddingClient(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions options, org.springframework.retry.support.RetryTemplate retryTemplate)
      Initializes a new instance of the OpenAiEmbeddingClient class.
      Parameters:
      openAiApi - - The OpenAiApi instance to use for making API requests.
      metadataMode - - The mode for generating metadata.
      options - - The options for OpenAI embedding.
      retryTemplate - - The RetryTemplate for retrying failed API requests.
  • Method Details

    • embed

      public List<Double> embed(Document document)
      Description copied from interface: EmbeddingClient
      Embeds the given document's content into a vector.
      Parameters:
      document - the document to embed.
      Returns:
      the embedded vector.
    • call

      public EmbeddingResponse call(EmbeddingRequest request)
      Description copied from interface: ModelClient
      Executes a method call to the AI model.
      Parameters:
      request - the request object to be sent to the AI model
      Returns:
      the response from the AI model