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:
@@ -506,6 +506,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('conversationSettings.enableQueryExpansion.label') }}</label>
|
||||
<p class="desc">{{ $t('conversationSettings.enableQueryExpansion.desc') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-switch
|
||||
v-model="localEnableQueryExpansion"
|
||||
:label="[$t('common.off'), $t('common.on')]"
|
||||
@change="handleEnableQueryExpansionChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 改写 Prompt:仅在开启改写时展示 -->
|
||||
<div v-if="localEnableRewrite" class="setting-row vertical">
|
||||
<div class="setting-info">
|
||||
@@ -662,6 +676,7 @@ const getDefaultConversationConfig = (): ConversationConfig => ({
|
||||
rerank_top_k: 5,
|
||||
rerank_threshold: 0.5,
|
||||
enable_rewrite: true,
|
||||
enable_query_expansion: true,
|
||||
fallback_strategy: 'fixed',
|
||||
fallback_response: '',
|
||||
fallback_prompt: '',
|
||||
@@ -720,6 +735,7 @@ const localVectorThreshold = ref(0.5)
|
||||
const localRerankTopK = ref(5)
|
||||
const localRerankThreshold = ref(0.5)
|
||||
const localEnableRewrite = ref(true)
|
||||
const localEnableQueryExpansion = ref(true)
|
||||
const localFallbackStrategy = ref<'fixed' | 'model'>('fixed')
|
||||
const localFallbackResponse = ref('')
|
||||
const localFallbackPrompt = ref('')
|
||||
@@ -750,6 +766,7 @@ const syncConversationLocals = () => {
|
||||
localRerankTopK.value = cfg.rerank_top_k ?? 5
|
||||
localRerankThreshold.value = cfg.rerank_threshold ?? 0.5
|
||||
localEnableRewrite.value = cfg.enable_rewrite ?? true
|
||||
localEnableQueryExpansion.value = cfg.enable_query_expansion ?? true
|
||||
localFallbackStrategy.value = (cfg.fallback_strategy as 'fixed' | 'model') || 'fixed'
|
||||
localFallbackResponse.value = cfg.fallback_response ?? ''
|
||||
localFallbackPrompt.value = cfg.fallback_prompt ?? ''
|
||||
@@ -1798,6 +1815,18 @@ const handleEnableRewriteChange = async (value: boolean) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleEnableQueryExpansionChange = async (value: boolean) => {
|
||||
try {
|
||||
await saveConversationConfig(
|
||||
{ enable_query_expansion: value },
|
||||
t('conversationSettings.toasts.enableQueryExpansionSaved')
|
||||
)
|
||||
} catch (error) {
|
||||
console.error('保存 enable_query_expansion 失败:', error)
|
||||
localEnableQueryExpansion.value = conversationConfig.value.enable_query_expansion ?? true
|
||||
}
|
||||
}
|
||||
|
||||
const handleFallbackStrategyChange = async (value: 'fixed' | 'model') => {
|
||||
try {
|
||||
await saveConversationConfig({ fallback_strategy: value }, t('conversationSettings.toasts.fallbackStrategySaved'))
|
||||
|
||||
Reference in New Issue
Block a user