AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/training/runner/TrainingConfig.java:125–258

构建器,用于构建并配置目标实例。位于 io.agentscope.core.training.runner 包。核心成员包括 trinityEndpoint、trinityApiKey、modelName、selectionStrategy、sampleRate、rewardCalculator。

A class in io.agentscope.core.training.runner that evaluates agent behaviour and records tracing and telemetry data. Declared in io.agentscope.core.training.runner.

方法摘要Method Summary

方法Method说明Description
public Builder trinityEndpoint(String endpoint)
设置该配置项。
Performs the trinity endpoint operation.
public Builder trinityApiKey(String apiKey)
设置该配置项。
Performs the trinity api key operation.
public Builder modelName(String modelName)
设置模型名称。
Performs the model name operation.
public Builder selectionStrategy(TrainingSelectionStrategy strategy)
设置该配置项。
Set training request filtering strategy
public Builder sampleRate(double sampleRate)
deprecated
设置该配置项。
Shortcut method: Set simple sampling rate strategy
public Builder rewardCalculator(RewardCalculator calculator)
设置该配置项。
Performs the reward calculator operation.
public Builder commitIntervalSeconds(long seconds)
设置提交间隔秒。
Performs the commit interval seconds operation.
public Builder httpTimeout(Duration timeout)
设置HTTP 超时。
Performs the http timeout operation.
public Builder enableAutoCommit(boolean enable)
启用该配置。
Enables the auto commit.
public Builder shadowPoolSize(int size)
设置该配置项。
Performs the shadow pool size operation.
public Builder shadowPoolCapacity(int capacity)
设置该配置项。
Performs the shadow pool capacity operation.
public Builder repeatTime(int repeatTime)
设置该配置项。
Set repeat execution count for each task
public TrainingConfig build()
构建并返回最终实例。
Creates and returns an instance.

方法详情Method Detail

trinityEndpoint

public Builder trinityEndpoint(String endpoint)

设置该配置项。

Performs the trinity endpoint operation.

参数Parameters
名称Name类型Type说明Description
endpointString端点地址(类型 `String`)。The endpoint.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:139–142

trinityApiKey

public Builder trinityApiKey(String apiKey)

设置该配置项。

Performs the trinity api key operation.

参数Parameters
名称Name类型Type说明Description
apiKeyStringAPI 键(类型 `String`)。The api key.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:144–147

modelName

public Builder modelName(String modelName)

设置模型名称。

Performs the model name operation.

参数Parameters
名称Name类型Type说明Description
modelNameString模型名称(类型 `String`)。The model name.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:149–152

selectionStrategy

public Builder selectionStrategy(TrainingSelectionStrategy strategy)

设置该配置项。

Set training request filtering strategy Supports multiple strategies: - SamplingRateStrategy - Based on sampling rate - io.agentscope.core.training.strategy.ExplicitMarkingStrategy - Based on user explicit marking - Custom strategy - Implement TrainingSelectionStrategy

参数Parameters
名称Name类型Type说明Description
strategyTrainingSelectionStrategystrategy(类型 `TrainingSelectionStrategy`)。Filtering strategy
返回Returns Builder
返回当前实例,以支持链式调用。this
源码Source io/agentscope/core/training/runner/TrainingConfig.java:167–170

sampleRate

public Builder sampleRate(double sampleRate)
deprecated

设置该配置项。

Shortcut method: Set simple sampling rate strategy

已弃用。Deprecated. 已弃用,请改用受支持的替代 API。Recommend using `#selectionStrategy(TrainingSelectionStrategy)`
参数Parameters
名称Name类型Type说明Description
sampleRatedoublesample 速率(类型 `double`)。Sampling rate (0.0 ~ 1.0)
返回Returns Builder
返回当前实例,以支持链式调用。this
源码Source io/agentscope/core/training/runner/TrainingConfig.java:179–186

rewardCalculator

public Builder rewardCalculator(RewardCalculator calculator)

设置该配置项。

Performs the reward calculator operation.

参数Parameters
名称Name类型Type说明Description
calculatorRewardCalculatorcalculator(类型 `RewardCalculator`)。The calculator.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:188–191

commitIntervalSeconds

public Builder commitIntervalSeconds(long seconds)

设置提交间隔秒。

Performs the commit interval seconds operation.

参数Parameters
名称Name类型Type说明Description
secondslong秒(类型 `long`)。The seconds.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:193–196

httpTimeout

public Builder httpTimeout(Duration timeout)

设置HTTP 超时。

Performs the http timeout operation.

参数Parameters
名称Name类型Type说明Description
timeoutDuration超时时间(类型 `Duration`)。The timeout.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:198–201

enableAutoCommit

public Builder enableAutoCommit(boolean enable)

启用该配置。

Enables the auto commit.

参数Parameters
名称Name类型Type说明Description
enableboolean启用(类型 `boolean`)。The enable.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:203–206

shadowPoolSize

public Builder shadowPoolSize(int size)

设置该配置项。

Performs the shadow pool size operation.

参数Parameters
名称Name类型Type说明Description
sizeint大小(类型 `int`)。The size.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:208–211

shadowPoolCapacity

public Builder shadowPoolCapacity(int capacity)

设置该配置项。

Performs the shadow pool capacity operation.

参数Parameters
名称Name类型Type说明Description
capacityintcapacity(类型 `int`)。The capacity.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:213–216

repeatTime

public Builder repeatTime(int repeatTime)

设置该配置项。

Set repeat execution count for each task When a request is selected for training, it will run repeatTime times with the same taskId, each run will be assigned an incrementing runId (0, 1, 2, ...).

参数Parameters
名称Name类型Type说明Description
repeatTimeintrepeat 时间(类型 `int`)。Repeat execution count, must be >= 1, defaults to 1
返回Returns Builder
返回当前实例,以支持链式调用。this
抛出Throws
  • IllegalArgumentException 可能抛出 `IllegalArgumentException`。if repeatTime < 1
源码Source io/agentscope/core/training/runner/TrainingConfig.java:235–241

build

public TrainingConfig build()

构建并返回最终实例。

Creates and returns an instance.

返回Returns TrainingConfig
返回TrainingConfig。Returns training config.
源码Source io/agentscope/core/training/runner/TrainingConfig.java:243–257
基于官方固定版本源码静态生成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.