feat: Introduce query expansion feature and enhance related configurations

- Added support for query expansion in conversation settings, allowing the system to generate additional queries when recall is low.
- Updated localization files in English, Russian, and Chinese to include new strings for the query expansion feature.
- Enhanced UI in AgentSettings.vue to allow users to toggle query expansion settings.
- Refactored related API and service logic to accommodate the new query expansion functionality in session management and chat processing.
This commit is contained in:
wizardchen
2025-11-19 20:23:30 +08:00
parent 5434768530
commit b9c1191dd2
15 changed files with 104 additions and 60 deletions
+1 -1
View File
@@ -746,7 +746,7 @@ func (e *AgentEngine) streamFinalAnswerToEventBus(
})
// Build messages with all context
systemPrompt := BuildReActSystemPromptWithStatus(e.knowledgeBasesInfo, e.config.WebSearchEnabled, e.systemPromptTemplate)
systemPrompt := BuildProgressiveRAGSystemPrompt(e.knowledgeBasesInfo, e.config.WebSearchEnabled, e.systemPromptTemplate)
messages := []chat.Message{
{Role: "system", Content: systemPrompt},
-13
View File
@@ -239,19 +239,6 @@ func BuildProgressiveRAGSystemPrompt(knowledgeBases []*KnowledgeBaseInfo, webSea
return BuildProgressiveRAGSystemPromptWithoutWeb(knowledgeBases, systemPromptTemplate...)
}
// BuildReActSystemPromptWithStatus builds the system prompt, allowing caller to pass tool status
// Deprecated: Use BuildProgressiveRAGSystemPrompt instead for better tool calling capabilities
func BuildReActSystemPromptWithStatus(knowledgeBases []*KnowledgeBaseInfo, webSearchEnabled bool, systemPromptTemplate ...string) string {
var template string
if len(systemPromptTemplate) > 0 && systemPromptTemplate[0] != "" {
template = systemPromptTemplate[0]
} else {
template = DefaultSystemPromptTemplate
}
currentTime := time.Now().Format(time.RFC3339)
return renderPromptPlaceholdersWithStatus(template, knowledgeBases, webSearchEnabled, currentTime)
}
// ProgressiveRAGSystemPromptWithWeb is the progressive RAG system prompt template with web search enabled
// This version emphasizes hybrid retrieval strategy: KB-first with web supplementation
var ProgressiveRAGSystemPromptWithWeb = `# Role & Mission