AS AgentScopeAPI 手册 / API Reference

PromptConfig

public class PromptConfig
源码Source 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()
static

返回构建器实例。

Creates a new Builder instance for constructing PromptConfig.

返回Returns Builder
一种新的构建器实例。a new Builder instance
源码Source io/agentscope/core/memory/autocontext/PromptConfig.java:206–208

getPreviousRoundToolCompressPrompt

public String getPreviousRoundToolCompressPrompt()

获取 getPreviousRoundToolCompressPrompt。

Gets the prompt for Strategy 1: compressing previous round tool invocations.

另见See also @see #previousRoundToolCompressPrompt
返回Returns String
返回字符串结果。the custom prompt, or null if not set (will use default from `Prompts`)
源码Source io/agentscope/core/memory/autocontext/PromptConfig.java:216–218

getPreviousRoundSummaryPrompt

public String getPreviousRoundSummaryPrompt()

获取 getPreviousRoundSummaryPrompt。

Gets the prompt for Strategy 4: summarizing previous round conversations.

另见See also @see #previousRoundSummaryPrompt
返回Returns String
返回字符串结果。the custom prompt, or null if not set (will use default from `Prompts`)
源码Source io/agentscope/core/memory/autocontext/PromptConfig.java:226–228

getCurrentRoundLargeMessagePrompt

public String getCurrentRoundLargeMessagePrompt()

获取 getCurrentRoundLargeMessagePrompt。

Gets the prompt for Strategy 5: summarizing current round large messages.

另见See also @see #currentRoundLargeMessagePrompt
返回Returns String
返回字符串结果。the custom prompt, or null if not set (will use default from `Prompts`)
源码Source io/agentscope/core/memory/autocontext/PromptConfig.java:236–238

getCurrentRoundCompressPrompt

public String getCurrentRoundCompressPrompt()

获取 getCurrentRoundCompressPrompt。

Gets the prompt for Strategy 6: compressing current round messages.

另见See also @see #currentRoundCompressPrompt
返回Returns String
返回字符串结果。the custom prompt, or null if not set (will use default from `Prompts`)
源码Source io/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();
`
基于官方固定版本源码静态生成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.