Builder
public static class Builder
io/agentscope/core/memory/autocontext/AutoContextConfig.java:142–290构建器,用于构建并配置目标实例。位于 io.agentscope.core.memory.autocontext 包。核心成员包括 largePayloadThreshold、maxToken、tokenRatio、offloadSinglePreview、msgThreshold、lastKeep。
Builder class for constructing AutoContextConfig instances.
This builder provides a fluent API for configuring AutoContextMemory parameters. All fields have default values matching those in AutoContextConfig.
Example usage:
`AutoContextConfig config = AutoContextConfig.builder()
.msgThreshold(50)
.maxToken(64 * 1024)
.lastKeep(20)
.build();
`
方法摘要Method Summary
方法详情Method Detail
largePayloadThreshold
public Builder largePayloadThreshold(long largePayloadThreshold)
设置该配置项。
Sets the threshold (in characters) for large payload messages to be offloaded.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
largePayloadThreshold | long | large 负载阈值(类型 `long`)。the threshold in characters |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:160–163maxToken
public Builder maxToken(long maxToken)
设置最大令牌。
Sets the maximum token limit for context window.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
maxToken | long | 最大令牌(类型 `long`)。the maximum token count |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:171–174tokenRatio
public Builder tokenRatio(double tokenRatio)
设置该配置项。
Sets the token ratio threshold (0.0-1.0) to trigger compression.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
tokenRatio | double | 令牌 Ratio(类型 `double`)。the token ratio (0.0-1.0) |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:182–185offloadSinglePreview
public Builder offloadSinglePreview(int offloadSinglePreview)
设置该配置项。
Sets the preview length (in characters) for offloaded messages.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
offloadSinglePreview | int | 卸载 Single 预览(类型 `int`)。the preview length in characters |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:193–196msgThreshold
public Builder msgThreshold(int msgThreshold)
设置消息阈值。
Sets the message count threshold to trigger compression.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msgThreshold | int | 消息数量阈值。the message count threshold |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:204–207lastKeep
public Builder lastKeep(int lastKeep)
设置该配置项。
Sets the number of recent messages to keep uncompressed.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
lastKeep | int | 最后 Keep(类型 `int`)。the number of messages to keep |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:215–218minConsecutiveToolMessages
public Builder minConsecutiveToolMessages(int minConsecutiveToolMessages)
设置该配置项。
Sets the minimum number of consecutive tool messages required for compression.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
minConsecutiveToolMessages | int | 最小 Consecutive 工具消息(类型 `int`)。the minimum consecutive tool messages count |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:226–229currentRoundCompressionRatio
public Builder currentRoundCompressionRatio(double currentRoundCompressionRatio)
设置该配置项。
Sets the compression ratio (0.0-1.0) for current round messages.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
currentRoundCompressionRatio | double | 当前 Round 压缩 Ratio(类型 `double`)。the compression ratio (0.0-1.0) |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:239–242minCompressionTokenThreshold
public Builder minCompressionTokenThreshold(int minCompressionTokenThreshold)
设置最小压缩令牌阈值。
Sets the minimum token count required for compression to proceed.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
minCompressionTokenThreshold | int | 最小压缩令牌阈值(类型 `int`)。the minimum token count threshold |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:252–255customPrompt
public Builder customPrompt(PromptConfig customPrompt)
设置自定义提示词配置。
Sets custom prompt configuration.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
customPrompt | PromptConfig | 自定义提示词(类型 `PromptConfig`)。the custom prompt configuration, or null to use defaults |
Builderio/agentscope/core/memory/autocontext/AutoContextConfig.java:266–269build
public AutoContextConfig build()
构建并返回最终实例。
Builds and returns a new AutoContextConfig instance with the configured values.
AutoContextConfigio/agentscope/core/memory/autocontext/AutoContextConfig.java:276–289