AS AgentScopeAPI 手册 / API Reference
类class agentscope.embedding

DashScopeEmbeddingModel

class DashScopeEmbeddingModel(EmbeddingModelBase[str | TextBlock | DataBlock])
源码Source agentscope/embedding/_dashscope/_model.py:91–533

DashScope 向量化模型,与模型服务通信并返回生成或向量化结果。位于 agentscope.embedding 包,继承自 EmbeddingModelBase[str | TextBlock | DataBlock]。

Routes to the text or multimodal DashScope API based on the model name.

  • Text mode (text-embedding-*): uses the base class's simple batch splitting + concurrent retry.
  • Multimodal mode (qwen*-vl-*, multimodal-*, tongyi-embedding-vision-*): overrides __call__ to perform content-aware batching that respects per-model limits on total elements, images, and videos per request.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(credential: CredentialBase, model: str, dimensions: int | None, parameters: 'DashScopeEmbeddingModel.Param…
初始化 `DashScopeEmbeddingModel` 实例。
Initialize the DashScope embedding model.

方法摘要Method Summary

方法Method说明Description
async def __call__(inputs: list[str | TextBlock | DataBlock], **kwargs: Any) -> EmbeddingResponseasync
以可调用对象方式执行。
Embed inputs with batching and retry.

构造器详情Constructor Detail

DashScopeEmbeddingModel

def __init__(credential: CredentialBase, model: str, dimensions: int | None, parameters: 'DashScopeEmbeddingModel.Parameters | None' = None, embedding_cache: EmbeddingCacheBase | None = None, context_size: int = 8192, max_retries: int = 3, retry_delay: float = 1.0) -> None

初始化 DashScopeEmbeddingModel 实例。

Initialize the DashScope embedding model.

参数Parameters
名称Name类型Type说明Description
credentialCredentialBase凭证对象(类型 `CredentialBase`)。A :class:`~agentscope.credential.DashScopeCredential` instance providing the API key.
modelstr模型实例(类型 `str`)。The embedding model name (e.g. `"text-embedding-v4"` or `"qwen3-vl-embedding"`).
dimensionsint | None向量维度(类型 `int | None`)。The output embedding vector dimensions. Required at the contract level — see :class:`EmbeddingModelBase` for the rationale. `None` is accepted only for backward compatibility with legacy configs that persisted `dimensions` inside `parameters`.
parameters默认default None'DashScopeEmbeddingModel.Parameters | None'参数(类型 `'DashScopeEmbeddingModel.Parameters | None'`)。Provider-specific non-dimensional parameters. Currently empty for DashScope.
embedding_cache默认default NoneEmbeddingCacheBase | None向量化缓存(类型 `EmbeddingCacheBase | None`)。Optional embedding cache.
context_size默认default 8192int上下文大小(类型 `int`)。Maximum input tokens per text.
max_retries默认default 3int最大重试次数(类型 `int`)。Number of retries on transient failures.
retry_delay默认default 1.0float重试延迟(类型 `float`)。Seconds between retry attempts.
源码Source agentscope/embedding/_dashscope/_model.py:109–166

方法详情Method Detail

__call__

async def __call__(inputs: list[str | TextBlock | DataBlock], **kwargs: Any) -> EmbeddingResponse
async

以可调用对象方式执行。

For text models, delegates to the base class (simple batch_size splitting).

参数Parameters
名称Name类型Type说明Description
inputslist[str | TextBlock | DataBlock]输入消息(类型 `list[str | TextBlock | DataBlock]`)。The input data to embed. `TextBlock` items are unpacked to their `.text` field on entry, so the remainder of the pipeline only sees `str` and `DataBlock`.
kwargsAny关键字参数(类型 `Any`)。The kwargs.
返回Returns EmbeddingResponse
返回EmbeddingResponse。`EmbeddingResponse`: Merged response for all inputs.
源码Source agentscope/embedding/_dashscope/_model.py:182–234

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.