Class PostgresMlEmbeddingModel
java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingModel
org.springframework.ai.postgresml.PostgresMlEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel
,Model<EmbeddingRequest,
,EmbeddingResponse> org.springframework.beans.factory.InitializingBean
public class PostgresMlEmbeddingModel
extends AbstractEmbeddingModel
implements org.springframework.beans.factory.InitializingBean
PostgresML EmbeddingModel
- Author:
- Toshiaki Maki, Christian Tzolov
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.springframework.ai.embedding.AbstractEmbeddingModel
embeddingDimensions
-
Constructor Summary
ConstructorDescriptionPostgresMlEmbeddingModel
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) a constructorPostgresMlEmbeddingModel
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer) Deprecated, for removal: This API element is subject to removal in a future version.PostgresMlEmbeddingModel
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer, PostgresMlEmbeddingModel.VectorType vectorType) Deprecated, for removal: This API element is subject to removal in a future version.PostgresMlEmbeddingModel
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer, PostgresMlEmbeddingModel.VectorType vectorType, Map<String, Object> kwargs, MetadataMode metadataMode) Deprecated, for removal: This API element is subject to removal in a future version.PostgresMlEmbeddingModel
(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, PostgresMlEmbeddingOptions options) a PostgresMlEmbeddingModel constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
call
(EmbeddingRequest request) Executes a method call to the AI model.float[]
Embeds the given text into a vector.float[]
Embeds the given document's content into a vector.Methods inherited from class org.springframework.ai.embedding.AbstractEmbeddingModel
dimensions, dimensions
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.embedding.EmbeddingModel
embed, embed, embedForResponse
-
Field Details
-
DEFAULT_TRANSFORMER_MODEL
- See Also:
-
-
Constructor Details
-
PostgresMlEmbeddingModel
public PostgresMlEmbeddingModel(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate) a constructor- Parameters:
jdbcTemplate
- JdbcTemplate
-
PostgresMlEmbeddingModel
public PostgresMlEmbeddingModel(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, PostgresMlEmbeddingOptions options) a PostgresMlEmbeddingModel constructor- Parameters:
jdbcTemplate
- JdbcTemplate to use to interact with the database.options
- PostgresMlEmbeddingOptions to configure the client.
-
PostgresMlEmbeddingModel
@Deprecated(since="0.8.0", forRemoval=true) public PostgresMlEmbeddingModel(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
- JdbcTemplatetransformer
- huggingface sentence-transformer name
-
PostgresMlEmbeddingModel
@Deprecated(since="0.8.0", forRemoval=true) public PostgresMlEmbeddingModel(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer, PostgresMlEmbeddingModel.VectorType vectorType) Deprecated, for removal: This API element is subject to removal in a future version.Use the constructor withPostgresMlEmbeddingOptions
instead.a constructor- Parameters:
jdbcTemplate
- JdbcTemplatetransformer
- huggingface sentence-transformer namevectorType
- vector type in PostgreSQL
-
PostgresMlEmbeddingModel
@Deprecated(since="0.8.0", forRemoval=true) public PostgresMlEmbeddingModel(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, String transformer, PostgresMlEmbeddingModel.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 withPostgresMlEmbeddingOptions
instead.- Parameters:
jdbcTemplate
- JdbcTemplatetransformer
- huggingface sentence-transformer namevectorType
- vector type in PostgreSQLkwargs
- optional arguments
-
-
Method Details
-
embed
Description copied from interface:EmbeddingModel
Embeds the given text into a vector.- Specified by:
embed
in interfaceEmbeddingModel
- Parameters:
text
- the text to embed.- Returns:
- the embedded vector.
-
embed
Description copied from interface:EmbeddingModel
Embeds the given document's content into a vector.- Specified by:
embed
in interfaceEmbeddingModel
- Parameters:
document
- the document to embed.- Returns:
- the embedded vector.
-
call
Description copied from interface:Model
Executes a method call to the AI model.- Specified by:
call
in interfaceEmbeddingModel
- Specified by:
call
in interfaceModel<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 interfaceorg.springframework.beans.factory.InitializingBean
-
PostgresMlEmbeddingOptions
instead.