Package dev.langchain4j.model.openai
Class OpenAiEmbeddingModel
java.lang.Object
dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dev.langchain4j.model.openai.OpenAiEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel
,TokenCountEstimator
public class OpenAiEmbeddingModel
extends DimensionAwareEmbeddingModel
implements TokenCountEstimator
Represents an OpenAI embedding model, such as text-embedding-ada-002.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dimension
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
embedAll
(List<TextSegment> textSegments) Embeds the text content of a list of TextSegments.int
estimateTokenCount
(String text) Estimates the count of tokens in the given text.protected Integer
When known (e.g., can be derived from the model name), returns the dimension of theEmbedding
produced by this embedding model.static OpenAiEmbeddingModel
withApiKey
(String apiKey) Methods inherited from class dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dimension
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.model.embedding.EmbeddingModel
embed, embed
Methods inherited from interface dev.langchain4j.model.embedding.TokenCountEstimator
estimateTokenCount, estimateTokenCount
-
Constructor Details
-
OpenAiEmbeddingModel
-
-
Method Details
-
knownDimension
Description copied from class:DimensionAwareEmbeddingModel
When known (e.g., can be derived from the model name), returns the dimension of theEmbedding
produced by this embedding model. Otherwise, it returnsnull
.- Overrides:
knownDimension
in classDimensionAwareEmbeddingModel
- Returns:
- the known dimension of the
Embedding
, ornull
if unknown.
-
modelName
-
embedAll
Description copied from interface:EmbeddingModel
Embeds the text content of a list of TextSegments.- Specified by:
embedAll
in interfaceEmbeddingModel
- Parameters:
textSegments
- the text segments to embed.- Returns:
- the embeddings.
-
estimateTokenCount
Description copied from interface:TokenCountEstimator
Estimates the count of tokens in the given text.- Specified by:
estimateTokenCount
in interfaceTokenCountEstimator
- Parameters:
text
- the text.- Returns:
- the estimated count of tokens.
-
withApiKey
-
builder
-