PromptConfig
public class PromptConfig
io/agentscope/core/memory/autocontext/PromptConfig.java:55–249提示词配置,保存相关配置项。位于 io.agentscope.core.memory.autocontext 包。核心成员包括 builder、getPreviousRoundToolCompressPrompt、getPreviousRoundSummaryPrompt、getCurrentRoundLargeMessagePrompt、getCurrentRoundCompressPrompt。
Configuration class for compression prompts used by AutoContextMemory.
This class allows customization of the prompts used in different compression strategies.
All prompts are optional - if not specified, default prompts from Prompts will be used.
Configurable Prompts:
-
Strategy 1: Previous round tool invocation compression
-
Strategy 4: Previous round conversation summarization
-
Strategy 5: Current round large message summarization
-
Strategy 6: Current round message compression
Usage Example:
`// Create a custom prompt configuration
PromptConfig customPrompt = PromptConfig.builder()
.previousRoundToolCompressPrompt("Custom tool compression prompt...")
.currentRoundCompressPrompt("Custom current round compression prompt...")
.build();
// Use in AutoContextConfig
AutoContextConfig config = AutoContextConfig.builder()
.msgThreshold(50)
.customPrompt(customPrompt)
.build();
`
Empty String Handling: If a prompt is set to an empty string or contains only
whitespace, the system will automatically fall back to the default prompt. This is handled by
PromptProvider.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 Builder class for constructing PromptConfig instances. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static Builder builder()static | 返回构建器实例。 Creates a new Builder instance for constructing PromptConfig. |
public String getPreviousRoundToolCompressPrompt() | 获取 `getPreviousRoundToolCompressPrompt`。 Gets the prompt for Strategy 1: compressing previous round tool invocations. |
public String getPreviousRoundSummaryPrompt() | 获取 `getPreviousRoundSummaryPrompt`。 Gets the prompt for Strategy 4: summarizing previous round conversations. |
public String getCurrentRoundLargeMessagePrompt() | 获取 `getCurrentRoundLargeMessagePrompt`。 Gets the prompt for Strategy 5: summarizing current round large messages. |
public String getCurrentRoundCompressPrompt() | 获取 `getCurrentRoundCompressPrompt`。 Gets the prompt for Strategy 6: compressing current round messages. |
方法详情Method Detail
builder
public static Builder builder()
返回构建器实例。
Creates a new Builder instance for constructing PromptConfig.
Builderio/agentscope/core/memory/autocontext/PromptConfig.java:206–208getPreviousRoundToolCompressPrompt
public String getPreviousRoundToolCompressPrompt()
获取 getPreviousRoundToolCompressPrompt。
Gets the prompt for Strategy 1: compressing previous round tool invocations.
Stringio/agentscope/core/memory/autocontext/PromptConfig.java:216–218getPreviousRoundSummaryPrompt
public String getPreviousRoundSummaryPrompt()
获取 getPreviousRoundSummaryPrompt。
Gets the prompt for Strategy 4: summarizing previous round conversations.
Stringio/agentscope/core/memory/autocontext/PromptConfig.java:226–228getCurrentRoundLargeMessagePrompt
public String getCurrentRoundLargeMessagePrompt()
获取 getCurrentRoundLargeMessagePrompt。
Gets the prompt for Strategy 5: summarizing current round large messages.
Stringio/agentscope/core/memory/autocontext/PromptConfig.java:236–238getCurrentRoundCompressPrompt
public String getCurrentRoundCompressPrompt()
获取 getCurrentRoundCompressPrompt。
Gets the prompt for Strategy 6: compressing current round messages.
Stringio/agentscope/core/memory/autocontext/PromptConfig.java:246–248嵌套类详情Nested Class Detail
Builder
public static class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.core.memory.autocontext 包。核心成员包括 previousRoundToolCompressPrompt、previousRoundSummaryPrompt、currentRoundLargeMessagePrompt、currentRoundCompressPrompt、build。
Builder class for constructing PromptConfig instances.
This builder follows the standard Builder pattern and supports method chaining.
Each call to #build() creates a new independent instance, allowing the same
builder to be reused multiple times safely.
Example:
`PromptConfig config = PromptConfig.builder()
.previousRoundToolCompressPrompt("Custom prompt 1")
.previousRoundSummaryPrompt("Custom prompt 4")
.build();
`