Class DashScopeTextEmbedding

java.lang.Object
io.agentscope.core.embedding.dashscope.DashScopeTextEmbedding
All Implemented Interfaces:
EmbeddingModel

public class DashScopeTextEmbedding extends Object implements EmbeddingModel
DashScope Text Embedding Model implementation.

This implementation provides access to DashScope's text embedding API, supporting both single text embedding and batch embedding operations.

Supports only TextBlock content blocks. Other content block types will result in an EmbeddingException.

Supports timeout and retry configuration through ExecutionConfig.

  • Constructor Details

    • DashScopeTextEmbedding

      public DashScopeTextEmbedding(String apiKey, String modelName, int dimensions, io.agentscope.core.model.ExecutionConfig defaultExecutionConfig, String baseUrl)
      Creates a new DashScope text embedding model instance.
      Parameters:
      apiKey - the API key for DashScope authentication
      modelName - the model name (e.g., "text-embedding-v3")
      dimensions - the dimension of embedding vectors
      defaultExecutionConfig - default execution configuration for timeout and retry
      baseUrl - custom base URL for DashScope API (null for default)
  • Method Details

    • builder

      public static DashScopeTextEmbedding.Builder builder()
      Creates a new builder for DashScopeTextEmbedding.
      Returns:
      a new Builder instance
    • embed

      public reactor.core.publisher.Mono<double[]> embed(io.agentscope.core.message.ContentBlock block)
      Description copied from interface: EmbeddingModel
      Generate embedding vector for a single content block.

      Implementations should check the content block type and throw EmbeddingException if the type is not supported.

      Specified by:
      embed in interface EmbeddingModel
      Parameters:
      block - the content block to embed (e.g., TextBlock, ImageBlock)
      Returns:
      Mono that emits a double array representing the embedding vector
    • getModelName

      public String getModelName()
      Description copied from interface: EmbeddingModel
      Get the model name for logging and identification.
      Specified by:
      getModelName in interface EmbeddingModel
      Returns:
      the model name
    • getDimensions

      public int getDimensions()
      Description copied from interface: EmbeddingModel
      Get the dimension of embedding vectors produced by this model. The default value is 1024 if not specified.
      Specified by:
      getDimensions in interface EmbeddingModel
      Returns:
      the dimension of embedding vectors