Class BedrockTitanEmbeddingModel

java.lang.Object
dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dev.langchain4j.model.bedrock.BedrockTitanEmbeddingModel
All Implemented Interfaces:
EmbeddingModel

public class BedrockTitanEmbeddingModel extends DimensionAwareEmbeddingModel
Bedrock Amazon Titan embedding model with support for both versions: amazon.titan-embed-text-v1 and amazon.titan-embed-text-v2:0
See more details here and here.
  • Constructor Details

  • Method Details

    • getModelId

      protected String getModelId()
      Get model id
      Returns:
      model id
    • knownDimension

      protected Integer knownDimension()
      Description copied from class: DimensionAwareEmbeddingModel
      When known (e.g., can be derived from the model name), returns the dimension of the Embedding produced by this embedding model. Otherwise, it returns null.
      Overrides:
      knownDimension in class DimensionAwareEmbeddingModel
      Returns:
      the known dimension of the Embedding, or null if unknown.
    • getRequestParameters

      protected List<Map<String,Object>> getRequestParameters(List<TextSegment> textSegments)
      Get request body
      Parameters:
      textSegments - Input texts to convert to embedding
      Returns:
      request body
    • getResponseClassType

      protected Class<dev.langchain4j.model.bedrock.BedrockTitanEmbeddingResponse> getResponseClassType()
      Get response class type
      Returns:
      response class type
    • getModel

      public String getModel()
    • getDimensions

      public Integer getDimensions()
    • getNormalize

      public Boolean getNormalize()
    • builder

    • embedAll

      public Response<List<Embedding>> embedAll(List<TextSegment> textSegments)
      Description copied from interface: EmbeddingModel
      Embeds the text content of a list of TextSegments.
      Parameters:
      textSegments - the text segments to embed.
      Returns:
      the embeddings.
    • getClient

      public software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient getClient()
    • invoke

      protected software.amazon.awssdk.services.bedrockruntime.model.InvokeModelResponse invoke(String body)
      Invoke model
      Parameters:
      body - body
      Returns:
      invoke model response
    • of

      protected static Map<String,Object> of(String key, Object value)
      Create map with single entry
      Parameters:
      key - key
      value - value
      Returns:
      map
    • getRegion

      public software.amazon.awssdk.regions.Region getRegion()
    • getCredentialsProvider

      public software.amazon.awssdk.auth.credentials.AwsCredentialsProvider getCredentialsProvider()
    • getMaxRetries

      public Integer getMaxRetries()