AS AgentScopeAPI 手册 / API Reference

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
responseFluxFlux<ChatResponse>响应 Flux(类型 `Flux`)。the original response Flux to enhance
optionsGenerateOptions选项(类型 `GenerateOptions`)。generation options containing timeout and retry config (may be null)
defaultOptionsGenerateOptions默认选项(类型 `GenerateOptions`)。default options to use if options is null
modelNameString模型用于错误消息和日志的名称。the name of the model for error messages and logging
providerString提供者(类型 `String`)。the provider name (e.g., "dashscope", "openai") for error messages
返回Returns Flux<ChatResponse>
返回Flux。wrapped Flux with timeout and retry applied
源码Source io/agentscope/core/model/ModelUtils.java:70–142

ensureDefaultExecutionConfig

public static GenerateOptions ensureDefaultExecutionConfig(GenerateOptions options)
static

设置确保默认执行配置。

Ensures GenerateOptions has MODEL_DEFAULTS for executionConfig applied.

参数Parameters
名称Name类型Type说明Description
optionsGenerateOptions选项(类型 `GenerateOptions`)。the original options (may be null)
返回Returns GenerateOptions
返回GenerateOptions。options with MODEL_DEFAULTS applied as needed
源码Source io/agentscope/core/model/ModelUtils.java:161–180
基于官方固定版本源码静态生成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.