ModelUtils
public final class ModelUtils
源码Source
io/agentscope/core/model/ModelUtils.java:32–181模型 Utils,与模型服务通信并返回生成或向量化结果。位于 io.agentscope.core.model 包。核心成员包括 applyTimeoutAndRetry、ensureDefaultExecutionConfig。
Utility class for common Model operations.
This class provides shared functionality used across different Model implementations, including timeout and retry logic for model API calls.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Flux<ChatResponse> applyTimeoutAndRetry(Flux<ChatResponse> responseFlux, GenerateOptions options, GenerateOptions defaultOptions, String modelName, String provider)static | 应用超时和重试。 Applies timeout and retry configuration to a model response Flux. |
public static GenerateOptions ensureDefaultExecutionConfig(GenerateOptions options)static | 设置确保默认执行配置。 Ensures GenerateOptions has MODEL_DEFAULTS for executionConfig applied. |
方法详情Method Detail
applyTimeoutAndRetry
public static Flux<ChatResponse> applyTimeoutAndRetry(Flux<ChatResponse> responseFlux, GenerateOptions options, GenerateOptions defaultOptions, String modelName, String provider)
static
应用超时和重试。
Applies timeout and retry configuration to a model response Flux.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
responseFlux | Flux<ChatResponse> | 响应 Flux(类型 `Flux`)。the original response Flux to enhance |
options | GenerateOptions | 选项(类型 `GenerateOptions`)。generation options containing timeout and retry config (may be null) |
defaultOptions | GenerateOptions | 默认选项(类型 `GenerateOptions`)。default options to use if options is null |
modelName | String | 模型用于错误消息和日志的名称。the name of the model for error messages and logging |
provider | String | 提供者(类型 `String`)。the provider name (e.g., "dashscope", "openai") for error messages |
Flux<ChatResponse>返回Flux。wrapped Flux with timeout and retry applied
源码Source
io/agentscope/core/model/ModelUtils.java:70–142ensureDefaultExecutionConfig
public static GenerateOptions ensureDefaultExecutionConfig(GenerateOptions options)
static
设置确保默认执行配置。
Ensures GenerateOptions has MODEL_DEFAULTS for executionConfig applied.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
options | GenerateOptions | 选项(类型 `GenerateOptions`)。the original options (may be null) |
GenerateOptions返回GenerateOptions。options with MODEL_DEFAULTS applied as needed
源码Source
io/agentscope/core/model/ModelUtils.java:161–180