AS AgentScopeAPI 手册 / API Reference

Builder

public static class Builder
源码Source io/agentscope/core/model/ChatUsage.java:205–310

构建器,用于构建并配置目标实例。位于 io.agentscope.core.model 包。核心成员包括 inputTokens、outputTokens、cachedTokens、cacheCreationTokens、reasoningTokens、toolUsePromptTokens。

Builder for creating ChatUsage instances.

方法摘要Method Summary

方法Method说明Description
public Builder inputTokens(int inputTokens)
设置数量的输入令牌数。
Sets the number of input tokens.
public Builder outputTokens(int outputTokens)
设置数量的输出令牌数。
Sets the number of output tokens.
public Builder cachedTokens(int cachedTokens)
设置数量的已缓存输入令牌数。
Sets the number of cached input tokens.
public Builder cacheCreationTokens(int cacheCreationTokens)
设置该配置项。
Sets the number of input tokens used to create a prompt cache entry.
public Builder reasoningTokens(int reasoningTokens)
设置推理令牌数。
Sets the number of output tokens used for model reasoning.
public Builder toolUsePromptTokens(int toolUsePromptTokens)
设置工具使用提示词令牌数。
Sets the number of input tokens representing tool results returned to the model.
public Builder time(double time)
设置执行时间。
Sets the execution time.
public ChatUsage build()
构建新的ChatUsage 实例使用设置值。
Builds a new ChatUsage instance with the set values.

方法详情Method Detail

inputTokens

public Builder inputTokens(int inputTokens)

设置数量的输入令牌数。

Sets the number of input tokens.

参数Parameters
名称Name类型Type说明Description
inputTokensint输入令牌数(类型 `int`)。the number of tokens used for the input/prompt
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatUsage.java:220–223

outputTokens

public Builder outputTokens(int outputTokens)

设置数量的输出令牌数。

Sets the number of output tokens.

参数Parameters
名称Name类型Type说明Description
outputTokensint输出令牌数(类型 `int`)。the number of tokens used for the output/generated response
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatUsage.java:231–234

cachedTokens

public Builder cachedTokens(int cachedTokens)

设置数量的已缓存输入令牌数。

Sets the number of cached input tokens.

参数Parameters
名称Name类型Type说明Description
cachedTokensint已缓存令牌数(类型 `int`)。the number of input tokens served from the prompt cache (a subset of `inputTokens`)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatUsage.java:243–246

cacheCreationTokens

public Builder cacheCreationTokens(int cacheCreationTokens)

设置该配置项。

Sets the number of input tokens used to create a prompt cache entry.

参数Parameters
名称Name类型Type说明Description
cacheCreationTokensint缓存 Creation 令牌数(类型 `int`)。the number of cache-creation input tokens (a subset of `inputTokens`)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatUsage.java:255–258

reasoningTokens

public Builder reasoningTokens(int reasoningTokens)

设置推理令牌数。

Sets the number of output tokens used for model reasoning.

参数Parameters
名称Name类型Type说明Description
reasoningTokensint推理令牌数(类型 `int`)。the number of output tokens used for reasoning (a subset of `outputTokens`)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatUsage.java:267–270

toolUsePromptTokens

public Builder toolUsePromptTokens(int toolUsePromptTokens)

设置工具使用提示词令牌数。

Sets the number of input tokens representing tool results returned to the model.

参数Parameters
名称Name类型Type说明Description
toolUsePromptTokensint工具使用提示词令牌数(类型 `int`)。the number of tool-result input tokens (a subset of `inputTokens`)
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatUsage.java:279–282

time

public Builder time(double time)

设置执行时间。

Sets the execution time.

参数Parameters
名称Name类型Type说明Description
timedouble执行时间 in 秒。the execution time in seconds
返回Returns Builder
返回当前实例,以支持链式调用。this builder instance
源码Source io/agentscope/core/model/ChatUsage.java:290–293

build

public ChatUsage build()

构建新的ChatUsage 实例使用设置值。

Builds a new ChatUsage instance with the set values.

返回Returns ChatUsage
一种新的ChatUsage 实例。a new ChatUsage instance
源码Source io/agentscope/core/model/ChatUsage.java:300–309
基于官方固定版本源码静态生成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.