Class OpenAiEmbeddingModel
java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingModel
org.springframework.ai.openai.OpenAiEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel, Model<EmbeddingRequest, EmbeddingResponse>
Open AI Embedding Model implementation.
- Author:
- Christian Tzolov, Thomas Vitale, Josh Long
-
Field Summary
Fields inherited from class AbstractEmbeddingModel
embeddingDimensions -
Constructor Summary
ConstructorsConstructorDescriptionOpenAiEmbeddingModel(OpenAiApi openAiApi) Constructor for the OpenAiEmbeddingModel class.OpenAiEmbeddingModel(OpenAiApi openAiApi, MetadataMode metadataMode) Initializes a new instance of the OpenAiEmbeddingModel class.OpenAiEmbeddingModel(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions openAiEmbeddingOptions) Initializes a new instance of the OpenAiEmbeddingModel class.OpenAiEmbeddingModel(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions options, org.springframework.core.retry.RetryTemplate retryTemplate) Initializes a new instance of the OpenAiEmbeddingModel class.OpenAiEmbeddingModel(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions options, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Initializes a new instance of the OpenAiEmbeddingModel class. -
Method Summary
Modifier and TypeMethodDescriptioncall(EmbeddingRequest request) Executes a method call to the AI model.float[]Embeds the given document's content into a vector.voidsetObservationConvention(EmbeddingModelObservationConvention observationConvention) Use the provided convention for reporting observation dataMethods inherited from class AbstractEmbeddingModel
dimensions, dimensionsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EmbeddingModel
embed, embed, embed, embedForResponse
-
Constructor Details
-
OpenAiEmbeddingModel
Constructor for the OpenAiEmbeddingModel class.- Parameters:
openAiApi- The OpenAiApi instance to use for making API requests.
-
OpenAiEmbeddingModel
Initializes a new instance of the OpenAiEmbeddingModel class.- Parameters:
openAiApi- The OpenAiApi instance to use for making API requests.metadataMode- The mode for generating metadata.
-
OpenAiEmbeddingModel
public OpenAiEmbeddingModel(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions openAiEmbeddingOptions) Initializes a new instance of the OpenAiEmbeddingModel class.- Parameters:
openAiApi- The OpenAiApi instance to use for making API requests.metadataMode- The mode for generating metadata.openAiEmbeddingOptions- The options for OpenAi embedding.
-
OpenAiEmbeddingModel
public OpenAiEmbeddingModel(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions options, org.springframework.core.retry.RetryTemplate retryTemplate) Initializes a new instance of the OpenAiEmbeddingModel 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.
-
OpenAiEmbeddingModel
public OpenAiEmbeddingModel(OpenAiApi openAiApi, MetadataMode metadataMode, OpenAiEmbeddingOptions options, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Initializes a new instance of the OpenAiEmbeddingModel 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.observationRegistry- - The ObservationRegistry used for instrumentation.
-
-
Method Details
-
embed
Description copied from interface:EmbeddingModelEmbeds the given document's content into a vector.- Parameters:
document- the document to embed.- Returns:
- the embedded vector.
-
call
Description copied from interface:ModelExecutes 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
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention- The provided convention
-