Package org.springframework.ai.openaisdk
Class OpenAiSdkEmbeddingModel
java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingModel
org.springframework.ai.openaisdk.OpenAiSdkEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel,Model<EmbeddingRequest,EmbeddingResponse>
Embedding Model implementation using the OpenAI Java SDK.
- Author:
- Julien Dubois
-
Field Summary
Fields inherited from class org.springframework.ai.embedding.AbstractEmbeddingModel
embeddingDimensions -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new OpenAiSdkEmbeddingModel with default options.OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient) Creates a new OpenAiSdkEmbeddingModel with the given OpenAI client.OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient, MetadataMode metadataMode) Creates a new OpenAiSdkEmbeddingModel with the given OpenAI client and metadata mode.OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient, MetadataMode metadataMode, OpenAiSdkEmbeddingOptions options) Creates a new OpenAiSdkEmbeddingModel with all configuration options.OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient, MetadataMode metadataMode, OpenAiSdkEmbeddingOptions options, io.micrometer.observation.ObservationRegistry observationRegistry) Creates a new OpenAiSdkEmbeddingModel with all configuration options.OpenAiSdkEmbeddingModel(MetadataMode metadataMode, OpenAiSdkEmbeddingOptions options) Creates a new OpenAiSdkEmbeddingModel with the given metadata mode and options.OpenAiSdkEmbeddingModel(MetadataMode metadataMode, OpenAiSdkEmbeddingOptions options, io.micrometer.observation.ObservationRegistry observationRegistry) Creates a new OpenAiSdkEmbeddingModel with the given metadata mode, options, and observation registry.Creates a new OpenAiSdkEmbeddingModel with the given options.OpenAiSdkEmbeddingModel(OpenAiSdkEmbeddingOptions options, io.micrometer.observation.ObservationRegistry observationRegistry) Creates a new OpenAiSdkEmbeddingModel with the given options and observation registry. -
Method Summary
Modifier and TypeMethodDescriptioncall(EmbeddingRequest embeddingRequest) Executes a method call to the AI model.float[]Embeds the given document's content into a vector.Gets the embedding options for this model.voidsetObservationConvention(EmbeddingModelObservationConvention observationConvention) Use the provided convention for reporting observation dataMethods inherited from class org.springframework.ai.embedding.AbstractEmbeddingModel
dimensions, dimensionsMethods 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
embed, embed, embed, embedForResponse
-
Constructor Details
-
OpenAiSdkEmbeddingModel
public OpenAiSdkEmbeddingModel()Creates a new OpenAiSdkEmbeddingModel with default options. -
OpenAiSdkEmbeddingModel
Creates a new OpenAiSdkEmbeddingModel with the given options.- Parameters:
options- the embedding options
-
OpenAiSdkEmbeddingModel
Creates a new OpenAiSdkEmbeddingModel with the given metadata mode and options.- Parameters:
metadataMode- the metadata modeoptions- the embedding options
-
OpenAiSdkEmbeddingModel
public OpenAiSdkEmbeddingModel(OpenAiSdkEmbeddingOptions options, io.micrometer.observation.ObservationRegistry observationRegistry) Creates a new OpenAiSdkEmbeddingModel with the given options and observation registry.- Parameters:
options- the embedding optionsobservationRegistry- the observation registry
-
OpenAiSdkEmbeddingModel
public OpenAiSdkEmbeddingModel(MetadataMode metadataMode, OpenAiSdkEmbeddingOptions options, io.micrometer.observation.ObservationRegistry observationRegistry) Creates a new OpenAiSdkEmbeddingModel with the given metadata mode, options, and observation registry.- Parameters:
metadataMode- the metadata modeoptions- the embedding optionsobservationRegistry- the observation registry
-
OpenAiSdkEmbeddingModel
public OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient) Creates a new OpenAiSdkEmbeddingModel with the given OpenAI client.- Parameters:
openAiClient- the OpenAI client
-
OpenAiSdkEmbeddingModel
public OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient, MetadataMode metadataMode) Creates a new OpenAiSdkEmbeddingModel with the given OpenAI client and metadata mode.- Parameters:
openAiClient- the OpenAI clientmetadataMode- the metadata mode
-
OpenAiSdkEmbeddingModel
public OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient, MetadataMode metadataMode, OpenAiSdkEmbeddingOptions options) Creates a new OpenAiSdkEmbeddingModel with all configuration options.- Parameters:
openAiClient- the OpenAI clientmetadataMode- the metadata modeoptions- the embedding options
-
OpenAiSdkEmbeddingModel
public OpenAiSdkEmbeddingModel(com.openai.client.OpenAIClient openAiClient, MetadataMode metadataMode, OpenAiSdkEmbeddingOptions options, io.micrometer.observation.ObservationRegistry observationRegistry) Creates a new OpenAiSdkEmbeddingModel with all configuration options.- Parameters:
openAiClient- the OpenAI clientmetadataMode- the metadata modeoptions- the embedding optionsobservationRegistry- the observation registry
-
-
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:
embeddingRequest- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
getOptions
Gets the embedding options for this model.- Returns:
- the embedding options
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention- The provided convention
-