AS AgentScopeAPI 手册 / API Reference

EmbeddingUtils

public final class EmbeddingUtils
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:32–266

向量化 Utils,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.embedding 包。核心成员包括 applyTimeoutAndRetry、applyTimeoutAndRetryBatch、ensureDefaultExecutionConfig、convertDoubleListToArray、convertFloatListToDoubleArray、convertFloatArrayToDoubleArray。

Utility class for common EmbeddingModel operations.

This class provides shared functionality used across different EmbeddingModel implementations, including timeout and retry logic for embedding API calls, and conversion utilities.

方法摘要Method Summary

方法Method说明Description
public static T Mono<T> applyTimeoutAndRetry(Mono<T> embeddingMono, ExecutionConfig config, String modelName, String provider, Logger logger, String operationType)
static
应用超时和重试。
Applies timeout and retry configuration to an embedding Mono.
public static Mono<double[]> applyTimeoutAndRetry(Mono<double[]> embeddingMono, ExecutionConfig config, String modelName, String provider, Logger logger)
static
应用超时和重试。
Applies timeout and retry configuration to a single embedding Mono.
public static Mono<List<double[]>> applyTimeoutAndRetryBatch(Mono<List<double[]>> batchEmbeddingMono, ExecutionConfig config, String modelName, String provider, Logger logger)
static
应用 `applyTimeoutAndRetryBatch`。
Applies timeout and retry configuration to a batch embedding Mono.
public static ExecutionConfig ensureDefaultExecutionConfig(ExecutionConfig config)
static
设置确保默认执行配置。
Ensures ExecutionConfig has MODEL_DEFAULTS applied.
public static double[] convertDoubleListToArray(List<Double> values)
static
转换 `convertDoubleListToArray`。
Converts a List of Double values to a double array.
public static double[] convertFloatListToDoubleArray(List<Float> values)
static
转换 `convertFloatListToDoubleArray`。
Converts a List of Float values to a double array.
public static double[] convertFloatArrayToDoubleArray(float[] values)
static
转换 `convertFloatArrayToDoubleArray`。
Converts a float array to a double array.

方法详情Method Detail

applyTimeoutAndRetry

public static T Mono<T> applyTimeoutAndRetry(Mono<T> embeddingMono, ExecutionConfig config, String modelName, String provider, Logger logger, String operationType)
static

应用超时和重试。

Applies timeout and retry configuration to an embedding Mono.

参数Parameters
名称Name类型Type说明Description
embeddingMonoMono<T>向量化 Mono(类型 `Mono`)。the original embedding Mono to enhance
configExecutionConfig配置对象(类型 `ExecutionConfig`)。execution config containing timeout and retry settings (may be null)
modelNameString模型用于错误消息和日志的名称。the name of the model for error messages and logging
providerString提供者(类型 `String`)。the provider name (e.g., "dashscope", "openai") for error messages
loggerLogger日志记录器(类型 `Logger`)。the logger instance for debug and warning messages
operationTypeStringoperation 类型(类型 `String`)。the operation type description (e.g., "embedding", "batch embedding")
返回Returns Mono<T>
返回Mono。wrapped Mono with timeout and retry applied
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:74–143

applyTimeoutAndRetry

public static Mono<double[]> applyTimeoutAndRetry(Mono<double[]> embeddingMono, ExecutionConfig config, String modelName, String provider, Logger logger)
static

应用超时和重试。

Applies timeout and retry configuration to a single embedding Mono.

参数Parameters
名称Name类型Type说明Description
embeddingMonoMono<double[]>向量化 Mono(类型 `Mono`)。the original embedding Mono to enhance
configExecutionConfig配置对象(类型 `ExecutionConfig`)。execution config containing timeout and retry settings (may be null)
modelNameString模型用于错误消息和日志的名称。the name of the model for error messages and logging
providerString提供者(类型 `String`)。the provider name (e.g., "dashscope", "openai") for error messages
loggerLogger日志记录器(类型 `Logger`)。the logger instance for debug and warning messages
返回Returns Mono<double[]>
返回Mono。wrapped Mono with timeout and retry applied
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:159–167

applyTimeoutAndRetryBatch

public static Mono<List<double[]>> applyTimeoutAndRetryBatch(Mono<List<double[]>> batchEmbeddingMono, ExecutionConfig config, String modelName, String provider, Logger logger)
static

应用 applyTimeoutAndRetryBatch。

Applies timeout and retry configuration to a batch embedding Mono.

参数Parameters
名称Name类型Type说明Description
batchEmbeddingMonoMono<List<double[]>>batch 向量化 Mono(类型 `Mono >`)。the original batch embedding Mono to enhance
configExecutionConfig配置对象(类型 `ExecutionConfig`)。execution config containing timeout and retry settings (may be null)
modelNameString模型用于错误消息和日志的名称。the name of the model for error messages and logging
providerString提供者(类型 `String`)。the provider name (e.g., "dashscope", "openai") for error messages
loggerLogger日志记录器(类型 `Logger`)。the logger instance for debug and warning messages
返回Returns Mono<List<double[]>>
返回Mono>。wrapped Mono with timeout and retry applied
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:183–191

ensureDefaultExecutionConfig

public static ExecutionConfig ensureDefaultExecutionConfig(ExecutionConfig config)
static

设置确保默认执行配置。

Ensures ExecutionConfig has MODEL_DEFAULTS applied.

参数Parameters
名称Name类型Type说明Description
configExecutionConfig配置对象(类型 `ExecutionConfig`)。the original config (may be null)
返回Returns ExecutionConfig
返回ExecutionConfig。config with MODEL_DEFAULTS applied as needed, or MODEL_DEFAULTS if config is null
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:208–214

convertDoubleListToArray

public static double[] convertDoubleListToArray(List<Double> values)
static

转换 convertDoubleListToArray。

Converts a List of Double values to a double array.

参数Parameters
名称Name类型Type说明Description
valuesList<Double>值(类型 `List`)。the list of Double values
返回Returns double[]
返回double[]。the double array
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:225–231

convertFloatListToDoubleArray

public static double[] convertFloatListToDoubleArray(List<Float> values)
static

转换 convertFloatListToDoubleArray。

Converts a List of Float values to a double array.

参数Parameters
名称Name类型Type说明Description
valuesList<Float>值(类型 `List`)。the list of Float values
返回Returns double[]
返回double[]。the double array
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:242–248

convertFloatArrayToDoubleArray

public static double[] convertFloatArrayToDoubleArray(float[] values)
static

转换 convertFloatArrayToDoubleArray。

Converts a float array to a double array.

参数Parameters
名称Name类型Type说明Description
valuesfloat[]值(类型 `float[]`)。the float array
返回Returns double[]
返回double[]。the double array
源码Source io/agentscope/core/embedding/EmbeddingUtils.java:259–265
基于官方固定版本源码静态生成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.