@@ -365,6 +379,7 @@ import KBModelConfig from './settings/KBModelConfig.vue'
import KBParserSettings from './settings/KBParserSettings.vue'
import KBStorageSettings from './settings/KBStorageSettings.vue'
import KBChunkingSettings from './settings/KBChunkingSettings.vue'
+import KBVectorStoreSettings from './settings/KBVectorStoreSettings.vue'
import KBAdvancedSettings from './settings/KBAdvancedSettings.vue'
import ModelSelector from '@/components/ModelSelector.vue'
import GraphSettings from './settings/GraphSettings.vue'
@@ -398,8 +413,9 @@ const hasFiles = ref(false)
const initialStorageProvider = ref
('')
const initialIndexingStrategy = ref(null)
const dsCount = ref(0)
-// KB.creator_id (added in PR 5). Empty for legacy KBs — those fall back
-// to "no owner", so only tenant Admin+ can mutate share settings.
+// Identifier of the user who created this KB. Empty for older rows
+// that predate per-KB ownership tracking; those KBs have no "owner" and
+// only tenant Admin+ can mutate their share settings.
const kbCreatorId = ref('')
// Backend gate for /knowledge-bases/:id/shares (POST/PUT/DELETE) is
@@ -437,7 +453,11 @@ const DEFAULT_CHUNKING_PRESET = {
const navItems = computed(() => {
const items: { key: string; icon: string; label: string; badge?: number }[] = [
{ key: 'basic', icon: 'info-circle', label: t('knowledgeEditor.sidebar.basic') },
- { key: 'models', icon: 'control-platform', label: t('knowledgeEditor.sidebar.models') }
+ { key: 'models', icon: 'control-platform', label: t('knowledgeEditor.sidebar.models') },
+ // VectorStore binding section — present in both create and edit
+ // modes. Create mode shows a dropdown; edit mode shows the bound
+ // store read-only with an immutability hint.
+ { key: 'vectorStore', icon: 'data-base', label: t('knowledgeEditor.sidebar.vectorStore') }
]
if (formData.value?.type === 'faq') {
items.push({ key: 'faq', icon: 'help-circle', label: t('knowledgeEditor.sidebar.faq') })
@@ -555,6 +575,16 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
wikiEnabled: false,
graphEnabled: false,
},
+ // Vector-store binding. Empty string means "use the env-configured
+ // store"; create mode defaults to that, edit mode loads the
+ // existing binding from the KB response below.
+ vectorStoreId: '' as string,
+ vectorStoreInfo: {
+ source: undefined as string | undefined,
+ name: undefined as string | undefined,
+ engineType: undefined as string | undefined,
+ status: undefined as string | undefined,
+ },
}
}
@@ -661,6 +691,19 @@ const loadKBData = async () => {
wikiEnabled: kb.indexing_strategy?.wiki_enabled ?? false,
graphEnabled: kb.indexing_strategy?.graph_enabled ?? false,
},
+ // Vector-store binding. vectorStoreId is editor-only state; it
+ // is only included in the create request, never the update
+ // request, because the binding is immutable after creation.
+ // vectorStoreInfo carries the read-only display fields that the
+ // edit view renders below; they come straight from the KB
+ // response.
+ vectorStoreId: '',
+ vectorStoreInfo: {
+ source: kb.vector_store_source,
+ name: kb.vector_store_name,
+ engineType: kb.vector_store_engine_type,
+ status: kb.vector_store_status,
+ },
}
initialStorageProvider.value = formData.value.storageProvider
initialIndexingStrategy.value = { ...formData.value.indexingStrategy }
@@ -793,6 +836,16 @@ const handleStorageProviderUpdate = (value: string) => {
}
}
+const handleVectorStoreIdUpdate = (id: string) => {
+ if (formData.value) {
+ // Empty string here means "use system default" (env-store fallback).
+ // The create-payload assembly below converts this back to `omit` so
+ // the backend stores NULL — keeping the wire shape identical to
+ // pre-Phase-2 clients.
+ formData.value.vectorStoreId = id || ''
+ }
+}
+
const handleQuestionGenerationUpdate = (config: any) => {
if (formData.value) {
formData.value.questionGenerationConfig = { ...config }
@@ -886,6 +939,15 @@ const buildSubmitData = () => {
summary_model_id: formData.value.modelConfig.llmModelId
}
+ // Vector-store binding. Only attach the field when the user actively
+ // selected a non-default store. The server treats an empty string as
+ // NULL, but keeping the field absent on the wire matches what a
+ // client that doesn't know about this binding would send — which
+ // makes A/B response diffs easier to read.
+ if (formData.value.vectorStoreId) {
+ data.vector_store_id = formData.value.vectorStoreId
+ }
+
// 添加多模态配置
data.vlm_config = {
enabled: formData.value.multimodalConfig.enabled,
@@ -1130,7 +1192,23 @@ const doSubmit = async () => {
handleClose()
} catch (error: any) {
console.error('Knowledge base operation failed:', error)
- MessagePlugin.error(error?.message || t('common.operationFailed'))
+ // Vector-store-binding error codes from the server. Both indicate
+ // the selected store cannot be used: 2200 is "the binding itself
+ // is invalid" (e.g. unknown id, foreign tenant), 2201 is "the
+ // store is currently unreachable". For either, swap in a localized
+ // message and jump the user back to the Vector Store section so
+ // they can pick a different store or fall back to the system
+ // default.
+ const code = error?.response?.data?.error?.code ?? error?.code
+ if (code === 2200) {
+ MessagePlugin.error(t('knowledgeEditor.errors.vectorStoreBindingInvalid'))
+ currentSection.value = 'vectorStore'
+ } else if (code === 2201) {
+ MessagePlugin.error(t('knowledgeEditor.errors.vectorStoreUnavailable'))
+ currentSection.value = 'vectorStore'
+ } else {
+ MessagePlugin.error(error?.message || t('common.operationFailed'))
+ }
} finally {
saving.value = false
}
diff --git a/frontend/src/views/knowledge/KnowledgeBaseList.vue b/frontend/src/views/knowledge/KnowledgeBaseList.vue
index 267abdf0..e3930791 100644
--- a/frontend/src/views/knowledge/KnowledgeBaseList.vue
+++ b/frontend/src/views/knowledge/KnowledgeBaseList.vue
@@ -277,6 +277,32 @@