feat: Enhance agent configuration and localization for web search prompts
- Updated agent configuration to support separate system prompts for web search enabled and disabled states. - Removed deprecated agent configuration parameters to streamline settings management. - Enhanced UI components in AgentSettings.vue to allow configuration of custom prompts based on web search status. - Improved localization in English, Russian, and Chinese for new prompt settings and UI elements. - Refactored related API and service logic to accommodate changes in agent configuration structure.
This commit is contained in:
+32
-12
@@ -10,18 +10,19 @@ import (
|
||||
// AgentConfig represents the full agent configuration (used at tenant level and runtime)
|
||||
// This includes all configuration parameters for agent execution
|
||||
type AgentConfig struct {
|
||||
Enabled bool `json:"enabled"` // Whether agent mode is enabled
|
||||
MaxIterations int `json:"max_iterations"` // Maximum number of ReAct iterations
|
||||
ReflectionEnabled bool `json:"reflection_enabled"` // Whether to enable reflection
|
||||
AllowedTools []string `json:"allowed_tools"` // List of allowed tool names
|
||||
Temperature float64 `json:"temperature"` // LLM temperature for agent
|
||||
ThinkingModelID string `json:"thinking_model_id"` // Model ID for reasoning
|
||||
RerankModelID string `json:"rerank_model_id"` // Model ID for reranking search results
|
||||
KnowledgeBases []string `json:"knowledge_bases"` // Accessible knowledge base IDs
|
||||
SystemPrompt string `json:"system_prompt,omitempty"` // System prompt template with placeholders (optional)
|
||||
UseCustomSystemPrompt bool `json:"use_custom_system_prompt"` // Whether to use custom system prompt instead of default
|
||||
WebSearchEnabled bool `json:"web_search_enabled"` // Whether web search tool is enabled
|
||||
WebSearchMaxResults int `json:"web_search_max_results"` // Maximum number of web search results (default: 5)
|
||||
Enabled bool `json:"enabled"` // Whether agent mode is enabled
|
||||
MaxIterations int `json:"max_iterations"` // Maximum number of ReAct iterations
|
||||
ReflectionEnabled bool `json:"reflection_enabled"` // Whether to enable reflection
|
||||
AllowedTools []string `json:"allowed_tools"` // List of allowed tool names
|
||||
Temperature float64 `json:"temperature"` // LLM temperature for agent
|
||||
ThinkingModelID string `json:"thinking_model_id"` // Model ID for reasoning
|
||||
RerankModelID string `json:"rerank_model_id"` // Model ID for reranking search results
|
||||
KnowledgeBases []string `json:"knowledge_bases"` // Accessible knowledge base IDs
|
||||
SystemPromptWebEnabled string `json:"system_prompt_web_enabled,omitempty"` // Custom prompt when web search is enabled
|
||||
SystemPromptWebDisabled string `json:"system_prompt_web_disabled,omitempty"` // Custom prompt when web search is disabled
|
||||
UseCustomSystemPrompt bool `json:"use_custom_system_prompt"` // Whether to use custom system prompt instead of default
|
||||
WebSearchEnabled bool `json:"web_search_enabled"` // Whether web search tool is enabled
|
||||
WebSearchMaxResults int `json:"web_search_max_results"` // Maximum number of web search results (default: 5)
|
||||
}
|
||||
|
||||
// SessionAgentConfig represents session-level agent configuration
|
||||
@@ -66,6 +67,25 @@ func (c *SessionAgentConfig) Scan(value interface{}) error {
|
||||
return json.Unmarshal(b, c)
|
||||
}
|
||||
|
||||
// ResolveSystemPrompt returns the prompt template for the given web search state.
|
||||
func (c *AgentConfig) ResolveSystemPrompt(webSearchEnabled bool) string {
|
||||
if c == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
if webSearchEnabled {
|
||||
if c.SystemPromptWebEnabled != "" {
|
||||
return c.SystemPromptWebEnabled
|
||||
}
|
||||
} else {
|
||||
if c.SystemPromptWebDisabled != "" {
|
||||
return c.SystemPromptWebDisabled
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// Tool defines the interface that all agent tools must implement
|
||||
type Tool interface {
|
||||
// Name returns the unique identifier for this tool
|
||||
|
||||
@@ -26,6 +26,8 @@ const (
|
||||
ChunkTypeRelationship ChunkType = "relationship"
|
||||
// ChunkTypeFAQ 表示 FAQ 条目 Chunk
|
||||
ChunkTypeFAQ ChunkType = "faq"
|
||||
// ChunkTypeWebSearch 表示 Web 搜索结果的 Chunk
|
||||
ChunkTypeWebSearch ChunkType = "web_search"
|
||||
)
|
||||
|
||||
// ImageInfo 表示与 Chunk 关联的图片信息
|
||||
|
||||
@@ -64,4 +64,6 @@ type ChunkService interface {
|
||||
DeleteByKnowledgeList(ctx context.Context, ids []string) error
|
||||
// ListChunkByParentID lists chunks by parent id
|
||||
ListChunkByParentID(ctx context.Context, tenantID uint, parentID string) ([]*types.Chunk, error)
|
||||
// GetRepository gets the chunk repository
|
||||
GetRepository() ChunkRepository
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ type KnowledgeService interface {
|
||||
UpdateKnowledgeTagBatch(ctx context.Context, updates map[string]*string) error
|
||||
// UpdateFAQEntryTagBatch updates tag for FAQ entries in batch.
|
||||
UpdateFAQEntryTagBatch(ctx context.Context, kbID string, updates map[string]*string) error
|
||||
// GetRepository gets the knowledge repository
|
||||
GetRepository() KnowledgeRepository
|
||||
}
|
||||
|
||||
// KnowledgeRepository defines the interface for knowledge repositories.
|
||||
|
||||
@@ -80,6 +80,14 @@ type KnowledgeBaseService interface {
|
||||
// - Copied knowledge base object
|
||||
// - Possible errors such as not existing, insufficient permissions, etc.
|
||||
CopyKnowledgeBase(ctx context.Context, src string, dst string) (*types.KnowledgeBase, *types.KnowledgeBase, error)
|
||||
|
||||
// GetRepository gets the knowledge base repository
|
||||
// Parameters:
|
||||
// - ctx: Context with authentication and request information
|
||||
//
|
||||
// Returns:
|
||||
// - interfaces.KnowledgeBaseRepository: Knowledge base repository
|
||||
GetRepository() KnowledgeBaseRepository
|
||||
}
|
||||
|
||||
// KnowledgeBaseRepository defines the knowledge base repository interface
|
||||
|
||||
@@ -83,7 +83,7 @@ type ConversationConfig struct {
|
||||
// Temperature controls the randomness of the model output
|
||||
Temperature float64 `json:"temperature"`
|
||||
// MaxTokens is the maximum number of tokens to generate
|
||||
MaxTokens int `json:"max_tokens"`
|
||||
MaxCompletionTokens int `json:"max_completion_tokens"`
|
||||
|
||||
// Retrieval & strategy parameters
|
||||
MaxRounds int `json:"max_rounds"`
|
||||
|
||||
Reference in New Issue
Block a user