Class OpenAiSpringEmbeddingModel
java.lang.Object
com.sap.ai.sdk.foundationmodels.openai.spring.OpenAiSpringEmbeddingModel
- All Implemented Interfaces:
org.springframework.ai.embedding.EmbeddingModel,org.springframework.ai.model.Model<org.springframework.ai.embedding.EmbeddingRequest,org.springframework.ai.embedding.EmbeddingResponse>
public class OpenAiSpringEmbeddingModel
extends Object
implements org.springframework.ai.embedding.EmbeddingModel
SpringAI integration with
OpenAiClient to generate embeddings.
This model transforms an EmbeddingRequest into an Azure OpenAI request, processes the
response, and returns a Spring AI EmbeddingResponse.
- Since:
- 1.5.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs anOpenAiSpringEmbeddingModelwith the specifiedOpenAiClientof some model.OpenAiSpringEmbeddingModel(OpenAiClient client, org.springframework.ai.document.MetadataMode metadataMode) Constructs anOpenAiSpringEmbeddingModelwith the specifiedOpenAiClientof some model and metadata mode. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.embedding.EmbeddingModel
dimensions, embed, embed, embed, embedForResponse, getEmbeddingContent
-
Constructor Details
-
OpenAiSpringEmbeddingModel
Constructs anOpenAiSpringEmbeddingModelwith the specifiedOpenAiClientof some model.- Parameters:
client- the OpenAI client
-
OpenAiSpringEmbeddingModel
public OpenAiSpringEmbeddingModel(@Nonnull OpenAiClient client, @Nonnull org.springframework.ai.document.MetadataMode metadataMode) Constructs anOpenAiSpringEmbeddingModelwith the specifiedOpenAiClientof some model and metadata mode.The metadata mode is used by content formatter to determine which metadata to include in the resulting content. Currently, the formatter is only effective for calls to
embed(Document).- Parameters:
client- the OpenAI clientmetadataMode- the metadata mode
-
-
Method Details
-
call
@Nonnull public org.springframework.ai.embedding.EmbeddingResponse call(@Nonnull org.springframework.ai.embedding.EmbeddingRequest request) throws IllegalArgumentException - Specified by:
callin interfaceorg.springframework.ai.embedding.EmbeddingModel- Specified by:
callin interfaceorg.springframework.ai.model.Model<org.springframework.ai.embedding.EmbeddingRequest,org.springframework.ai.embedding.EmbeddingResponse> - Throws:
IllegalArgumentException- ifrequest.getOptions().getModel()is not null.
-
embed
@Nonnull public float[] embed(@Nonnull org.springframework.ai.document.Document document) throws UnsupportedOperationException - Specified by:
embedin interfaceorg.springframework.ai.embedding.EmbeddingModel- Throws:
UnsupportedOperationException
-