Class PostgresMlEmbeddingClient

java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingClient
org.springframework.ai.postgresml.PostgresMlEmbeddingClient
All Implemented Interfaces:
EmbeddingClient, ModelClient<EmbeddingRequest,EmbeddingResponse>, org.springframework.beans.factory.InitializingBean

public class PostgresMlEmbeddingClient extends AbstractEmbeddingClient implements org.springframework.beans.factory.InitializingBean
PostgresML EmbeddingClient
Author:
Toshiaki Maki, Christian Tzolov
  • Field Details

  • Constructor Details

    • PostgresMlEmbeddingClient

      public PostgresMlEmbeddingClient(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
      a constructor
      Parameters:
      jdbcTemplate - JdbcTemplate
    • PostgresMlEmbeddingClient

      public PostgresMlEmbeddingClient(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, PostgresMlEmbeddingOptions options)
      a PostgresMlEmbeddingClient constructor
      Parameters:
      jdbcTemplate - JdbcTemplate to use to interact with the database.
      options - PostgresMlEmbeddingOptions to configure the client.
    • PostgresMlEmbeddingClient

      @Deprecated(since="0.8.0", forRemoval=true) public PostgresMlEmbeddingClient(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      a constructor
      Parameters:
      jdbcTemplate - JdbcTemplate
      transformer - huggingface sentence-transformer name
    • PostgresMlEmbeddingClient

      @Deprecated(since="0.8.0", forRemoval=true) public PostgresMlEmbeddingClient(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer, PostgresMlEmbeddingClient.VectorType vectorType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use the constructor with PostgresMlEmbeddingOptions instead.
      a constructor
      Parameters:
      jdbcTemplate - JdbcTemplate
      transformer - huggingface sentence-transformer name
      vectorType - vector type in PostgreSQL
    • PostgresMlEmbeddingClient

      @Deprecated(since="0.8.0", forRemoval=true) public PostgresMlEmbeddingClient(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer, PostgresMlEmbeddingClient.VectorType vectorType, Map<String,Object> kwargs, MetadataMode metadataMode)
      Deprecated, for removal: This API element is subject to removal in a future version.
      a constructor * @deprecated Use the constructor with PostgresMlEmbeddingOptions instead.
      Parameters:
      jdbcTemplate - JdbcTemplate
      transformer - huggingface sentence-transformer name
      vectorType - vector type in PostgreSQL
      kwargs - optional arguments
  • Method Details

    • embed

      public List<Double> embed(String text)
      Description copied from interface: EmbeddingClient
      Embeds the given text into a vector.
      Specified by:
      embed in interface EmbeddingClient
      Parameters:
      text - the text to embed.
      Returns:
      the embedded vector.
    • embed

      public List<Double> embed(Document document)
      Description copied from interface: EmbeddingClient
      Embeds the given document's content into a vector.
      Specified by:
      embed in interface EmbeddingClient
      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.
      Specified by:
      call in interface EmbeddingClient
      Specified by:
      call in interface ModelClient<EmbeddingRequest,EmbeddingResponse>
      Parameters:
      request - the request object to be sent to the AI model
      Returns:
      the response from the AI model
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean