Documentation
¶
Index ¶
- Constants
- func BuildDefaultPrompt(req *types.RunRequest, enabledTools []string) string
- func BuildDynamicPrompt(req *types.RunRequest) string
- func BuildSimplePrompt(customPrompt string) string
- func BuildStaticPrompt(enabledTools []string) string
- func GetA2AAgentsSection(a2a []types.A2AAgentConfig) string
- func GetActionsSection() string
- func GetContextSection(context map[string]any) string
- func GetDoingTasksSection() string
- func GetFilesSection(files []types.FileConfig) string
- func GetInternalAgentsSection(agents []types.InternalAgentConfig) string
- func GetIntroSection() string
- func GetMcpSection(mcps []types.MCPConfig) string
- func GetMemorySection(indexLines []string) string
- func GetOutputEfficiencySection() string
- func GetResponseLanguageSection(locale, userPrompt string) string
- func GetResponseSchemaSection(schema *types.ResponseSchemaConfig) string
- func GetRuntimeContextSection(now time.Time, requestContext ...map[string]any) string
- func GetSkillUsageSection() string
- func GetSkillsSection(skills []types.Skill) string
- func GetSkillsSystemSection() string
- func GetSystemSection() string
- func GetToneAndStyleSection() string
- func GetUsingCapabilitiesSection(enabledCapabilities []string) string
- type CachedPrompt
- type PromptBuilder
- func (b *PromptBuilder) AddCustomSection(name string, content string) *PromptBuilder
- func (b *PromptBuilder) AddDynamicSection(sectionType SectionType, content string) *PromptBuilder
- func (b *PromptBuilder) AddStaticSection(sectionType SectionType, content string) *PromptBuilder
- func (b *PromptBuilder) Build() string
- func (b *PromptBuilder) BuildWithCustomPrompt(customPrompt string) string
- func (b *PromptBuilder) Clear() *PromptBuilder
- func (b *PromptBuilder) GetDynamicSections() string
- func (b *PromptBuilder) GetStaticSections() string
- func (b *PromptBuilder) Sections() []PromptSection
- type PromptCache
- func (c *PromptCache) Clear()
- func (c *PromptCache) Get(agentID string) (string, string, bool)
- func (c *PromptCache) Invalidate(agentID string)
- func (c *PromptCache) Set(agentID string, staticSections string, toolsHash string)
- func (c *PromptCache) ShouldRefresh(agentID string, currentToolsHash string) bool
- func (c *PromptCache) Stats() (int, time.Time)
- type PromptSection
- type SectionType
Constants ¶
const MaxSkillDescChars = 250
MaxSkillDescChars is the maximum characters for skill descriptions in listings Reference: Claude Code's MAX_LISTING_DESC_CHARS = 250
Variables ¶
This section is empty.
Functions ¶
func BuildDefaultPrompt ¶
func BuildDefaultPrompt(req *types.RunRequest, enabledTools []string) string
BuildDefaultPrompt builds the default system prompt using the prompt builder
func BuildDynamicPrompt ¶
func BuildDynamicPrompt(req *types.RunRequest) string
BuildDynamicPrompt builds only the dynamic sections (Skills, MCPs, Context, Files, A2A, InternalAgents, ResponseSchema) These are always recalculated per request
func BuildSimplePrompt ¶
BuildSimplePrompt builds a simple prompt without the full section structure This is useful when you just need a basic prompt quickly
func BuildStaticPrompt ¶
BuildStaticPrompt builds only the static sections, including selected capability guidance. These can be cached per agent + tools combination
func GetA2AAgentsSection ¶
func GetA2AAgentsSection(a2a []types.A2AAgentConfig) string
GetA2AAgentsSection returns the A2A agents section
func GetActionsSection ¶
func GetActionsSection() string
GetActionsSection returns the careful actions section (dangerous operations)
func GetContextSection ¶
GetContextSection returns the context variables section
func GetDoingTasksSection ¶
func GetDoingTasksSection() string
GetDoingTasksSection returns the task execution rules section
func GetFilesSection ¶
func GetFilesSection(files []types.FileConfig) string
GetFilesSection returns the uploaded files section
func GetInternalAgentsSection ¶
func GetInternalAgentsSection(agents []types.InternalAgentConfig) string
GetInternalAgentsSection returns the internal agents section
func GetIntroSection ¶
func GetIntroSection() string
GetIntroSection returns the identity definition section
func GetMcpSection ¶
GetMcpSection returns the MCP instructions section (dynamic)
func GetMemorySection ¶
GetMemorySection returns the memory section for the prompt memories 是记忆内容列表,index 是索引列表(用于展示)
func GetOutputEfficiencySection ¶
func GetOutputEfficiencySection() string
GetOutputEfficiencySection returns the output efficiency section
func GetResponseLanguageSection ¶ added in v0.1.2
GetResponseLanguageSection applies the frontend selection unless the user explicitly requests a different response language in the current message.
func GetResponseSchemaSection ¶
func GetResponseSchemaSection(schema *types.ResponseSchemaConfig) string
GetResponseSchemaSection returns the response schema section for structured output
func GetRuntimeContextSection ¶ added in v0.1.2
GetRuntimeContextSection returns per-request temporal context that must not be cached.
func GetSkillUsageSection ¶
func GetSkillUsageSection() string
GetSkillUsageSection returns practical examples of skill usage
func GetSkillsSection ¶
GetSkillsSection returns the available skills section with metadata (dynamic) Reference: DB-GPT's progressive disclosure pattern
func GetSkillsSystemSection ¶
func GetSkillsSystemSection() string
GetSkillsSystemSection returns the skills system guidance (Reference: DB-GPT SKILLS_SYSTEM_PROMPT) This instructs the LLM on how to use skills
func GetSystemSection ¶
func GetSystemSection() string
GetSystemSection returns the system rules section
func GetToneAndStyleSection ¶
func GetToneAndStyleSection() string
GetToneAndStyleSection returns the tone and style section
func GetUsingCapabilitiesSection ¶ added in v0.1.2
GetUsingCapabilitiesSection returns guidance for selected abilities.
Types ¶
type CachedPrompt ¶
CachedPrompt represents a cached static sections prompt
type PromptBuilder ¶
type PromptBuilder struct {
// contains filtered or unexported fields
}
PromptBuilder builds structured system prompts
func NewPromptBuilder ¶
func NewPromptBuilder() *PromptBuilder
NewPromptBuilder creates a new prompt builder
func (*PromptBuilder) AddCustomSection ¶
func (b *PromptBuilder) AddCustomSection(name string, content string) *PromptBuilder
AddCustomSection adds a custom section with the given type and content
func (*PromptBuilder) AddDynamicSection ¶
func (b *PromptBuilder) AddDynamicSection(sectionType SectionType, content string) *PromptBuilder
AddDynamicSection adds a dynamic section that should be recalculated
func (*PromptBuilder) AddStaticSection ¶
func (b *PromptBuilder) AddStaticSection(sectionType SectionType, content string) *PromptBuilder
AddStaticSection adds a static (non-changing) section
func (*PromptBuilder) Build ¶
func (b *PromptBuilder) Build() string
Build builds the final prompt string
func (*PromptBuilder) BuildWithCustomPrompt ¶
func (b *PromptBuilder) BuildWithCustomPrompt(customPrompt string) string
BuildWithCustomPrompt builds prompt with custom system prompt prepended
func (*PromptBuilder) Clear ¶
func (b *PromptBuilder) Clear() *PromptBuilder
Clear removes all sections
func (*PromptBuilder) GetDynamicSections ¶
func (b *PromptBuilder) GetDynamicSections() string
GetDynamicSections returns only the dynamic sections joined together
func (*PromptBuilder) GetStaticSections ¶
func (b *PromptBuilder) GetStaticSections() string
GetStaticSections returns only the static sections joined together
func (*PromptBuilder) Sections ¶
func (b *PromptBuilder) Sections() []PromptSection
Sections returns all sections
type PromptCache ¶
type PromptCache struct {
// contains filtered or unexported fields
}
PromptCache caches static sections of prompts per agent
func (*PromptCache) Get ¶
func (c *PromptCache) Get(agentID string) (string, string, bool)
Get retrieves cached static sections for an agent Returns (content, toolsHash, found)
func (*PromptCache) Invalidate ¶
func (c *PromptCache) Invalidate(agentID string)
Invalidate removes cached entry for an agent
func (*PromptCache) Set ¶
func (c *PromptCache) Set(agentID string, staticSections string, toolsHash string)
Set stores static sections for an agent
func (*PromptCache) ShouldRefresh ¶
func (c *PromptCache) ShouldRefresh(agentID string, currentToolsHash string) bool
ShouldRefresh checks if the cache should be refreshed based on tools hash
type PromptSection ¶
type PromptSection struct {
Type SectionType
Content string
Dynamic bool // 动态区块每次重新计算
}
PromptSection represents a single section in the prompt
type SectionType ¶
type SectionType string
SectionType represents the type of prompt section
const ( IntroSection SectionType = "intro" SystemSection SectionType = "system" DoingTasksSection SectionType = "doing_tasks" ActionsSection SectionType = "actions" UsingCapabilitiesSection SectionType = "using_capabilities" OutputEfficiencySection SectionType = "output_efficiency" ToneAndStyleSection SectionType = "tone_and_style" SkillsSection SectionType = "skills" SkillsSystemSection SectionType = "skills_system" SkillUsageSection SectionType = "skill_usage" McpSection SectionType = "mcp" EnvironmentSection SectionType = "environment" SessionSpecificSection SectionType = "session_specific" ContextSection SectionType = "context" FilesSection SectionType = "files" A2AAgentsSection SectionType = "a2a_agents" InternalAgentsSection SectionType = "internal_agents" MemorySection SectionType = "memory" ResponseSchemaSection SectionType = "response_schema" )