Class WatsonxEmbeddingModel
java.lang.Object
dev.langchain4j.model.watsonx.WatsonxEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel
A
EmbeddingModel implementation that integrates IBM watsonx.ai with LangChain4j.
Example usage:
EmbeddingModel embeddingModel = WatsonxEmbeddingModel.builder()
.url("https://...") // or use CloudRegion
.apiKey("...")
.projectId("...")
.modelName("ibm/granite-embedding-278m-multilingual")
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for constructingWatsonxEmbeddingModelinstances with configurable parameters. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Returns a newWatsonxEmbeddingModel.Builderinstance.embedAll(List<TextSegment> textSegments) Embeds the text content of a list of TextSegments.embedAll(List<TextSegment> textSegments, com.ibm.watsonx.ai.embedding.EmbeddingParameters parameters) Embeds the text content of a list of TextSegment using the specifiedEmbeddingParameters.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EmbeddingModel
dimension, embed, embed
-
Method Details
-
embedAll
Description copied from interface:EmbeddingModelEmbeds the text content of a list of TextSegments.- Specified by:
embedAllin interfaceEmbeddingModel- Parameters:
textSegments- the text segments to embed.- Returns:
- the embeddings.
-
embedAll
public Response<List<Embedding>> embedAll(List<TextSegment> textSegments, com.ibm.watsonx.ai.embedding.EmbeddingParameters parameters) Embeds the text content of a list of TextSegment using the specifiedEmbeddingParameters.- Parameters:
textSegments- the text segments to embed.parameters- the embedding parameters to use.- Returns:
- the embeddings.
-
builder
Returns a newWatsonxEmbeddingModel.Builderinstance.Example usage:
EmbeddingModel embeddingModel = WatsonxEmbeddingModel.builder() .url("https://...") // or use CloudRegion .apiKey("...") .projectId("...") .modelName("ibm/granite-embedding-278m-multilingual") .build();- Returns:
WatsonxEmbeddingModel.Builderinstance.
-