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 |
|---|---|---|
inputTokens | int | 输入令牌数(类型 `int`)。the number of tokens used for the input/prompt |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/core/model/ChatUsage.java:220–223outputTokens
public Builder outputTokens(int outputTokens)
设置数量的输出令牌数。
Sets the number of output tokens.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
outputTokens | int | 输出令牌数(类型 `int`)。the number of tokens used for the output/generated response |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/core/model/ChatUsage.java:231–234cachedTokens
public Builder cachedTokens(int cachedTokens)
设置数量的已缓存输入令牌数。
Sets the number of cached input tokens.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
cachedTokens | int | 已缓存令牌数(类型 `int`)。the number of input tokens served from the prompt cache (a subset of `inputTokens`) |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/core/model/ChatUsage.java:243–246cacheCreationTokens
public Builder cacheCreationTokens(int cacheCreationTokens)
设置该配置项。
Sets the number of input tokens used to create a prompt cache entry.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
cacheCreationTokens | int | 缓存 Creation 令牌数(类型 `int`)。the number of cache-creation input tokens (a subset of `inputTokens`) |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/core/model/ChatUsage.java:255–258reasoningTokens
public Builder reasoningTokens(int reasoningTokens)
设置推理令牌数。
Sets the number of output tokens used for model reasoning.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
reasoningTokens | int | 推理令牌数(类型 `int`)。the number of output tokens used for reasoning (a subset of `outputTokens`) |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/core/model/ChatUsage.java:267–270toolUsePromptTokens
public Builder toolUsePromptTokens(int toolUsePromptTokens)
设置工具使用提示词令牌数。
Sets the number of input tokens representing tool results returned to the model.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
toolUsePromptTokens | int | 工具使用提示词令牌数(类型 `int`)。the number of tool-result input tokens (a subset of `inputTokens`) |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/core/model/ChatUsage.java:279–282time
public Builder time(double time)
设置执行时间。
Sets the execution time.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
time | double | 执行时间 in 秒。the execution time in seconds |
Builder返回当前实例,以支持链式调用。this builder instance
源码Source
io/agentscope/core/model/ChatUsage.java:290–293build
public ChatUsage build()
构建新的ChatUsage 实例使用设置值。
Builds a new ChatUsage instance with the set values.
ChatUsage一种新的ChatUsage 实例。a new ChatUsage instance
源码Source
io/agentscope/core/model/ChatUsage.java:300–309