Class WatsonxEmbeddingModel

java.lang.Object
dev.langchain4j.model.watsonx.WatsonxEmbeddingModel
All Implemented Interfaces:
dev.langchain4j.model.embedding.EmbeddingModel

public class WatsonxEmbeddingModel extends Object implements dev.langchain4j.model.embedding.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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder class for constructing WatsonxEmbeddingModel instances with configurable parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a new WatsonxEmbeddingModel.Builder instance.
    dev.langchain4j.model.output.Response<List<dev.langchain4j.data.embedding.Embedding>>
    embedAll(List<dev.langchain4j.data.segment.TextSegment> textSegments)
     
    dev.langchain4j.model.output.Response<List<dev.langchain4j.data.embedding.Embedding>>
    embedAll(List<dev.langchain4j.data.segment.TextSegment> textSegments, com.ibm.watsonx.ai.embedding.EmbeddingParameters parameters)
    Embeds the text content of a list of TextSegment using the specified EmbeddingParameters.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface dev.langchain4j.model.embedding.EmbeddingModel

    dimension, embed, embed
  • Method Details

    • embedAll

      public dev.langchain4j.model.output.Response<List<dev.langchain4j.data.embedding.Embedding>> embedAll(List<dev.langchain4j.data.segment.TextSegment> textSegments)
      Specified by:
      embedAll in interface dev.langchain4j.model.embedding.EmbeddingModel
    • embedAll

      public dev.langchain4j.model.output.Response<List<dev.langchain4j.data.embedding.Embedding>> embedAll(List<dev.langchain4j.data.segment.TextSegment> textSegments, com.ibm.watsonx.ai.embedding.EmbeddingParameters parameters)
      Embeds the text content of a list of TextSegment using the specified EmbeddingParameters.
      Parameters:
      textSegments - the text segments to embed.
      parameters - the embedding parameters to use.
      Returns:
      the embeddings.
    • builder

      public static WatsonxEmbeddingModel.Builder builder()
      Returns a new WatsonxEmbeddingModel.Builder instance.

      Example usage:

      EmbeddingModel embeddingModel = WatsonxEmbeddingModel.builder()
          .url("https://...") // or use CloudRegion
          .apiKey("...")
          .projectId("...")
          .modelName("ibm/granite-embedding-278m-multilingual")
          .build();
      
      Returns:
      WatsonxEmbeddingModel.Builder instance.