2025-11-06 13:12:26 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<Teleport to="body">
|
|
|
|
|
|
<Transition name="modal">
|
|
|
|
|
|
<div v-if="visible" class="settings-overlay" @click.self="handleClose">
|
|
|
|
|
|
<div class="settings-modal">
|
2026-09-02 09:20:37 +00:00
|
|
|
|
<div v-if="loading" class="editor-initializing" role="status" :aria-label="$t('common.loading')">
|
|
|
|
|
|
<t-loading size="medium" :text="$t('common.loading')" />
|
|
|
|
|
|
</div>
|
2025-11-06 13:12:26 +00:00
|
|
|
|
<!-- 关闭按钮 -->
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<button class="close-btn" @click="handleClose" :aria-label="$t('general.close')">
|
2025-11-06 13:12:26 +00:00
|
|
|
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
|
|
|
|
|
<path d="M15 5L5 15M5 5L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
|
|
|
|
</svg>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="settings-container">
|
|
|
|
|
|
<!-- 左侧导航 -->
|
|
|
|
|
|
<div class="settings-sidebar">
|
|
|
|
|
|
<div class="sidebar-header">
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<h2 class="sidebar-title">{{ editorMode === 'create' ? $t('knowledgeEditor.titleCreate') : $t('knowledgeEditor.titleEdit') }}</h2>
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</div>
|
2026-06-03 06:41:12 +00:00
|
|
|
|
<div class="settings-nav" data-guide="kb-editor-sidebar">
|
2026-06-12 14:40:18 +00:00
|
|
|
|
<template v-for="group in navGroups" :key="group.key">
|
|
|
|
|
|
<div class="nav-group-title">{{ group.label }}</div>
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(item, index) in group.items"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
:class="['nav-item', { 'active': currentSection === item.key }]"
|
|
|
|
|
|
:data-guide="`kb-editor-nav-${item.key}`"
|
|
|
|
|
|
@click="currentSection = item.key"
|
|
|
|
|
|
>
|
|
|
|
|
|
<t-icon :name="item.icon" class="nav-icon" />
|
|
|
|
|
|
<span class="nav-label">{{ item.label }}</span>
|
|
|
|
|
|
<span v-if="item.badge" class="nav-badge">{{ item.badge }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 右侧内容区域 -->
|
|
|
|
|
|
<div class="settings-content">
|
|
|
|
|
|
<div class="content-wrapper">
|
|
|
|
|
|
<!-- 基本信息 -->
|
|
|
|
|
|
<div v-show="currentSection === 'basic'" class="section">
|
|
|
|
|
|
<div v-if="formData" class="section-content">
|
|
|
|
|
|
<div class="section-header">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<h3 class="section-title">{{ $t('knowledgeEditor.basic.title') }}</h3>
|
|
|
|
|
|
<p class="section-desc">{{ $t('knowledgeEditor.basic.description') }}</p>
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="section-body">
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<div v-if="editorMode === 'edit' && activeKbId" class="form-item">
|
2026-05-28 12:53:34 +00:00
|
|
|
|
<label class="form-label">{{ $t('knowledgeEditor.basic.kbId') }}</label>
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<p class="form-tip">{{ isPostCreateSession ? $t('knowledgeEditor.postCreateHint.followUpDesc') : $t('knowledgeEditor.basic.kbIdDesc') }}</p>
|
2026-05-28 12:53:34 +00:00
|
|
|
|
<div class="kb-id-field">
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<code class="kb-id-value" :title="activeKbId">{{ activeKbId }}</code>
|
2026-05-28 12:53:34 +00:00
|
|
|
|
<t-tooltip :content="$t('common.copy')" placement="top">
|
|
|
|
|
|
<t-button theme="default" size="small" variant="text" class="kb-id-copy"
|
|
|
|
|
|
@click="copyKbId">
|
|
|
|
|
|
<t-icon name="file-copy" />
|
|
|
|
|
|
</t-button>
|
|
|
|
|
|
</t-tooltip>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
<div class="form-item">
|
|
|
|
|
|
<label class="form-label required">{{ $t('knowledgeEditor.basic.typeLabel') }}</label>
|
|
|
|
|
|
<t-radio-group
|
|
|
|
|
|
v-model="formData.type"
|
2026-07-31 03:42:09 +00:00
|
|
|
|
:disabled="editorMode === 'edit'"
|
2026-06-03 06:41:12 +00:00
|
|
|
|
data-guide="kb-create-type"
|
2025-11-14 17:30:17 +00:00
|
|
|
|
>
|
|
|
|
|
|
<t-radio-button value="document">{{ $t('knowledgeEditor.basic.typeDocument') }}</t-radio-button>
|
|
|
|
|
|
<t-radio-button value="faq">{{ $t('knowledgeEditor.basic.typeFAQ') }}</t-radio-button>
|
|
|
|
|
|
</t-radio-group>
|
|
|
|
|
|
<p class="form-tip">{{ $t('knowledgeEditor.basic.typeDescription') }}</p>
|
|
|
|
|
|
</div>
|
2026-04-20 11:16:46 +00:00
|
|
|
|
|
|
|
|
|
|
<!-- 索引策略 (紧跟类型选择) -->
|
|
|
|
|
|
<div v-if="!isFAQ" class="form-item">
|
2026-04-20 13:54:54 +00:00
|
|
|
|
<label class="form-label required">{{ $t('knowledgeEditor.indexing.title') }}</label>
|
|
|
|
|
|
<p class="form-tip">{{ $t('knowledgeEditor.indexing.description') }}</p>
|
2026-06-03 06:41:12 +00:00
|
|
|
|
<div class="indexing-checks" :class="{ 'is-locked': isIndexingLocked }"
|
|
|
|
|
|
data-guide="kb-create-indexing">
|
2026-04-20 13:54:54 +00:00
|
|
|
|
<div
|
|
|
|
|
|
class="indexing-check-item"
|
2026-04-21 06:46:41 +00:00
|
|
|
|
:class="{ 'is-checked': formData.indexingStrategy.vectorEnabled, 'is-disabled': isIndexingLocked }"
|
2026-04-20 13:54:54 +00:00
|
|
|
|
@click="toggleVectorIndexing"
|
|
|
|
|
|
>
|
|
|
|
|
|
<t-checkbox
|
|
|
|
|
|
:checked="formData.indexingStrategy.vectorEnabled"
|
2026-04-21 06:46:41 +00:00
|
|
|
|
:disabled="isIndexingLocked"
|
2026-04-20 13:54:54 +00:00
|
|
|
|
class="indexing-check-box"
|
|
|
|
|
|
>{{ $t('knowledgeEditor.indexing.searchTitle') }}</t-checkbox>
|
|
|
|
|
|
<p class="indexing-check-desc">{{ $t('knowledgeEditor.indexing.searchDesc') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="indexing-check-item"
|
2026-04-21 06:46:41 +00:00
|
|
|
|
:class="{ 'is-checked': formData.indexingStrategy.wikiEnabled, 'is-disabled': isIndexingLocked }"
|
|
|
|
|
|
@click="toggleWikiIndexing"
|
2026-04-20 13:54:54 +00:00
|
|
|
|
>
|
|
|
|
|
|
<t-checkbox
|
|
|
|
|
|
:checked="formData.indexingStrategy.wikiEnabled"
|
2026-04-21 06:46:41 +00:00
|
|
|
|
:disabled="isIndexingLocked"
|
2026-04-20 13:54:54 +00:00
|
|
|
|
class="indexing-check-box"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span class="indexing-check-title">
|
|
|
|
|
|
{{ $t('knowledgeEditor.indexing.wikiTitle') }}
|
|
|
|
|
|
<span class="indexing-new-badge">NEW</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</t-checkbox>
|
|
|
|
|
|
<p class="indexing-check-desc">{{ $t('knowledgeEditor.indexing.wikiDesc') }}</p>
|
|
|
|
|
|
</div>
|
2026-04-20 11:16:46 +00:00
|
|
|
|
</div>
|
2026-04-21 06:46:41 +00:00
|
|
|
|
<p v-if="isIndexingLocked" class="form-tip locked-tip">
|
|
|
|
|
|
{{ $t('knowledgeEditor.indexing.lockedTip') }}
|
|
|
|
|
|
</p>
|
2026-04-20 11:16:46 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-04-22 12:27:19 +00:00
|
|
|
|
<!-- Wiki 提取粒度 (仅当 Wiki 启用时显示) -->
|
|
|
|
|
|
<div v-if="!isFAQ && formData.indexingStrategy.wikiEnabled" class="form-item">
|
|
|
|
|
|
<label class="form-label">{{ $t('knowledgeEditor.wiki.extractionGranularityLabel') }}</label>
|
|
|
|
|
|
<p class="form-tip">{{ $t('knowledgeEditor.wiki.extractionGranularityTip') }}</p>
|
|
|
|
|
|
<t-radio-group
|
|
|
|
|
|
:value="resolvedGranularity"
|
|
|
|
|
|
class="granularity-radio-group"
|
|
|
|
|
|
@change="handleGranularityChange"
|
|
|
|
|
|
>
|
|
|
|
|
|
<t-radio-button value="focused">
|
|
|
|
|
|
{{ $t('knowledgeEditor.wiki.granularityFocused') }}
|
|
|
|
|
|
</t-radio-button>
|
|
|
|
|
|
<t-radio-button value="standard">
|
|
|
|
|
|
{{ $t('knowledgeEditor.wiki.granularityStandard') }}
|
|
|
|
|
|
</t-radio-button>
|
|
|
|
|
|
<t-radio-button value="exhaustive">
|
|
|
|
|
|
{{ $t('knowledgeEditor.wiki.granularityExhaustive') }}
|
|
|
|
|
|
</t-radio-button>
|
|
|
|
|
|
</t-radio-group>
|
|
|
|
|
|
<p class="form-tip granularity-hint">{{ granularityHint }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-07-13 03:57:30 +00:00
|
|
|
|
<div v-if="!isFAQ && formData.indexingStrategy.wikiEnabled" class="form-item">
|
|
|
|
|
|
<label class="form-label">{{ $t('knowledgeEditor.wiki.contentInstructionsLabel') }}</label>
|
|
|
|
|
|
<p class="form-tip">{{ $t('knowledgeEditor.wiki.contentInstructionsTip') }}</p>
|
|
|
|
|
|
<t-textarea
|
|
|
|
|
|
v-model="formData.wikiConfig.contentInstructions"
|
|
|
|
|
|
:placeholder="$t('knowledgeEditor.wiki.contentInstructionsPlaceholder')"
|
|
|
|
|
|
:maxlength="4000"
|
|
|
|
|
|
:autosize="{ minRows: 3, maxRows: 8 }"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div v-if="!isFAQ && formData.indexingStrategy.wikiEnabled" class="form-item">
|
|
|
|
|
|
<label class="form-label">{{ $t('knowledgeEditor.wiki.extractionInstructionsLabel') }}</label>
|
|
|
|
|
|
<p class="form-tip">{{ $t('knowledgeEditor.wiki.extractionInstructionsTip') }}</p>
|
|
|
|
|
|
<t-textarea
|
|
|
|
|
|
v-model="formData.wikiConfig.extractionInstructions"
|
|
|
|
|
|
:placeholder="$t('knowledgeEditor.wiki.extractionInstructionsPlaceholder')"
|
|
|
|
|
|
:maxlength="4000"
|
|
|
|
|
|
:autosize="{ minRows: 3, maxRows: 8 }"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-06-03 06:41:12 +00:00
|
|
|
|
<div class="form-item" data-guide="kb-create-name">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label required">{{ $t('knowledgeEditor.basic.nameLabel') }}</label>
|
2025-11-06 13:12:26 +00:00
|
|
|
|
<t-input
|
|
|
|
|
|
v-model="formData.name"
|
2025-11-13 11:34:33 +00:00
|
|
|
|
:placeholder="$t('knowledgeEditor.basic.namePlaceholder')"
|
2025-11-06 13:12:26 +00:00
|
|
|
|
:maxlength="50"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="form-item">
|
2025-11-13 11:34:33 +00:00
|
|
|
|
<label class="form-label">{{ $t('knowledgeEditor.basic.descriptionLabel') }}</label>
|
2026-04-20 11:16:46 +00:00
|
|
|
|
<t-textarea
|
|
|
|
|
|
v-model="formData.description"
|
2025-11-13 11:34:33 +00:00
|
|
|
|
:placeholder="$t('knowledgeEditor.basic.descriptionPlaceholder')"
|
2025-11-06 13:12:26 +00:00
|
|
|
|
:maxlength="200"
|
|
|
|
|
|
:autosize="{ minRows: 3, maxRows: 6 }"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-04-20 11:16:46 +00:00
|
|
|
|
|
|
|
|
|
|
<!-- Wiki 合成模型移至模型配置页 -->
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 模型配置 -->
|
|
|
|
|
|
<div v-show="currentSection === 'models'" class="section">
|
|
|
|
|
|
<KBModelConfig
|
|
|
|
|
|
ref="modelConfigRef"
|
|
|
|
|
|
v-if="formData"
|
|
|
|
|
|
:config="formData.modelConfig"
|
|
|
|
|
|
:has-files="hasFiles"
|
2026-04-20 11:16:46 +00:00
|
|
|
|
:wiki-enabled="formData.indexingStrategy?.wikiEnabled"
|
|
|
|
|
|
:rag-enabled="formData.indexingStrategy?.vectorEnabled || formData.indexingStrategy?.keywordEnabled"
|
2025-11-06 13:12:26 +00:00
|
|
|
|
:all-models="allModels"
|
|
|
|
|
|
@update:config="handleModelConfigUpdate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
<!-- VectorStore 绑定 -->
|
|
|
|
|
|
<div v-show="currentSection === 'vectorStore'" class="section">
|
|
|
|
|
|
<KBVectorStoreSettings
|
|
|
|
|
|
v-if="formData"
|
2026-07-31 03:42:09 +00:00
|
|
|
|
:mode="editorMode"
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
:vector-store-id="formData.vectorStoreId"
|
|
|
|
|
|
:bound-source="formData.vectorStoreInfo?.source"
|
|
|
|
|
|
:bound-name="formData.vectorStoreInfo?.name"
|
|
|
|
|
|
:bound-engine-type="formData.vectorStoreInfo?.engineType"
|
|
|
|
|
|
:bound-status="formData.vectorStoreInfo?.status"
|
|
|
|
|
|
@update:vector-store-id="handleVectorStoreIdUpdate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
<!-- FAQ 配置 -->
|
|
|
|
|
|
<div v-if="isFAQ && formData" v-show="currentSection === 'faq'" class="section">
|
|
|
|
|
|
<div class="section-content">
|
|
|
|
|
|
<div class="section-header">
|
|
|
|
|
|
<h3 class="section-title">{{ $t('knowledgeEditor.faq.title') }}</h3>
|
|
|
|
|
|
<p class="section-desc">{{ $t('knowledgeEditor.faq.description') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="section-body">
|
|
|
|
|
|
<div class="form-item">
|
|
|
|
|
|
<label class="form-label required">{{ $t('knowledgeEditor.faq.indexModeLabel') }}</label>
|
|
|
|
|
|
<t-radio-group
|
|
|
|
|
|
v-model="formData.faqConfig.indexMode"
|
|
|
|
|
|
>
|
|
|
|
|
|
<t-radio-button value="question_only">{{ $t('knowledgeEditor.faq.modes.questionOnly') }}</t-radio-button>
|
|
|
|
|
|
<t-radio-button value="question_answer">{{ $t('knowledgeEditor.faq.modes.questionAnswer') }}</t-radio-button>
|
|
|
|
|
|
</t-radio-group>
|
|
|
|
|
|
<p class="form-tip">{{ $t('knowledgeEditor.faq.indexModeDescription') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="form-item">
|
|
|
|
|
|
<label class="form-label required">{{ $t('knowledgeEditor.faq.questionIndexModeLabel') }}</label>
|
|
|
|
|
|
<t-radio-group
|
|
|
|
|
|
v-model="formData.faqConfig.questionIndexMode"
|
|
|
|
|
|
>
|
|
|
|
|
|
<t-radio-button value="combined">{{ $t('knowledgeEditor.faq.modes.combined') }}</t-radio-button>
|
|
|
|
|
|
<t-radio-button value="separate">{{ $t('knowledgeEditor.faq.modes.separate') }}</t-radio-button>
|
|
|
|
|
|
</t-radio-group>
|
|
|
|
|
|
<p class="form-tip">{{ $t('knowledgeEditor.faq.questionIndexModeDescription') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="faq-guide">
|
|
|
|
|
|
<p>{{ $t('knowledgeEditor.faq.entryGuide') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-02-28 05:22:07 +00:00
|
|
|
|
<!-- 解析引擎 -->
|
2026-06-08 12:55:54 +00:00
|
|
|
|
<div v-if="!isFAQ && formData && currentSection === 'parser'" class="section">
|
2026-02-28 05:22:07 +00:00
|
|
|
|
<KBParserSettings
|
|
|
|
|
|
:parser-engine-rules="formData.chunkingConfig.parserEngineRules"
|
|
|
|
|
|
@update:parser-engine-rules="handleParserEngineRulesUpdate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 存储引擎 -->
|
2026-06-08 12:55:54 +00:00
|
|
|
|
<div v-if="!isFAQ && formData && currentSection === 'storage'" class="section">
|
2026-02-28 05:22:07 +00:00
|
|
|
|
<KBStorageSettings
|
2026-07-15 05:26:29 +00:00
|
|
|
|
:storage-backend-id="formData.storageBackendId"
|
2026-02-28 05:22:07 +00:00
|
|
|
|
:storage-provider="formData.storageProvider"
|
2026-07-31 03:42:09 +00:00
|
|
|
|
:has-files="editorMode === 'edit' && hasFiles"
|
2026-07-15 05:26:29 +00:00
|
|
|
|
@update:storage-backend-id="handleStorageBackendUpdate"
|
2026-02-28 05:22:07 +00:00
|
|
|
|
@update:storage-provider="handleStorageProviderUpdate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
<!-- 分块设置 -->
|
2026-04-07 11:36:06 +00:00
|
|
|
|
<div v-if="!isFAQ" v-show="currentSection === 'chunking'" class="section">
|
2025-11-06 13:12:26 +00:00
|
|
|
|
<KBChunkingSettings
|
|
|
|
|
|
v-if="formData"
|
|
|
|
|
|
:config="formData.chunkingConfig"
|
|
|
|
|
|
@update:config="handleChunkingConfigUpdate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-03-11 13:16:23 +00:00
|
|
|
|
<!-- 多模态配置 -->
|
2026-04-07 11:36:06 +00:00
|
|
|
|
<div v-if="!isFAQ" v-show="currentSection === 'multimodal'" class="section">
|
2026-03-11 13:16:23 +00:00
|
|
|
|
<div v-if="formData" class="kb-multimodal-settings">
|
|
|
|
|
|
<div class="section-header">
|
|
|
|
|
|
<h2>{{ $t('knowledgeEditor.multimodal.title') }}</h2>
|
|
|
|
|
|
<p class="section-description">{{ $t('knowledgeEditor.multimodal.description') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="settings-group">
|
|
|
|
|
|
<!-- 多模态开关 -->
|
2026-06-03 06:41:12 +00:00
|
|
|
|
<div class="setting-row" data-guide="kb-create-multimodal-toggle">
|
2026-03-11 13:16:23 +00:00
|
|
|
|
<div class="setting-info">
|
|
|
|
|
|
<label>{{ $t('knowledgeEditor.advanced.multimodal.label') }}</label>
|
|
|
|
|
|
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.description') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="setting-control">
|
|
|
|
|
|
<t-switch
|
|
|
|
|
|
v-model="formData.multimodalConfig.enabled"
|
|
|
|
|
|
@change="handleMultimodalToggle"
|
|
|
|
|
|
size="medium"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- VLLM 模型选择(多模态启用时) -->
|
2026-06-03 06:41:12 +00:00
|
|
|
|
<div v-if="formData.multimodalConfig.enabled" class="setting-row"
|
|
|
|
|
|
data-guide="kb-create-multimodal-vllm">
|
2026-03-11 13:16:23 +00:00
|
|
|
|
<div class="setting-info">
|
|
|
|
|
|
<label>{{ $t('knowledgeEditor.advanced.multimodal.vllmLabel') }} <span class="required">*</span></label>
|
|
|
|
|
|
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.vllmDescription') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="setting-control">
|
|
|
|
|
|
<ModelSelector
|
|
|
|
|
|
model-type="VLLM"
|
|
|
|
|
|
:selected-model-id="formData.multimodalConfig.vllmModelId"
|
|
|
|
|
|
:all-models="allModels"
|
|
|
|
|
|
@update:selected-model-id="handleMultimodalVLLMChange"
|
|
|
|
|
|
@add-model="handleAddVLLMModel"
|
|
|
|
|
|
:placeholder="$t('knowledgeEditor.advanced.multimodal.vllmPlaceholder')"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-07-13 03:57:30 +00:00
|
|
|
|
|
|
|
|
|
|
<div v-if="formData.multimodalConfig.enabled" class="setting-row">
|
|
|
|
|
|
<div class="setting-info">
|
|
|
|
|
|
<label>{{ $t('knowledgeEditor.advanced.multimodal.descriptionLanguageLabel') }}</label>
|
|
|
|
|
|
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.descriptionLanguageDescription') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="setting-control">
|
|
|
|
|
|
<t-select v-model="formData.multimodalConfig.descriptionLanguage" clearable
|
|
|
|
|
|
:placeholder="$t('knowledgeEditor.advanced.multimodal.descriptionLanguageAuto')">
|
|
|
|
|
|
<t-option value="Chinese" :label="$t('language.zhCN')" />
|
|
|
|
|
|
<t-option value="English" :label="$t('language.enUS')" />
|
|
|
|
|
|
<t-option value="Korean" :label="$t('language.koKR')" />
|
|
|
|
|
|
<t-option value="Russian" :label="$t('language.ruRU')" />
|
|
|
|
|
|
</t-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div v-if="formData.multimodalConfig.enabled" class="setting-row setting-row-vertical">
|
|
|
|
|
|
<div class="setting-info">
|
|
|
|
|
|
<label>{{ $t('knowledgeEditor.advanced.multimodal.customInstructionsLabel') }}</label>
|
|
|
|
|
|
<p class="desc">{{ $t('knowledgeEditor.advanced.multimodal.customInstructionsDescription') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="setting-control setting-control-full">
|
|
|
|
|
|
<t-textarea v-model="formData.multimodalConfig.customInstructions"
|
|
|
|
|
|
:placeholder="$t('knowledgeEditor.advanced.multimodal.customInstructionsPlaceholder')"
|
|
|
|
|
|
:maxlength="4000" :autosize="{ minRows: 3, maxRows: 8 }" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-03-11 13:16:23 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
<!-- 音频处理(ASR)设置 -->
|
2026-04-07 11:36:06 +00:00
|
|
|
|
<div v-if="!isFAQ" v-show="currentSection === 'asr'" class="section">
|
2026-04-02 08:43:37 +00:00
|
|
|
|
<div v-if="formData" class="kb-multimodal-settings">
|
|
|
|
|
|
<div class="section-header">
|
|
|
|
|
|
<h2>{{ $t('knowledgeEditor.asr.title') }}</h2>
|
|
|
|
|
|
<p class="section-description">{{ $t('knowledgeEditor.asr.description') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="settings-group">
|
|
|
|
|
|
<!-- ASR 开关 -->
|
|
|
|
|
|
<div class="setting-row">
|
|
|
|
|
|
<div class="setting-info">
|
|
|
|
|
|
<label>{{ $t('knowledgeEditor.asr.label') }}</label>
|
|
|
|
|
|
<p class="desc">{{ $t('knowledgeEditor.asr.desc') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="setting-control">
|
|
|
|
|
|
<t-switch
|
|
|
|
|
|
v-model="formData.asrConfig.enabled"
|
|
|
|
|
|
size="medium"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ASR 模型选择 -->
|
|
|
|
|
|
<div v-if="formData.asrConfig.enabled" class="setting-row">
|
|
|
|
|
|
<div class="setting-info">
|
|
|
|
|
|
<label>{{ $t('knowledgeEditor.asr.modelLabel') }} <span class="required">*</span></label>
|
|
|
|
|
|
<p class="desc">{{ $t('knowledgeEditor.asr.modelDescription') }}</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="setting-control">
|
|
|
|
|
|
<ModelSelector
|
|
|
|
|
|
model-type="ASR"
|
|
|
|
|
|
:selected-model-id="formData.asrConfig.modelId"
|
|
|
|
|
|
:all-models="allModels"
|
|
|
|
|
|
@update:selected-model-id="(val: string) => { if (formData) formData.asrConfig.modelId = val }"
|
2026-04-03 04:14:33 +00:00
|
|
|
|
@add-model="handleAddASRModel"
|
2026-04-02 08:43:37 +00:00
|
|
|
|
:placeholder="$t('knowledgeEditor.asr.modelPlaceholder')"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-04-20 11:16:46 +00:00
|
|
|
|
<!-- 知识图谱 -->
|
2026-06-08 12:55:54 +00:00
|
|
|
|
<div v-if="!isFAQ && currentSection === 'graph'" class="section">
|
2026-04-20 11:16:46 +00:00
|
|
|
|
<GraphSettings
|
|
|
|
|
|
v-if="formData"
|
|
|
|
|
|
:graph-extract="formData.nodeExtractConfig"
|
|
|
|
|
|
:model-id="formData.modelConfig.llmModelId"
|
|
|
|
|
|
:all-models="allModels"
|
|
|
|
|
|
@update:graphExtract="handleNodeExtractUpdate"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
<!-- 高级设置 -->
|
2026-04-07 11:36:06 +00:00
|
|
|
|
<div v-if="!isFAQ" v-show="currentSection === 'advanced'" class="section">
|
2025-11-06 13:12:26 +00:00
|
|
|
|
<KBAdvancedSettings
|
|
|
|
|
|
ref="advancedSettingsRef"
|
|
|
|
|
|
v-if="formData"
|
2025-12-02 17:42:31 +00:00
|
|
|
|
:question-generation="formData.questionGenerationConfig"
|
2026-08-05 13:56:58 +00:00
|
|
|
|
:auto-tag="formData.autoTagConfig"
|
2026-04-20 11:16:46 +00:00
|
|
|
|
:rag-enabled="formData.indexingStrategy?.vectorEnabled || formData.indexingStrategy?.keywordEnabled"
|
2025-11-06 13:12:26 +00:00
|
|
|
|
:all-models="allModels"
|
2026-07-13 03:57:30 +00:00
|
|
|
|
:table-metadata-instructions="formData.chunkingConfig.tableMetadataInstructions"
|
2025-12-02 17:42:31 +00:00
|
|
|
|
@update:question-generation="handleQuestionGenerationUpdate"
|
2026-08-05 13:56:58 +00:00
|
|
|
|
@update:auto-tag="(value) => { if (formData) formData.autoTagConfig = value }"
|
2026-07-13 03:57:30 +00:00
|
|
|
|
@update:table-metadata-instructions="(value: string) => { if (formData) formData.chunkingConfig.tableMetadataInstructions = value }"
|
2025-11-06 13:12:26 +00:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-01-30 08:28:01 +00:00
|
|
|
|
|
2026-03-27 07:02:40 +00:00
|
|
|
|
<!-- 数据源管理(仅编辑模式) -->
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<div v-if="editorMode === 'edit' && activeKbId && currentSection === 'datasource'" class="section">
|
|
|
|
|
|
<DataSourceSettings :kb-id="activeKbId" @count="dsCount = $event" />
|
2026-03-27 07:02:40 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-01-30 08:28:01 +00:00
|
|
|
|
<!-- 共享设置(仅编辑模式) -->
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<div v-if="editorMode === 'edit' && activeKbId && currentSection === 'share'" class="section">
|
|
|
|
|
|
<KBShareSettings :kb-id="activeKbId" :can-share="canShareKB" />
|
2026-01-30 08:28:01 +00:00
|
|
|
|
</div>
|
2026-07-22 11:15:27 +00:00
|
|
|
|
|
|
|
|
|
|
<!-- 活动记录(仅编辑模式,KB 所属租户内 Owner/Admin) -->
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<div v-if="editorMode === 'edit' && activeKbId && canViewActivity && currentSection === 'activity'" class="section">
|
|
|
|
|
|
<KnowledgeBaseActivitySettings :kb-id="activeKbId" :active="currentSection === 'activity'" />
|
2026-07-22 11:15:27 +00:00
|
|
|
|
</div>
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 保存按钮 -->
|
|
|
|
|
|
<div class="settings-footer">
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<p v-if="isPostCreateSession" class="settings-footer-note">
|
|
|
|
|
|
<t-icon name="check-circle-filled" class="settings-footer-note__icon" />
|
|
|
|
|
|
<span>
|
|
|
|
|
|
<strong>{{ $t('knowledgeEditor.postCreateHint.title') }}</strong>
|
|
|
|
|
|
{{ $t('knowledgeEditor.postCreateHint.footer') }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<div class="settings-footer-actions">
|
|
|
|
|
|
<t-button theme="default" variant="outline" @click="handleClose">
|
|
|
|
|
|
{{ $t('common.cancel') }}
|
|
|
|
|
|
</t-button>
|
2026-09-02 09:20:37 +00:00
|
|
|
|
<t-button theme="primary" data-guide="kb-create-submit" @click="handleSubmit" :loading="saving"
|
|
|
|
|
|
:disabled="loading">
|
2026-07-31 03:42:09 +00:00
|
|
|
|
{{ saveButtonLabel }}
|
|
|
|
|
|
</t-button>
|
|
|
|
|
|
</div>
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Transition>
|
|
|
|
|
|
</Teleport>
|
2026-06-03 06:41:12 +00:00
|
|
|
|
|
2026-07-31 03:42:09 +00:00
|
|
|
|
<KbCreateContextualGuide :when="visible && editorMode === 'create'" :is-faq="isFAQ"
|
2026-06-03 06:41:12 +00:00
|
|
|
|
:needs-embedding="kbCreateNeedsEmbedding" />
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-06-03 06:41:12 +00:00
|
|
|
|
import { ref, computed, watch, onMounted, onBeforeUnmount } from 'vue'
|
|
|
|
|
|
import KbCreateContextualGuide from '@/components/KbCreateContextualGuide.vue'
|
|
|
|
|
|
import { KB_EDITOR_FOCUS_SECTION_EVENT, markContextualGuideDone } from '@/config/contextualGuides'
|
2026-03-09 12:27:24 +00:00
|
|
|
|
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
|
2026-04-20 11:16:46 +00:00
|
|
|
|
import { createKnowledgeBase, getKnowledgeBaseById, listKnowledgeFiles, updateKnowledgeBase, rebuildKBIndex } from '@/api/knowledge-base'
|
2025-11-06 13:12:26 +00:00
|
|
|
|
import { updateKBConfig, type KBModelConfigRequest } from '@/api/initialization'
|
2026-06-08 12:55:54 +00:00
|
|
|
|
import { useChatResourcesStore } from '@/stores/chatResources'
|
2026-08-10 02:55:36 +00:00
|
|
|
|
import { selectInitialModelId } from '@/utils/modelDefaults'
|
2026-08-12 06:20:20 +00:00
|
|
|
|
import { copyWithToast } from '@/utils/clipboard'
|
2026-06-08 12:55:54 +00:00
|
|
|
|
import { useEditorResourcesStore } from '@/stores/editorResources'
|
2025-11-07 08:40:53 +00:00
|
|
|
|
import { useUIStore } from '@/stores/ui'
|
2026-04-11 06:05:56 +00:00
|
|
|
|
import { useAuthStore } from '@/stores/auth'
|
2025-11-06 13:12:26 +00:00
|
|
|
|
import KBModelConfig from './settings/KBModelConfig.vue'
|
2026-02-28 05:22:07 +00:00
|
|
|
|
import KBParserSettings from './settings/KBParserSettings.vue'
|
|
|
|
|
|
import KBStorageSettings from './settings/KBStorageSettings.vue'
|
2025-11-06 13:12:26 +00:00
|
|
|
|
import KBChunkingSettings from './settings/KBChunkingSettings.vue'
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
import KBVectorStoreSettings from './settings/KBVectorStoreSettings.vue'
|
2025-11-06 13:12:26 +00:00
|
|
|
|
import KBAdvancedSettings from './settings/KBAdvancedSettings.vue'
|
2026-03-11 13:16:23 +00:00
|
|
|
|
import ModelSelector from '@/components/ModelSelector.vue'
|
2025-11-25 08:44:44 +00:00
|
|
|
|
import GraphSettings from './settings/GraphSettings.vue'
|
2026-01-30 08:28:01 +00:00
|
|
|
|
import KBShareSettings from './settings/KBShareSettings.vue'
|
2026-03-27 07:02:40 +00:00
|
|
|
|
import DataSourceSettings from './settings/DataSourceSettings.vue'
|
2026-07-22 11:15:27 +00:00
|
|
|
|
import KnowledgeBaseActivitySettings from './settings/KnowledgeBaseActivitySettings.vue'
|
2025-11-13 11:34:33 +00:00
|
|
|
|
import { useI18n } from 'vue-i18n'
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
2025-11-07 08:40:53 +00:00
|
|
|
|
const uiStore = useUIStore()
|
2026-04-11 06:05:56 +00:00
|
|
|
|
const authStore = useAuthStore()
|
2026-06-08 12:55:54 +00:00
|
|
|
|
const chatResources = useChatResourcesStore()
|
|
|
|
|
|
const editorResources = useEditorResourcesStore()
|
2025-11-13 11:34:33 +00:00
|
|
|
|
const { t } = useI18n()
|
2025-11-07 08:40:53 +00:00
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
// Props
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
|
visible: boolean
|
|
|
|
|
|
mode: 'create' | 'edit'
|
|
|
|
|
|
kbId?: string
|
2026-04-07 11:36:06 +00:00
|
|
|
|
initialType?: 'document' | 'faq'
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
|
|
// Emits
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
|
(e: 'update:visible', value: boolean): void
|
|
|
|
|
|
(e: 'success', kbId: string): void
|
|
|
|
|
|
}>()
|
|
|
|
|
|
|
2026-07-31 03:42:09 +00:00
|
|
|
|
/** 首次保存创建成功后留在弹窗内,继续配置共享等设置 */
|
|
|
|
|
|
const savedKbId = ref<string | null>(null)
|
|
|
|
|
|
const editorMode = computed(() => (savedKbId.value ? 'edit' : props.mode))
|
|
|
|
|
|
const activeKbId = computed(() => savedKbId.value ?? props.kbId)
|
|
|
|
|
|
const isPostCreateSession = computed(() => !!savedKbId.value)
|
|
|
|
|
|
const saveButtonLabel = computed(() =>
|
|
|
|
|
|
editorMode.value === 'create'
|
|
|
|
|
|
? t('knowledgeEditor.buttons.create')
|
|
|
|
|
|
: t('knowledgeEditor.buttons.saveAndClose')
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-05-28 12:53:34 +00:00
|
|
|
|
const copyKbId = async () => {
|
2026-08-12 06:20:20 +00:00
|
|
|
|
await copyWithToast(activeKbId.value, 'common.copied')
|
2026-05-28 12:53:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
const currentSection = ref<string>('basic')
|
2026-06-03 06:41:12 +00:00
|
|
|
|
|
|
|
|
|
|
const onKbEditorFocusSection = (event: Event) => {
|
|
|
|
|
|
const section = (event as CustomEvent<{ section?: string }>).detail?.section
|
|
|
|
|
|
if (section) {
|
|
|
|
|
|
currentSection.value = section
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
window.addEventListener(KB_EDITOR_FOCUS_SECTION_EVENT, onKbEditorFocusSection)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
window.removeEventListener(KB_EDITOR_FOCUS_SECTION_EVENT, onKbEditorFocusSection)
|
|
|
|
|
|
})
|
2025-11-06 13:12:26 +00:00
|
|
|
|
const saving = ref(false)
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
const allModels = ref<any[]>([])
|
|
|
|
|
|
const hasFiles = ref(false)
|
2026-03-09 12:27:24 +00:00
|
|
|
|
const initialStorageProvider = ref<string>('')
|
2026-05-29 05:36:06 +00:00
|
|
|
|
/** Tenant-wide default from Settings → Storage engine (used when creating a KB). */
|
|
|
|
|
|
const tenantDefaultStorageProvider = ref('local')
|
2026-04-20 11:16:46 +00:00
|
|
|
|
const initialIndexingStrategy = ref<any>(null)
|
2026-03-30 05:32:39 +00:00
|
|
|
|
const dsCount = ref(0)
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
// 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.
|
2026-05-15 09:56:58 +00:00
|
|
|
|
const kbCreatorId = ref<string>('')
|
2026-07-22 11:15:27 +00:00
|
|
|
|
const kbTenantId = ref<number>(0)
|
2026-05-15 09:56:58 +00:00
|
|
|
|
|
|
|
|
|
|
// Backend gate for /knowledge-bases/:id/shares (POST/PUT/DELETE) is
|
|
|
|
|
|
// g.OwnedKBOrAdmin(): only the KB creator or tenant Admin+ may mutate
|
|
|
|
|
|
// shares. Org-admins on a shared KB do NOT pass this guard, so they
|
|
|
|
|
|
// would only see 403s if we let them try. Mirror the matrix here so
|
|
|
|
|
|
// the buttons disappear instead of failing.
|
|
|
|
|
|
const canShareKB = computed(() => {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (!activeKbId.value) return false
|
2026-05-15 09:56:58 +00:00
|
|
|
|
const userId = authStore.user?.id || ''
|
|
|
|
|
|
if (kbCreatorId.value && userId && kbCreatorId.value === userId) return true
|
|
|
|
|
|
return authStore.hasRole('admin')
|
|
|
|
|
|
})
|
2026-07-22 11:15:27 +00:00
|
|
|
|
|
|
|
|
|
|
const isKbOwner = computed(() => {
|
|
|
|
|
|
const userId = authStore.user?.id || ''
|
|
|
|
|
|
return Boolean(kbCreatorId.value && userId && kbCreatorId.value === userId)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const canViewActivity = computed(() => {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (editorMode.value !== 'edit' || !activeKbId.value) return false
|
2026-07-22 11:15:27 +00:00
|
|
|
|
if (Number(kbTenantId.value || 0) !== Number(authStore.currentTenantId || 0)) return false
|
|
|
|
|
|
return isKbOwner.value || authStore.hasRole('admin')
|
|
|
|
|
|
})
|
2026-04-23 03:21:28 +00:00
|
|
|
|
// 用户是否在分块设置中手动改过任何值。一旦为 true,就不再根据索引策略自动调整默认分块参数。
|
|
|
|
|
|
const chunkingDirty = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
// 仅 Wiki 索引模式下的分块预设:更大 chunk、无 overlap、关闭父子分块。
|
|
|
|
|
|
// 该预设只在「创建模式」下、且用户尚未手动调整分块参数时生效,避免覆盖既有 KB 的配置。
|
|
|
|
|
|
const WIKI_ONLY_CHUNKING_PRESET = {
|
|
|
|
|
|
chunkSize: 2048,
|
|
|
|
|
|
chunkOverlap: 0,
|
|
|
|
|
|
enableParentChild: false,
|
|
|
|
|
|
} as const
|
|
|
|
|
|
|
docs(chunking): align overlap default + sharpen UI/source/repo docs
Three documentation passes around the adaptive chunking work:
UI
- Frontend ChunkOverlap default consolidated to 80 (was 100), matching
chunker.DefaultChunkOverlap on the backend. Both DEFAULT_CHUNKING_PRESET
and initFormData updated. The KB-load fallback also uses 80 when a
loaded KB has no chunk_overlap stored.
- All four locales (en-US, zh-CN, ko-KR, ru-RU) get rewritten chunking
setting descriptions: each now states the validated range, the default,
and the situations where you'd deviate (FAQ vs narrative, embedder
token limits, language-specific corpora).
Source code
- splitter.go: DefaultChunkSize / DefaultChunkOverlap constants get a
longer block-comment explaining the per-language token math and the
use-case sweet spots, plus the migration note on what the old
inconsistent defaults were.
- KBChunkingSettings.vue: new comment block above ChunkingConfig
documents the slider min/max for each setting, why those bounds
exist, and the recommended TokenLimit values per embedding model.
Repo docs
- New docs/CHUNKING.md: end-to-end guide covering why chunking matters,
the adaptive 3-tier architecture, per-setting reference with ranges
and sweet spots, parent-child explanation, the token-limit table per
embedder (OpenAI / Voyage / Cohere / BGE / MiniLM / Jina), 7 use-case
presets, the debug panel workflow, the API surface, and known
trade-offs (recursive strategy hidden from UI, no auto-reindex on
strategy switch, OCR limitations).
- CHANGELOG.md gets a new [Unreleased] section consolidating all the
adaptive-chunking work shipped on this branch: 5 features, 8
improvements, 6 fixes, 1 docs entry. The entry references
docs/CHUNKING.md for deeper explanation.
https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-03 11:57:03 +00:00
|
|
|
|
// Non-Wiki-only fallback. Mirrors chunker.DefaultChunkSize and
|
|
|
|
|
|
// DefaultChunkOverlap on the backend so a freshly created KB uses
|
|
|
|
|
|
// the same numbers whether the editor sets them or the splitter
|
|
|
|
|
|
// falls back to its package defaults.
|
2026-04-23 03:21:28 +00:00
|
|
|
|
const DEFAULT_CHUNKING_PRESET = {
|
|
|
|
|
|
chunkSize: 512,
|
docs(chunking): align overlap default + sharpen UI/source/repo docs
Three documentation passes around the adaptive chunking work:
UI
- Frontend ChunkOverlap default consolidated to 80 (was 100), matching
chunker.DefaultChunkOverlap on the backend. Both DEFAULT_CHUNKING_PRESET
and initFormData updated. The KB-load fallback also uses 80 when a
loaded KB has no chunk_overlap stored.
- All four locales (en-US, zh-CN, ko-KR, ru-RU) get rewritten chunking
setting descriptions: each now states the validated range, the default,
and the situations where you'd deviate (FAQ vs narrative, embedder
token limits, language-specific corpora).
Source code
- splitter.go: DefaultChunkSize / DefaultChunkOverlap constants get a
longer block-comment explaining the per-language token math and the
use-case sweet spots, plus the migration note on what the old
inconsistent defaults were.
- KBChunkingSettings.vue: new comment block above ChunkingConfig
documents the slider min/max for each setting, why those bounds
exist, and the recommended TokenLimit values per embedding model.
Repo docs
- New docs/CHUNKING.md: end-to-end guide covering why chunking matters,
the adaptive 3-tier architecture, per-setting reference with ranges
and sweet spots, parent-child explanation, the token-limit table per
embedder (OpenAI / Voyage / Cohere / BGE / MiniLM / Jina), 7 use-case
presets, the debug panel workflow, the API surface, and known
trade-offs (recursive strategy hidden from UI, no auto-reindex on
strategy switch, OCR limitations).
- CHANGELOG.md gets a new [Unreleased] section consolidating all the
adaptive-chunking work shipped on this branch: 5 features, 8
improvements, 6 fixes, 1 docs entry. The entry references
docs/CHUNKING.md for deeper explanation.
https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-03 11:57:03 +00:00
|
|
|
|
chunkOverlap: 80,
|
2026-04-23 03:21:28 +00:00
|
|
|
|
enableParentChild: true,
|
|
|
|
|
|
} as const
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
const navItems = computed(() => {
|
2026-03-30 05:32:39 +00:00
|
|
|
|
const items: { key: string; icon: string; label: string; badge?: number }[] = [
|
2025-11-14 17:30:17 +00:00
|
|
|
|
{ key: 'basic', icon: 'info-circle', label: t('knowledgeEditor.sidebar.basic') },
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
{ 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') }
|
2025-11-14 17:30:17 +00:00
|
|
|
|
]
|
|
|
|
|
|
if (formData.value?.type === 'faq') {
|
|
|
|
|
|
items.push({ key: 'faq', icon: 'help-circle', label: t('knowledgeEditor.sidebar.faq') })
|
|
|
|
|
|
} else {
|
|
|
|
|
|
items.push(
|
2026-03-05 14:42:36 +00:00
|
|
|
|
{ key: 'parser', icon: 'file-search', label: t('settings.parserEngine') },
|
2026-04-02 12:53:44 +00:00
|
|
|
|
{ key: 'multimodal', icon: 'image', label: t('knowledgeEditor.sidebar.multimodal') },
|
|
|
|
|
|
{ key: 'asr', icon: 'sound', label: t('knowledgeEditor.sidebar.asr') },
|
2026-02-28 05:22:07 +00:00
|
|
|
|
{ key: 'storage', icon: 'cloud', label: t('knowledgeEditor.sidebar.storage') },
|
2025-11-14 17:30:17 +00:00
|
|
|
|
{ key: 'chunking', icon: 'file-copy', label: t('knowledgeEditor.sidebar.chunking') },
|
2025-11-25 08:44:44 +00:00
|
|
|
|
{ key: 'graph', icon: 'chart-bubble', label: t('knowledgeEditor.sidebar.graph') },
|
2025-11-14 17:30:17 +00:00
|
|
|
|
{ key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
|
|
|
|
|
|
)
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (editorMode.value === 'edit' && activeKbId.value) {
|
2026-03-30 05:32:39 +00:00
|
|
|
|
items.push({ key: 'datasource', icon: 'cloud-download', label: t('knowledgeEditor.sidebar.datasource'), badge: dsCount.value || undefined })
|
2026-03-27 07:02:40 +00:00
|
|
|
|
}
|
2025-11-14 17:30:17 +00:00
|
|
|
|
}
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (editorMode.value === 'edit' && activeKbId.value && !authStore.isLiteMode) {
|
2026-01-30 08:28:01 +00:00
|
|
|
|
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') })
|
|
|
|
|
|
}
|
2026-07-22 11:15:27 +00:00
|
|
|
|
if (canViewActivity.value) {
|
|
|
|
|
|
items.push({ key: 'activity', icon: 'history', label: t('knowledgeEditor.sidebar.activity') })
|
|
|
|
|
|
}
|
2025-11-14 17:30:17 +00:00
|
|
|
|
return items
|
|
|
|
|
|
})
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
2026-06-12 14:40:18 +00:00
|
|
|
|
// 左侧导航分组(与 AgentEditorModal 对齐)
|
|
|
|
|
|
const navGroups = computed(() => {
|
|
|
|
|
|
const itemMap = new Map(navItems.value.map((item) => [item.key, item]))
|
|
|
|
|
|
const pickItems = (keys: string[]) =>
|
|
|
|
|
|
keys.map((key) => itemMap.get(key)).filter(Boolean) as typeof navItems.value
|
|
|
|
|
|
return [
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'basic',
|
|
|
|
|
|
label: t('knowledgeEditor.navGroups.basic'),
|
|
|
|
|
|
items: pickItems(['basic', 'models', 'vectorStore', 'faq']),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'processing',
|
|
|
|
|
|
label: t('knowledgeEditor.navGroups.processing'),
|
|
|
|
|
|
items: pickItems(['parser', 'chunking', 'multimodal', 'asr', 'graph', 'advanced']),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'data',
|
|
|
|
|
|
label: t('knowledgeEditor.navGroups.data'),
|
|
|
|
|
|
items: pickItems(['storage', 'datasource']),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'integration',
|
|
|
|
|
|
label: t('knowledgeEditor.navGroups.integration'),
|
|
|
|
|
|
items: pickItems(['share']),
|
|
|
|
|
|
},
|
2026-07-22 11:15:27 +00:00
|
|
|
|
{
|
|
|
|
|
|
key: 'management',
|
|
|
|
|
|
label: t('knowledgeEditor.navGroups.management'),
|
|
|
|
|
|
items: pickItems(['activity']),
|
|
|
|
|
|
},
|
2026-06-12 14:40:18 +00:00
|
|
|
|
].filter((group) => group.items.length > 0)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
// 模型配置引用
|
|
|
|
|
|
const modelConfigRef = ref<InstanceType<typeof KBModelConfig>>()
|
|
|
|
|
|
const advancedSettingsRef = ref<InstanceType<typeof KBAdvancedSettings>>()
|
|
|
|
|
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
|
|
const formData = ref<any>(null)
|
2025-11-14 17:30:17 +00:00
|
|
|
|
const isFAQ = computed(() => formData.value?.type === 'faq')
|
|
|
|
|
|
|
2026-06-03 06:41:12 +00:00
|
|
|
|
const kbCreateNeedsEmbedding = computed(() => {
|
|
|
|
|
|
if (!formData.value || formData.value.type === 'faq') return false
|
|
|
|
|
|
const s = formData.value.indexingStrategy
|
|
|
|
|
|
return Boolean(s?.vectorEnabled || s?.keywordEnabled)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const applyDefaultModelsIfEmpty = () => {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (!formData.value || editorMode.value !== 'create') return
|
2026-08-10 02:55:36 +00:00
|
|
|
|
const chatModelId = selectInitialModelId(allModels.value, 'KnowledgeQA')
|
|
|
|
|
|
const embeddingModelId = selectInitialModelId(allModels.value, 'Embedding')
|
|
|
|
|
|
if (!formData.value.modelConfig.llmModelId && chatModelId) {
|
|
|
|
|
|
formData.value.modelConfig.llmModelId = chatModelId
|
2026-06-03 06:41:12 +00:00
|
|
|
|
}
|
2026-08-10 02:55:36 +00:00
|
|
|
|
if (!formData.value.modelConfig.embeddingModelId && embeddingModelId) {
|
|
|
|
|
|
formData.value.modelConfig.embeddingModelId = embeddingModelId
|
2026-06-03 06:41:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
watch(
|
|
|
|
|
|
() => formData.value?.type,
|
|
|
|
|
|
(newType, oldType) => {
|
|
|
|
|
|
if (!formData.value) return
|
|
|
|
|
|
if (newType === 'faq') {
|
|
|
|
|
|
if (!formData.value.faqConfig) {
|
2025-11-16 15:35:54 +00:00
|
|
|
|
formData.value.faqConfig = { indexMode: 'question_only', questionIndexMode: 'separate' }
|
2025-11-14 17:30:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (!['basic', 'models', 'faq'].includes(currentSection.value)) {
|
|
|
|
|
|
currentSection.value = 'faq'
|
|
|
|
|
|
}
|
2026-04-07 11:36:06 +00:00
|
|
|
|
} else if (oldType === 'faq' && currentSection.value === 'faq') {
|
2025-11-14 17:30:17 +00:00
|
|
|
|
currentSection.value = 'basic'
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
// 初始化表单数据
|
2026-04-07 11:36:06 +00:00
|
|
|
|
const initFormData = (type: 'document' | 'faq' = 'document') => {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
return {
|
2025-11-14 17:30:17 +00:00
|
|
|
|
type,
|
2025-11-06 13:12:26 +00:00
|
|
|
|
name: '',
|
|
|
|
|
|
description: '',
|
2025-11-14 17:30:17 +00:00
|
|
|
|
faqConfig: {
|
2025-11-16 15:35:54 +00:00
|
|
|
|
indexMode: 'question_only',
|
|
|
|
|
|
questionIndexMode: 'separate'
|
2025-11-14 17:30:17 +00:00
|
|
|
|
},
|
2025-11-06 13:12:26 +00:00
|
|
|
|
modelConfig: {
|
|
|
|
|
|
llmModelId: '',
|
2026-04-20 11:16:46 +00:00
|
|
|
|
embeddingModelId: '',
|
|
|
|
|
|
wikiSynthesisModelId: '',
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
|
|
|
|
|
chunkingConfig: {
|
|
|
|
|
|
chunkSize: 512,
|
docs(chunking): align overlap default + sharpen UI/source/repo docs
Three documentation passes around the adaptive chunking work:
UI
- Frontend ChunkOverlap default consolidated to 80 (was 100), matching
chunker.DefaultChunkOverlap on the backend. Both DEFAULT_CHUNKING_PRESET
and initFormData updated. The KB-load fallback also uses 80 when a
loaded KB has no chunk_overlap stored.
- All four locales (en-US, zh-CN, ko-KR, ru-RU) get rewritten chunking
setting descriptions: each now states the validated range, the default,
and the situations where you'd deviate (FAQ vs narrative, embedder
token limits, language-specific corpora).
Source code
- splitter.go: DefaultChunkSize / DefaultChunkOverlap constants get a
longer block-comment explaining the per-language token math and the
use-case sweet spots, plus the migration note on what the old
inconsistent defaults were.
- KBChunkingSettings.vue: new comment block above ChunkingConfig
documents the slider min/max for each setting, why those bounds
exist, and the recommended TokenLimit values per embedding model.
Repo docs
- New docs/CHUNKING.md: end-to-end guide covering why chunking matters,
the adaptive 3-tier architecture, per-setting reference with ranges
and sweet spots, parent-child explanation, the token-limit table per
embedder (OpenAI / Voyage / Cohere / BGE / MiniLM / Jina), 7 use-case
presets, the debug panel workflow, the API surface, and known
trade-offs (recursive strategy hidden from UI, no auto-reindex on
strategy switch, OCR limitations).
- CHANGELOG.md gets a new [Unreleased] section consolidating all the
adaptive-chunking work shipped on this branch: 5 features, 8
improvements, 6 fixes, 1 docs entry. The entry references
docs/CHUNKING.md for deeper explanation.
https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-03 11:57:03 +00:00
|
|
|
|
// 80 ≈ 15% of chunkSize — community-recommended sweet spot.
|
|
|
|
|
|
// Aligned with chunker.DefaultChunkOverlap on the backend.
|
|
|
|
|
|
chunkOverlap: 80,
|
2026-02-28 05:22:07 +00:00
|
|
|
|
separators: ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
2026-03-04 12:35:10 +00:00
|
|
|
|
parserEngineRules: undefined as any,
|
2026-03-13 09:22:02 +00:00
|
|
|
|
enableParentChild: true,
|
2026-03-05 07:04:08 +00:00
|
|
|
|
parentChunkSize: 4096,
|
2026-05-02 20:40:07 +00:00
|
|
|
|
childChunkSize: 384,
|
|
|
|
|
|
// New KBs default to the adaptive auto-strategy. User can change in the UI.
|
|
|
|
|
|
strategy: 'auto' as string,
|
|
|
|
|
|
tokenLimit: 0,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
languages: [] as string[],
|
|
|
|
|
|
tableMetadataInstructions: ''
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
2026-07-15 05:26:29 +00:00
|
|
|
|
storageBackendId: '' as string,
|
2026-03-20 22:18:34 +00:00
|
|
|
|
storageProvider: '' as string,
|
2025-11-06 13:12:26 +00:00
|
|
|
|
multimodalConfig: {
|
|
|
|
|
|
enabled: false,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
vllmModelId: '',
|
|
|
|
|
|
descriptionLanguage: '',
|
|
|
|
|
|
customInstructions: ''
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
2026-04-02 08:43:37 +00:00
|
|
|
|
asrConfig: {
|
|
|
|
|
|
enabled: false,
|
|
|
|
|
|
modelId: '',
|
|
|
|
|
|
language: ''
|
|
|
|
|
|
},
|
2025-11-25 08:51:14 +00:00
|
|
|
|
nodeExtractConfig: {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
enabled: false,
|
|
|
|
|
|
text: '',
|
2025-11-20 12:08:24 +00:00
|
|
|
|
tags: [] as string[],
|
|
|
|
|
|
nodes: [] as Array<{
|
|
|
|
|
|
name: string
|
|
|
|
|
|
attributes: string[]
|
|
|
|
|
|
}>,
|
|
|
|
|
|
relations: [] as Array<{
|
|
|
|
|
|
node1: string
|
|
|
|
|
|
node2: string
|
|
|
|
|
|
type: string
|
2026-07-13 03:57:30 +00:00
|
|
|
|
}>,
|
|
|
|
|
|
customInstructions: ''
|
2025-11-25 08:44:44 +00:00
|
|
|
|
},
|
2025-12-02 17:42:31 +00:00
|
|
|
|
questionGenerationConfig: {
|
2026-03-13 09:22:02 +00:00
|
|
|
|
enabled: true,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
questionCount: 3,
|
|
|
|
|
|
customInstructions: ''
|
2025-12-02 17:42:31 +00:00
|
|
|
|
},
|
2026-08-05 13:56:58 +00:00
|
|
|
|
autoTagConfig: {
|
|
|
|
|
|
enabled: false,
|
|
|
|
|
|
modelId: '',
|
fix(knowledge): harden auto-tagging and let it respect manual tags
Automatic tagging shipped with a few paths that quietly disabled it and a
prompt that spent most of its budget on data the model never needed.
Robustness:
- Treat an omitted confidence as a deliberate selection instead of zero.
Models frequently drop the field, and the 0.75 floor then filtered out
every match, silently turning the feature off. Percentage-scale values
are rescaled rather than accepted as out-of-range certainty.
- Classify the first 500 tags when a knowledge base has more, logging a
warning, instead of dropping the task entirely. Large knowledge bases
previously got no auto-tagging at all with no user-visible signal.
- Reuse common.ParseLLMJsonResponse for the model reply, and give that
helper a balanced-scan fallback. The local extraction cut the payload at
the last "}" or "]", so a trailing citation such as "see [1]" produced
invalid JSON and burned the task's retries.
Prompt:
- Address candidates by ordinal rather than UUID. Tag names are short while
a UUID is 36 characters, so this cuts candidate tokens roughly tenfold,
keeps the model from having to reproduce (and corrupt) an id, and is what
makes the raised 500 ceiling affordable. Ordinals are range-checked and
mapped back to ids server-side.
- Drop the rationale field. Nothing read it, and at max_tags=10 it competed
with the 1024-token output budget and risked truncating the JSON.
- Fence document text in <document> so file content cannot be read as
instructions.
Behaviour:
- Add auto_tag_config.skip_if_tagged, defaulting to true, so documents the
user already tagged at upload time keep their classification. Existing
tags are now loaded before the model call, so a skipped document costs no
LLM round-trip. Configs stored without the field adopt the default.
Also promote AddKnowledgeTagRelations to KnowledgeRepository instead of
reaching for it through a type assertion that failed at runtime, and route
the max_tags bounds through AutoTagConfig.Normalize so the prompt, the match
filter and the persisted config cannot drift apart.
Adds handler-level coverage for scope, cancellation, idempotency, ordinal
validation and the new toggle, plus SDK, Swagger and API doc updates.
2026-08-07 07:32:16 +00:00
|
|
|
|
maxTags: 3,
|
|
|
|
|
|
skipIfTagged: true
|
2026-08-05 13:56:58 +00:00
|
|
|
|
},
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
wikiConfig: {
|
|
|
|
|
|
synthesisModelId: '',
|
|
|
|
|
|
maxPagesPerIngest: 0,
|
2026-04-22 12:27:19 +00:00
|
|
|
|
extractionGranularity: 'standard' as 'focused' | 'standard' | 'exhaustive',
|
2026-07-13 03:57:30 +00:00
|
|
|
|
contentInstructions: '',
|
|
|
|
|
|
extractionInstructions: '',
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
},
|
2026-04-20 11:16:46 +00:00
|
|
|
|
indexingStrategy: {
|
|
|
|
|
|
vectorEnabled: true,
|
|
|
|
|
|
keywordEnabled: true,
|
|
|
|
|
|
wikiEnabled: false,
|
|
|
|
|
|
graphEnabled: false,
|
|
|
|
|
|
},
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
// 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,
|
|
|
|
|
|
},
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 加载所有模型
|
2026-06-08 12:55:54 +00:00
|
|
|
|
const loadAllModels = async (force = false) => {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
try {
|
2026-06-08 12:55:54 +00:00
|
|
|
|
await chatResources.ensureModels(force)
|
|
|
|
|
|
allModels.value = chatResources.allModels || []
|
2025-11-06 13:12:26 +00:00
|
|
|
|
} catch (error) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
console.error('Failed to load model list:', error)
|
|
|
|
|
|
MessagePlugin.error(t('knowledgeEditor.messages.loadModelsFailed'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
allModels.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-02 09:20:37 +00:00
|
|
|
|
let kbEditorLoadGeneration = 0
|
|
|
|
|
|
|
|
|
|
|
|
const isCurrentKBLoad = (generation: number, kbId: string) => (
|
|
|
|
|
|
generation === kbEditorLoadGeneration
|
|
|
|
|
|
&& props.visible
|
|
|
|
|
|
&& activeKbId.value === kbId
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
// 加载知识库数据(编辑模式)
|
2026-09-02 09:20:37 +00:00
|
|
|
|
const loadKBData = async (
|
|
|
|
|
|
kbIdOverride?: string,
|
|
|
|
|
|
generation = kbEditorLoadGeneration,
|
|
|
|
|
|
) => {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
const kbId = kbIdOverride ?? activeKbId.value
|
|
|
|
|
|
if (editorMode.value !== 'edit' || !kbId) return
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
try {
|
2026-06-08 12:55:54 +00:00
|
|
|
|
const [kbInfo, filesResult] = await Promise.all([
|
2026-07-31 03:42:09 +00:00
|
|
|
|
getKnowledgeBaseById(kbId),
|
|
|
|
|
|
listKnowledgeFiles(kbId, { page: 1, page_size: 1 })
|
2025-11-06 13:12:26 +00:00
|
|
|
|
])
|
2026-09-02 09:20:37 +00:00
|
|
|
|
|
|
|
|
|
|
if (!isCurrentKBLoad(generation, kbId)) return
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
if (!kbInfo || !kbInfo.data) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
throw new Error(t('knowledgeEditor.messages.notFound'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const kb = kbInfo.data
|
|
|
|
|
|
hasFiles.value = (filesResult as any)?.total > 0
|
2026-05-15 09:56:58 +00:00
|
|
|
|
kbCreatorId.value = (kb as any).creator_id || ''
|
2026-07-22 11:15:27 +00:00
|
|
|
|
kbTenantId.value = Number((kb as any).tenant_id || 0)
|
2026-05-15 09:56:58 +00:00
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
// 设置表单数据
|
2026-04-07 11:36:06 +00:00
|
|
|
|
const kbType = (kb.type as 'document' | 'faq') || 'document'
|
2025-11-06 13:12:26 +00:00
|
|
|
|
formData.value = {
|
2025-11-14 17:30:17 +00:00
|
|
|
|
type: kbType,
|
2025-11-06 13:12:26 +00:00
|
|
|
|
name: kb.name || '',
|
|
|
|
|
|
description: kb.description || '',
|
2025-11-14 17:30:17 +00:00
|
|
|
|
faqConfig: {
|
2025-11-16 15:35:54 +00:00
|
|
|
|
indexMode: kb.faq_config?.index_mode || 'question_only',
|
|
|
|
|
|
questionIndexMode: kb.faq_config?.question_index_mode || 'separate'
|
2025-11-14 17:30:17 +00:00
|
|
|
|
},
|
2025-11-06 13:12:26 +00:00
|
|
|
|
modelConfig: {
|
|
|
|
|
|
llmModelId: kb.summary_model_id || '',
|
2026-04-20 11:16:46 +00:00
|
|
|
|
embeddingModelId: kb.embedding_model_id || '',
|
|
|
|
|
|
wikiSynthesisModelId: kb.wiki_config?.synthesis_model_id || ''
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
|
|
|
|
|
chunkingConfig: {
|
|
|
|
|
|
chunkSize: kb.chunking_config?.chunk_size || 512,
|
docs(chunking): align overlap default + sharpen UI/source/repo docs
Three documentation passes around the adaptive chunking work:
UI
- Frontend ChunkOverlap default consolidated to 80 (was 100), matching
chunker.DefaultChunkOverlap on the backend. Both DEFAULT_CHUNKING_PRESET
and initFormData updated. The KB-load fallback also uses 80 when a
loaded KB has no chunk_overlap stored.
- All four locales (en-US, zh-CN, ko-KR, ru-RU) get rewritten chunking
setting descriptions: each now states the validated range, the default,
and the situations where you'd deviate (FAQ vs narrative, embedder
token limits, language-specific corpora).
Source code
- splitter.go: DefaultChunkSize / DefaultChunkOverlap constants get a
longer block-comment explaining the per-language token math and the
use-case sweet spots, plus the migration note on what the old
inconsistent defaults were.
- KBChunkingSettings.vue: new comment block above ChunkingConfig
documents the slider min/max for each setting, why those bounds
exist, and the recommended TokenLimit values per embedding model.
Repo docs
- New docs/CHUNKING.md: end-to-end guide covering why chunking matters,
the adaptive 3-tier architecture, per-setting reference with ranges
and sweet spots, parent-child explanation, the token-limit table per
embedder (OpenAI / Voyage / Cohere / BGE / MiniLM / Jina), 7 use-case
presets, the debug panel workflow, the API surface, and known
trade-offs (recursive strategy hidden from UI, no auto-reindex on
strategy switch, OCR limitations).
- CHANGELOG.md gets a new [Unreleased] section consolidating all the
adaptive-chunking work shipped on this branch: 5 features, 8
improvements, 6 fixes, 1 docs entry. The entry references
docs/CHUNKING.md for deeper explanation.
https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-03 11:57:03 +00:00
|
|
|
|
// Fallback only used when the loaded KB has no chunk_overlap stored.
|
|
|
|
|
|
// Aligned with chunker.DefaultChunkOverlap on the backend.
|
|
|
|
|
|
chunkOverlap: kb.chunking_config?.chunk_overlap || 80,
|
2026-02-28 05:22:07 +00:00
|
|
|
|
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';'],
|
2026-03-04 12:35:10 +00:00
|
|
|
|
parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined,
|
|
|
|
|
|
enableParentChild: kb.chunking_config?.enable_parent_child || false,
|
2026-03-05 07:04:08 +00:00
|
|
|
|
parentChunkSize: kb.chunking_config?.parent_chunk_size || 4096,
|
2026-05-02 20:40:07 +00:00
|
|
|
|
childChunkSize: kb.chunking_config?.child_chunk_size || 384,
|
|
|
|
|
|
// Existing KBs without strategy field render as empty (= legacy behavior).
|
|
|
|
|
|
// The user has to actively pick a value to opt in to the new tiers.
|
|
|
|
|
|
strategy: kb.chunking_config?.strategy || '',
|
|
|
|
|
|
tokenLimit: kb.chunking_config?.token_limit || 0,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
languages: kb.chunking_config?.languages || [],
|
|
|
|
|
|
tableMetadataInstructions: kb.chunking_config?.table_metadata_instructions || ''
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
2026-07-15 05:26:29 +00:00
|
|
|
|
storageBackendId: (kb.storage_backend_id || '') as string,
|
fix(frontend): use storage_provider_config instead of legacy storage_config
The backend introduced storage_provider_config as the authoritative
field in commit dbab7b0, but the frontend was never updated to use it.
This caused the UI to always display "local" regardless of the actual
storage provider, and saving KB settings could overwrite the correct
storage_provider_config with an incorrect value.
Changes:
- KnowledgeBaseEditorModal.vue: read from storage_provider_config with
storage_config fallback, dual-write both fields on save
- KnowledgeBaseList.vue: update feature badge logic and add type def
for storage_provider_config, exclude "local" from badge display
- api/knowledge-base/index.ts: add storage_provider_config to API type
- ko-KR.ts, ru-RU.ts: add missing i18n keys — multimodal section
(sidebar.multimodal, multimodal.title/description), channel labels
(channelLabel, channelWeb, channelApi, etc.), and agent.think
2026-04-01 07:37:13 +00:00
|
|
|
|
storageProvider: (kb.storage_provider_config?.provider || kb.storage_config?.provider || 'local') as string,
|
2025-11-06 13:12:26 +00:00
|
|
|
|
multimodalConfig: {
|
2026-02-28 05:22:07 +00:00
|
|
|
|
enabled: !!kb.vlm_config?.enabled,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
vllmModelId: kb.vlm_config?.model_id || '',
|
|
|
|
|
|
descriptionLanguage: kb.vlm_config?.description_language || '',
|
|
|
|
|
|
customInstructions: kb.vlm_config?.custom_instructions || ''
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
2026-04-02 08:43:37 +00:00
|
|
|
|
asrConfig: {
|
|
|
|
|
|
enabled: !!kb.asr_config?.enabled,
|
|
|
|
|
|
modelId: kb.asr_config?.model_id || '',
|
|
|
|
|
|
language: kb.asr_config?.language || ''
|
|
|
|
|
|
},
|
2025-11-25 08:51:14 +00:00
|
|
|
|
nodeExtractConfig: {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
enabled: kb.extract_config?.enabled || false,
|
|
|
|
|
|
text: kb.extract_config?.text || '',
|
2025-11-20 12:08:24 +00:00
|
|
|
|
tags: kb.extract_config?.tags || [],
|
2025-11-25 08:44:44 +00:00
|
|
|
|
nodes: (kb.extract_config?.nodes || []).map((node: any) => ({
|
|
|
|
|
|
name: node.name,
|
|
|
|
|
|
attributes: node.attributes || []
|
|
|
|
|
|
})),
|
2026-07-13 03:57:30 +00:00
|
|
|
|
relations: kb.extract_config?.relations || [],
|
|
|
|
|
|
customInstructions: kb.extract_config?.custom_instructions || ''
|
2025-11-25 08:44:44 +00:00
|
|
|
|
},
|
2025-12-02 17:42:31 +00:00
|
|
|
|
questionGenerationConfig: {
|
|
|
|
|
|
enabled: kb.question_generation_config?.enabled || false,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
questionCount: kb.question_generation_config?.question_count || 3,
|
|
|
|
|
|
customInstructions: kb.question_generation_config?.custom_instructions || ''
|
2025-12-02 17:42:31 +00:00
|
|
|
|
},
|
2026-08-05 13:56:58 +00:00
|
|
|
|
autoTagConfig: {
|
|
|
|
|
|
enabled: kb.auto_tag_config?.enabled || false,
|
|
|
|
|
|
modelId: kb.auto_tag_config?.model_id || '',
|
fix(knowledge): harden auto-tagging and let it respect manual tags
Automatic tagging shipped with a few paths that quietly disabled it and a
prompt that spent most of its budget on data the model never needed.
Robustness:
- Treat an omitted confidence as a deliberate selection instead of zero.
Models frequently drop the field, and the 0.75 floor then filtered out
every match, silently turning the feature off. Percentage-scale values
are rescaled rather than accepted as out-of-range certainty.
- Classify the first 500 tags when a knowledge base has more, logging a
warning, instead of dropping the task entirely. Large knowledge bases
previously got no auto-tagging at all with no user-visible signal.
- Reuse common.ParseLLMJsonResponse for the model reply, and give that
helper a balanced-scan fallback. The local extraction cut the payload at
the last "}" or "]", so a trailing citation such as "see [1]" produced
invalid JSON and burned the task's retries.
Prompt:
- Address candidates by ordinal rather than UUID. Tag names are short while
a UUID is 36 characters, so this cuts candidate tokens roughly tenfold,
keeps the model from having to reproduce (and corrupt) an id, and is what
makes the raised 500 ceiling affordable. Ordinals are range-checked and
mapped back to ids server-side.
- Drop the rationale field. Nothing read it, and at max_tags=10 it competed
with the 1024-token output budget and risked truncating the JSON.
- Fence document text in <document> so file content cannot be read as
instructions.
Behaviour:
- Add auto_tag_config.skip_if_tagged, defaulting to true, so documents the
user already tagged at upload time keep their classification. Existing
tags are now loaded before the model call, so a skipped document costs no
LLM round-trip. Configs stored without the field adopt the default.
Also promote AddKnowledgeTagRelations to KnowledgeRepository instead of
reaching for it through a type assertion that failed at runtime, and route
the max_tags bounds through AutoTagConfig.Normalize so the prompt, the match
filter and the persisted config cannot drift apart.
Adds handler-level coverage for scope, cancellation, idempotency, ordinal
validation and the new toggle, plus SDK, Swagger and API doc updates.
2026-08-07 07:32:16 +00:00
|
|
|
|
maxTags: kb.auto_tag_config?.max_tags || 3,
|
|
|
|
|
|
// Absent on knowledge bases saved before the toggle existed; the
|
|
|
|
|
|
// backend treats that as "skip", so mirror it here.
|
|
|
|
|
|
skipIfTagged: kb.auto_tag_config?.skip_if_tagged ?? true
|
2026-08-05 13:56:58 +00:00
|
|
|
|
},
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
wikiConfig: {
|
|
|
|
|
|
synthesisModelId: kb.wiki_config?.synthesis_model_id || '',
|
|
|
|
|
|
maxPagesPerIngest: kb.wiki_config?.max_pages_per_ingest || 0,
|
2026-04-22 12:27:19 +00:00
|
|
|
|
extractionGranularity: (
|
|
|
|
|
|
kb.wiki_config?.extraction_granularity === 'focused' ||
|
|
|
|
|
|
kb.wiki_config?.extraction_granularity === 'exhaustive'
|
|
|
|
|
|
? kb.wiki_config.extraction_granularity
|
|
|
|
|
|
: 'standard'
|
|
|
|
|
|
) as 'focused' | 'standard' | 'exhaustive',
|
2026-07-13 03:57:30 +00:00
|
|
|
|
contentInstructions: kb.wiki_config?.content_instructions || '',
|
|
|
|
|
|
extractionInstructions: kb.wiki_config?.extraction_instructions || '',
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
},
|
2026-04-20 11:16:46 +00:00
|
|
|
|
indexingStrategy: {
|
|
|
|
|
|
vectorEnabled: kb.indexing_strategy?.vector_enabled ?? true,
|
|
|
|
|
|
keywordEnabled: kb.indexing_strategy?.keyword_enabled ?? true,
|
|
|
|
|
|
wikiEnabled: kb.indexing_strategy?.wiki_enabled ?? false,
|
|
|
|
|
|
graphEnabled: kb.indexing_strategy?.graph_enabled ?? false,
|
|
|
|
|
|
},
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
// 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,
|
|
|
|
|
|
},
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
2026-03-09 12:27:24 +00:00
|
|
|
|
initialStorageProvider.value = formData.value.storageProvider
|
2026-04-20 11:16:46 +00:00
|
|
|
|
initialIndexingStrategy.value = { ...formData.value.indexingStrategy }
|
2025-11-06 13:12:26 +00:00
|
|
|
|
} catch (error) {
|
2026-09-02 09:20:37 +00:00
|
|
|
|
if (!isCurrentKBLoad(generation, kbId)) return
|
2025-11-13 11:34:33 +00:00
|
|
|
|
console.error('Failed to load knowledge base data:', error)
|
|
|
|
|
|
MessagePlugin.error(t('knowledgeEditor.messages.loadDataFailed'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
handleClose()
|
|
|
|
|
|
} finally {
|
2026-09-02 09:20:37 +00:00
|
|
|
|
if (isCurrentKBLoad(generation, kbId)) {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理配置更新
|
|
|
|
|
|
const handleModelConfigUpdate = (config: any) => {
|
|
|
|
|
|
if (formData.value) {
|
|
|
|
|
|
formData.value.modelConfig = { ...config }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-22 12:27:19 +00:00
|
|
|
|
// 粒度选择器:从 formData.wikiConfig 读出并规范化,未知值回退到 'standard',
|
|
|
|
|
|
// 与后端 WikiExtractionGranularity.Normalize() 的契约保持一致。
|
|
|
|
|
|
const resolvedGranularity = computed<'focused' | 'standard' | 'exhaustive'>(() => {
|
|
|
|
|
|
const g = formData.value?.wikiConfig?.extractionGranularity
|
|
|
|
|
|
if (g === 'focused' || g === 'standard' || g === 'exhaustive') {
|
|
|
|
|
|
return g
|
|
|
|
|
|
}
|
|
|
|
|
|
return 'standard'
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const granularityHint = computed<string>(() => {
|
|
|
|
|
|
switch (resolvedGranularity.value) {
|
|
|
|
|
|
case 'focused':
|
|
|
|
|
|
return t('knowledgeEditor.wiki.granularityFocusedHint')
|
|
|
|
|
|
case 'exhaustive':
|
|
|
|
|
|
return t('knowledgeEditor.wiki.granularityExhaustiveHint')
|
|
|
|
|
|
default:
|
|
|
|
|
|
return t('knowledgeEditor.wiki.granularityStandardHint')
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const handleGranularityChange = (value: string | number | boolean) => {
|
|
|
|
|
|
if (!formData.value) return
|
|
|
|
|
|
const next: 'focused' | 'standard' | 'exhaustive' =
|
|
|
|
|
|
value === 'focused' || value === 'exhaustive'
|
|
|
|
|
|
? (value as 'focused' | 'exhaustive')
|
|
|
|
|
|
: 'standard'
|
|
|
|
|
|
formData.value.wikiConfig = {
|
|
|
|
|
|
...formData.value.wikiConfig,
|
|
|
|
|
|
extractionGranularity: next,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-31 03:42:09 +00:00
|
|
|
|
const isIndexingLocked = computed(() => editorMode.value === 'edit' && hasFiles.value)
|
2026-04-21 06:46:41 +00:00
|
|
|
|
|
2026-04-20 13:54:54 +00:00
|
|
|
|
const toggleVectorIndexing = () => {
|
|
|
|
|
|
if (!formData.value) return
|
2026-04-21 06:46:41 +00:00
|
|
|
|
if (isIndexingLocked.value) return
|
2026-04-20 13:54:54 +00:00
|
|
|
|
const next = !formData.value.indexingStrategy.vectorEnabled
|
|
|
|
|
|
formData.value.indexingStrategy.vectorEnabled = next
|
|
|
|
|
|
formData.value.indexingStrategy.keywordEnabled = next
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-21 06:46:41 +00:00
|
|
|
|
const toggleWikiIndexing = () => {
|
|
|
|
|
|
if (!formData.value) return
|
|
|
|
|
|
if (isIndexingLocked.value) return
|
|
|
|
|
|
formData.value.indexingStrategy.wikiEnabled = !formData.value.indexingStrategy.wikiEnabled
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
const handleChunkingConfigUpdate = (config: any) => {
|
|
|
|
|
|
if (formData.value) {
|
|
|
|
|
|
formData.value.chunkingConfig = { ...config }
|
2026-04-23 03:21:28 +00:00
|
|
|
|
// 用户已经手动触达分块设置,后续索引策略切换不再覆盖这些值
|
|
|
|
|
|
chunkingDirty.value = true
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-23 03:21:28 +00:00
|
|
|
|
// 判断当前是否为「仅 Wiki 索引」:只开了 Wiki,关了向量/关键词检索
|
|
|
|
|
|
const isWikiOnlyStrategy = computed(() => {
|
|
|
|
|
|
const s = formData.value?.indexingStrategy
|
|
|
|
|
|
if (!s) return false
|
|
|
|
|
|
return !!s.wikiEnabled && !s.vectorEnabled && !s.keywordEnabled
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 仅在创建模式、用户未改过分块设置时,随索引策略自动应用/撤销 Wiki-only 预设。
|
|
|
|
|
|
// 编辑模式严格保持后端已有配置不变,避免误改。
|
|
|
|
|
|
watch(isWikiOnlyStrategy, (wikiOnly) => {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (editorMode.value !== 'create') return
|
2026-04-23 03:21:28 +00:00
|
|
|
|
if (!formData.value) return
|
|
|
|
|
|
if (chunkingDirty.value) return
|
|
|
|
|
|
const preset = wikiOnly ? WIKI_ONLY_CHUNKING_PRESET : DEFAULT_CHUNKING_PRESET
|
|
|
|
|
|
formData.value.chunkingConfig = {
|
|
|
|
|
|
...formData.value.chunkingConfig,
|
|
|
|
|
|
...preset,
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-02-28 05:22:07 +00:00
|
|
|
|
const handleParserEngineRulesUpdate = (rules: any[]) => {
|
|
|
|
|
|
if (formData.value) {
|
|
|
|
|
|
formData.value.chunkingConfig.parserEngineRules = rules?.length ? rules : undefined
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-11 13:16:23 +00:00
|
|
|
|
const handleMultimodalToggle = () => {
|
|
|
|
|
|
if (formData.value && !formData.value.multimodalConfig.enabled) {
|
|
|
|
|
|
formData.value.multimodalConfig.vllmModelId = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleMultimodalVLLMChange = (modelId: string) => {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
if (formData.value) {
|
2026-03-11 13:16:23 +00:00
|
|
|
|
formData.value.multimodalConfig.vllmModelId = modelId
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-11 13:16:23 +00:00
|
|
|
|
const handleAddVLLMModel = () => {
|
|
|
|
|
|
uiStore.openSettings('models', 'vllm')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-03 04:14:33 +00:00
|
|
|
|
const handleAddASRModel = () => {
|
|
|
|
|
|
uiStore.openSettings('models', 'asr')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-07 11:36:06 +00:00
|
|
|
|
const handleAddWikiModel = () => {
|
|
|
|
|
|
uiStore.openSettings('models', 'knowledgeqa')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-28 05:22:07 +00:00
|
|
|
|
const handleStorageProviderUpdate = (value: string) => {
|
|
|
|
|
|
if (formData.value) {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
formData.value.storageProvider = editorMode.value === 'create'
|
2026-07-15 02:57:32 +00:00
|
|
|
|
? editorResources.resolveUsableStorageProvider(value || tenantDefaultStorageProvider.value)
|
2026-07-08 09:49:30 +00:00
|
|
|
|
: (value || tenantDefaultStorageProvider.value || 'local')
|
2026-02-28 05:22:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-15 05:26:29 +00:00
|
|
|
|
const handleStorageBackendUpdate = (value: string) => {
|
|
|
|
|
|
if (formData.value) {
|
|
|
|
|
|
formData.value.storageBackendId = value
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-08 12:55:54 +00:00
|
|
|
|
async function loadTenantDefaultStorageProvider(force = false) {
|
2026-05-29 05:36:06 +00:00
|
|
|
|
try {
|
2026-06-08 12:55:54 +00:00
|
|
|
|
await editorResources.ensureStorageEngine(force)
|
2026-07-15 02:57:32 +00:00
|
|
|
|
tenantDefaultStorageProvider.value = editorResources.resolveUsableStorageProvider(
|
|
|
|
|
|
editorResources.storageConfig?.default_provider,
|
|
|
|
|
|
)
|
2026-05-29 05:36:06 +00:00
|
|
|
|
} catch {
|
2026-07-15 02:57:32 +00:00
|
|
|
|
tenantDefaultStorageProvider.value = editorResources.resolveUsableStorageProvider()
|
2026-05-29 05:36:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Resolved storage provider for create payload (never silently default to local before tenant config loads). */
|
|
|
|
|
|
function resolvedStorageProvider(): string {
|
|
|
|
|
|
const explicit = formData.value?.storageProvider?.trim()
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (editorMode.value === 'create') {
|
2026-07-15 02:57:32 +00:00
|
|
|
|
return editorResources.resolveUsableStorageProvider(explicit || tenantDefaultStorageProvider.value)
|
2026-07-08 09:49:30 +00:00
|
|
|
|
}
|
2026-05-29 05:36:06 +00:00
|
|
|
|
if (explicit) return explicit
|
|
|
|
|
|
return tenantDefaultStorageProvider.value || 'local'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
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 || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-02 17:42:31 +00:00
|
|
|
|
const handleQuestionGenerationUpdate = (config: any) => {
|
|
|
|
|
|
if (formData.value) {
|
|
|
|
|
|
formData.value.questionGenerationConfig = { ...config }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
const handleNodeExtractUpdate = (config: any) => {
|
|
|
|
|
|
if (formData.value) {
|
2025-11-25 08:51:14 +00:00
|
|
|
|
formData.value.nodeExtractConfig = { ...config }
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 验证表单
|
|
|
|
|
|
const validateForm = (): boolean => {
|
|
|
|
|
|
if (!formData.value) return false
|
|
|
|
|
|
|
|
|
|
|
|
// 验证基本信息
|
|
|
|
|
|
if (!formData.value.name || !formData.value.name.trim()) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.warning(t('knowledgeEditor.messages.nameRequired'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
currentSection.value = 'basic'
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-20 11:16:46 +00:00
|
|
|
|
// 验证索引策略 — 文档类型至少需要开启一种
|
|
|
|
|
|
if (formData.value.type !== 'faq') {
|
|
|
|
|
|
const s = formData.value.indexingStrategy
|
|
|
|
|
|
if (s && !s.vectorEnabled && !s.keywordEnabled && !s.wikiEnabled && !s.graphEnabled) {
|
|
|
|
|
|
MessagePlugin.warning(t('knowledgeEditor.indexing.atLeastOne'))
|
|
|
|
|
|
currentSection.value = 'basic'
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 验证模型配置 - embedding 模型仅在检索索引启用时必须
|
|
|
|
|
|
const needsEmbedding = formData.value.indexingStrategy?.vectorEnabled || formData.value.indexingStrategy?.keywordEnabled
|
|
|
|
|
|
if (needsEmbedding && !formData.value.modelConfig.embeddingModelId) {
|
|
|
|
|
|
MessagePlugin.warning(t('knowledgeEditor.indexing.embeddingRequired'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
currentSection.value = 'models'
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!formData.value.modelConfig.llmModelId) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.warning(t('knowledgeEditor.messages.summaryRequired'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
currentSection.value = 'models'
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 验证多模态配置(如果启用)
|
2026-03-11 13:16:23 +00:00
|
|
|
|
if (formData.value.multimodalConfig.enabled && !formData.value.multimodalConfig.vllmModelId) {
|
|
|
|
|
|
MessagePlugin.warning(t('knowledgeEditor.messages.multimodalInvalid'))
|
|
|
|
|
|
currentSection.value = 'multimodal'
|
|
|
|
|
|
return false
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
if (formData.value.type === 'faq' && !formData.value.faqConfig?.indexMode) {
|
|
|
|
|
|
MessagePlugin.warning(t('knowledgeEditor.messages.indexModeRequired'))
|
|
|
|
|
|
currentSection.value = 'faq'
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 构建提交数据
|
|
|
|
|
|
const buildSubmitData = () => {
|
|
|
|
|
|
if (!formData.value) return null
|
|
|
|
|
|
|
|
|
|
|
|
const data: any = {
|
|
|
|
|
|
name: formData.value.name,
|
|
|
|
|
|
description: formData.value.description,
|
2025-11-14 17:30:17 +00:00
|
|
|
|
type: formData.value.type,
|
2025-11-06 13:12:26 +00:00
|
|
|
|
chunking_config: {
|
|
|
|
|
|
chunk_size: formData.value.chunkingConfig.chunkSize,
|
|
|
|
|
|
chunk_overlap: formData.value.chunkingConfig.chunkOverlap,
|
|
|
|
|
|
separators: formData.value.chunkingConfig.separators,
|
2026-03-04 12:35:10 +00:00
|
|
|
|
enable_parent_child: formData.value.chunkingConfig.enableParentChild,
|
|
|
|
|
|
parent_chunk_size: formData.value.chunkingConfig.parentChunkSize,
|
|
|
|
|
|
child_chunk_size: formData.value.chunkingConfig.childChunkSize,
|
2026-05-03 07:01:20 +00:00
|
|
|
|
// Adaptive chunking fields are always sent (empty/zero values
|
|
|
|
|
|
// included) so the user can clear them — backend uses pointer DTOs
|
|
|
|
|
|
// to distinguish "not in payload" from "explicitly empty".
|
|
|
|
|
|
strategy: formData.value.chunkingConfig.strategy ?? '',
|
|
|
|
|
|
token_limit: formData.value.chunkingConfig.tokenLimit ?? 0,
|
|
|
|
|
|
languages: formData.value.chunkingConfig.languages ?? [],
|
2026-07-13 03:57:30 +00:00
|
|
|
|
table_metadata_instructions: formData.value.chunkingConfig.tableMetadataInstructions || '',
|
2026-02-28 05:22:07 +00:00
|
|
|
|
...(formData.value.chunkingConfig.parserEngineRules?.length
|
|
|
|
|
|
? { parser_engine_rules: formData.value.chunkingConfig.parserEngineRules }
|
|
|
|
|
|
: {})
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
|
|
|
|
|
embedding_model_id: formData.value.modelConfig.embeddingModelId,
|
|
|
|
|
|
summary_model_id: formData.value.modelConfig.llmModelId
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
// 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
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
// 添加多模态配置
|
2025-11-20 12:08:24 +00:00
|
|
|
|
data.vlm_config = {
|
|
|
|
|
|
enabled: formData.value.multimodalConfig.enabled,
|
|
|
|
|
|
model_id: formData.value.multimodalConfig.enabled
|
|
|
|
|
|
? (formData.value.multimodalConfig.vllmModelId || '')
|
2026-07-13 03:57:30 +00:00
|
|
|
|
: '',
|
|
|
|
|
|
description_language: formData.value.multimodalConfig.descriptionLanguage || '',
|
|
|
|
|
|
custom_instructions: formData.value.multimodalConfig.customInstructions || ''
|
2025-11-20 12:08:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-02 08:43:37 +00:00
|
|
|
|
// 添加ASR语音识别配置
|
|
|
|
|
|
data.asr_config = {
|
|
|
|
|
|
enabled: formData.value.asrConfig?.enabled || false,
|
|
|
|
|
|
model_id: formData.value.asrConfig?.enabled
|
|
|
|
|
|
? (formData.value.asrConfig?.modelId || '')
|
|
|
|
|
|
: '',
|
|
|
|
|
|
language: formData.value.asrConfig?.language || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-15 05:26:29 +00:00
|
|
|
|
// storage_backend_id is authoritative. Keep provider projection for old clients
|
|
|
|
|
|
// and for rolling upgrades where a node has not picked up the new schema yet.
|
|
|
|
|
|
if (formData.value.storageBackendId) {
|
|
|
|
|
|
data.storage_backend_id = formData.value.storageBackendId
|
|
|
|
|
|
}
|
2026-05-29 05:36:06 +00:00
|
|
|
|
const storageProvider = resolvedStorageProvider()
|
fix(frontend): use storage_provider_config instead of legacy storage_config
The backend introduced storage_provider_config as the authoritative
field in commit dbab7b0, but the frontend was never updated to use it.
This caused the UI to always display "local" regardless of the actual
storage provider, and saving KB settings could overwrite the correct
storage_provider_config with an incorrect value.
Changes:
- KnowledgeBaseEditorModal.vue: read from storage_provider_config with
storage_config fallback, dual-write both fields on save
- KnowledgeBaseList.vue: update feature badge logic and add type def
for storage_provider_config, exclude "local" from badge display
- api/knowledge-base/index.ts: add storage_provider_config to API type
- ko-KR.ts, ru-RU.ts: add missing i18n keys — multimodal section
(sidebar.multimodal, multimodal.title/description), channel labels
(channelLabel, channelWeb, channelApi, etc.), and agent.think
2026-04-01 07:37:13 +00:00
|
|
|
|
data.storage_provider_config = {
|
2026-05-29 05:36:06 +00:00
|
|
|
|
provider: storageProvider
|
fix(frontend): use storage_provider_config instead of legacy storage_config
The backend introduced storage_provider_config as the authoritative
field in commit dbab7b0, but the frontend was never updated to use it.
This caused the UI to always display "local" regardless of the actual
storage provider, and saving KB settings could overwrite the correct
storage_provider_config with an incorrect value.
Changes:
- KnowledgeBaseEditorModal.vue: read from storage_provider_config with
storage_config fallback, dual-write both fields on save
- KnowledgeBaseList.vue: update feature badge logic and add type def
for storage_provider_config, exclude "local" from badge display
- api/knowledge-base/index.ts: add storage_provider_config to API type
- ko-KR.ts, ru-RU.ts: add missing i18n keys — multimodal section
(sidebar.multimodal, multimodal.title/description), channel labels
(channelLabel, channelWeb, channelApi, etc.), and agent.think
2026-04-01 07:37:13 +00:00
|
|
|
|
}
|
2026-02-28 09:39:59 +00:00
|
|
|
|
data.storage_config = {
|
2026-05-29 05:36:06 +00:00
|
|
|
|
provider: storageProvider
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-20 11:16:46 +00:00
|
|
|
|
// 添加知识图谱配置 — now synced via indexingStrategy.graphEnabled
|
|
|
|
|
|
// extract_config is sent below along with indexing_strategy
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
2025-12-02 17:42:31 +00:00
|
|
|
|
// 添加问题生成配置
|
|
|
|
|
|
if (formData.value.questionGenerationConfig?.enabled) {
|
|
|
|
|
|
data.question_generation_config = {
|
|
|
|
|
|
enabled: true,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
question_count: formData.value.questionGenerationConfig.questionCount || 3,
|
|
|
|
|
|
custom_instructions: formData.value.questionGenerationConfig.customInstructions || ''
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
data.question_generation_config = {
|
|
|
|
|
|
enabled: false,
|
|
|
|
|
|
question_count: 3,
|
|
|
|
|
|
custom_instructions: formData.value.questionGenerationConfig?.customInstructions || ''
|
2025-12-02 17:42:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-05 13:56:58 +00:00
|
|
|
|
data.auto_tag_config = {
|
|
|
|
|
|
enabled: formData.value.autoTagConfig?.enabled || false,
|
|
|
|
|
|
model_id: formData.value.autoTagConfig?.modelId || '',
|
fix(knowledge): harden auto-tagging and let it respect manual tags
Automatic tagging shipped with a few paths that quietly disabled it and a
prompt that spent most of its budget on data the model never needed.
Robustness:
- Treat an omitted confidence as a deliberate selection instead of zero.
Models frequently drop the field, and the 0.75 floor then filtered out
every match, silently turning the feature off. Percentage-scale values
are rescaled rather than accepted as out-of-range certainty.
- Classify the first 500 tags when a knowledge base has more, logging a
warning, instead of dropping the task entirely. Large knowledge bases
previously got no auto-tagging at all with no user-visible signal.
- Reuse common.ParseLLMJsonResponse for the model reply, and give that
helper a balanced-scan fallback. The local extraction cut the payload at
the last "}" or "]", so a trailing citation such as "see [1]" produced
invalid JSON and burned the task's retries.
Prompt:
- Address candidates by ordinal rather than UUID. Tag names are short while
a UUID is 36 characters, so this cuts candidate tokens roughly tenfold,
keeps the model from having to reproduce (and corrupt) an id, and is what
makes the raised 500 ceiling affordable. Ordinals are range-checked and
mapped back to ids server-side.
- Drop the rationale field. Nothing read it, and at max_tags=10 it competed
with the 1024-token output budget and risked truncating the JSON.
- Fence document text in <document> so file content cannot be read as
instructions.
Behaviour:
- Add auto_tag_config.skip_if_tagged, defaulting to true, so documents the
user already tagged at upload time keep their classification. Existing
tags are now loaded before the model call, so a skipped document costs no
LLM round-trip. Configs stored without the field adopt the default.
Also promote AddKnowledgeTagRelations to KnowledgeRepository instead of
reaching for it through a type assertion that failed at runtime, and route
the max_tags bounds through AutoTagConfig.Normalize so the prompt, the match
filter and the persisted config cannot drift apart.
Adds handler-level coverage for scope, cancellation, idempotency, ordinal
validation and the new toggle, plus SDK, Swagger and API doc updates.
2026-08-07 07:32:16 +00:00
|
|
|
|
max_tags: formData.value.autoTagConfig?.maxTags || 3,
|
|
|
|
|
|
skip_if_tagged: formData.value.autoTagConfig?.skipIfTagged ?? true
|
2026-08-05 13:56:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
if (formData.value.type === 'faq') {
|
|
|
|
|
|
data.faq_config = {
|
2025-11-16 15:35:54 +00:00
|
|
|
|
index_mode: formData.value.faqConfig?.indexMode || 'question_only',
|
|
|
|
|
|
question_index_mode: formData.value.faqConfig?.questionIndexMode || 'separate'
|
2025-11-14 17:30:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-22 12:27:19 +00:00
|
|
|
|
// Wiki enablement is carried solely by indexing_strategy.wiki_enabled.
|
|
|
|
|
|
// wiki_config only holds wiki-specific tunables.
|
2026-04-07 11:36:06 +00:00
|
|
|
|
if (formData.value.type !== 'faq') {
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
data.wiki_config = {
|
2026-04-20 11:16:46 +00:00
|
|
|
|
synthesis_model_id: formData.value.modelConfig?.wikiSynthesisModelId || '',
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
max_pages_per_ingest: formData.value.wikiConfig?.maxPagesPerIngest || 0,
|
2026-04-22 12:27:19 +00:00
|
|
|
|
extraction_granularity: formData.value.wikiConfig?.extractionGranularity || 'standard',
|
2026-07-13 03:57:30 +00:00
|
|
|
|
content_instructions: formData.value.wikiConfig?.contentInstructions || '',
|
|
|
|
|
|
extraction_instructions: formData.value.wikiConfig?.extractionInstructions || '',
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-20 11:16:46 +00:00
|
|
|
|
// Send indexing strategy
|
|
|
|
|
|
if (formData.value.type !== 'faq') {
|
|
|
|
|
|
data.indexing_strategy = {
|
|
|
|
|
|
vector_enabled: formData.value.indexingStrategy?.vectorEnabled ?? true,
|
|
|
|
|
|
keyword_enabled: formData.value.indexingStrategy?.keywordEnabled ?? true,
|
|
|
|
|
|
wiki_enabled: formData.value.indexingStrategy?.wikiEnabled ?? false,
|
|
|
|
|
|
graph_enabled: formData.value.indexingStrategy?.graphEnabled ?? false,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-12 16:33:51 +00:00
|
|
|
|
// Always persist extract_config so the toggle state from GraphSettings is saved,
|
|
|
|
|
|
// regardless of whether the graph indexing strategy is currently enabled.
|
|
|
|
|
|
if (formData.value.nodeExtractConfig) {
|
2026-04-20 11:16:46 +00:00
|
|
|
|
data.extract_config = {
|
2026-05-12 16:33:51 +00:00
|
|
|
|
enabled: !!formData.value.nodeExtractConfig.enabled,
|
|
|
|
|
|
text: formData.value.nodeExtractConfig.text || '',
|
|
|
|
|
|
tags: formData.value.nodeExtractConfig.tags || [],
|
|
|
|
|
|
nodes: formData.value.nodeExtractConfig.nodes || [],
|
2026-07-13 03:57:30 +00:00
|
|
|
|
relations: formData.value.nodeExtractConfig.relations || [],
|
|
|
|
|
|
custom_instructions: formData.value.nodeExtractConfig.customInstructions || ''
|
2026-04-20 11:16:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
return data
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 提交表单
|
|
|
|
|
|
const handleSubmit = async () => {
|
|
|
|
|
|
if (!validateForm()) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-09 12:27:24 +00:00
|
|
|
|
// 编辑模式下,若已有文件且存储引擎发生了变化,弹窗确认
|
|
|
|
|
|
if (
|
2026-07-31 03:42:09 +00:00
|
|
|
|
editorMode.value === 'edit' &&
|
2026-03-09 12:27:24 +00:00
|
|
|
|
hasFiles.value &&
|
|
|
|
|
|
formData.value &&
|
|
|
|
|
|
initialStorageProvider.value &&
|
|
|
|
|
|
formData.value.storageProvider !== initialStorageProvider.value
|
|
|
|
|
|
) {
|
|
|
|
|
|
const dialog = DialogPlugin.confirm({
|
|
|
|
|
|
header: t('common.confirm'),
|
|
|
|
|
|
body: t('knowledgeEditor.messages.storageChangeConfirm'),
|
|
|
|
|
|
confirmBtn: t('common.confirm'),
|
|
|
|
|
|
cancelBtn: t('common.cancel'),
|
|
|
|
|
|
onConfirm: () => {
|
|
|
|
|
|
dialog.destroy()
|
|
|
|
|
|
doSubmit()
|
|
|
|
|
|
},
|
|
|
|
|
|
onCancel: () => {
|
|
|
|
|
|
dialog.destroy()
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
doSubmit()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const doSubmit = async () => {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
saving.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
const data = buildSubmitData()
|
|
|
|
|
|
if (!data) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
throw new Error(t('knowledgeEditor.messages.buildDataFailed'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-31 03:42:09 +00:00
|
|
|
|
if (editorMode.value === 'create') {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
// 创建模式:一次性创建知识库及所有配置
|
2025-11-13 11:34:33 +00:00
|
|
|
|
const result: any = await createKnowledgeBase(data)
|
2025-11-06 13:12:26 +00:00
|
|
|
|
if (!result.success || !result.data?.id) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
throw new Error(result.message || t('knowledgeEditor.messages.createFailed'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
2026-07-31 03:47:34 +00:00
|
|
|
|
const createdKbId = result.data.id as string
|
|
|
|
|
|
savedKbId.value = createdKbId
|
2026-07-31 03:42:09 +00:00
|
|
|
|
currentSection.value = 'basic'
|
2026-07-31 03:47:34 +00:00
|
|
|
|
await loadKBData(createdKbId)
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.success(t('knowledgeEditor.messages.createSuccess'))
|
2026-06-03 06:41:12 +00:00
|
|
|
|
markContextualGuideDone('kbCreate')
|
2026-07-31 03:47:34 +00:00
|
|
|
|
emit('success', createdKbId)
|
2025-11-06 13:12:26 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
// 编辑模式:分别更新基本信息和配置
|
2026-07-31 03:42:09 +00:00
|
|
|
|
const kbId = activeKbId.value
|
|
|
|
|
|
if (!kbId) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
throw new Error(t('knowledgeEditor.messages.missingId'))
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
// 1. 更新基本信息(名称、描述)和 FAQ/Wiki 配置
|
2025-11-14 17:30:17 +00:00
|
|
|
|
const updateConfig: any = {}
|
|
|
|
|
|
if (formData.value.type === 'faq' && formData.value.faqConfig) {
|
|
|
|
|
|
updateConfig.faq_config = {
|
2025-11-16 15:35:54 +00:00
|
|
|
|
index_mode: formData.value.faqConfig.indexMode || 'question_only',
|
|
|
|
|
|
question_index_mode: formData.value.faqConfig.questionIndexMode || 'separate'
|
2025-11-14 17:30:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-07 11:36:06 +00:00
|
|
|
|
if (formData.value.wikiConfig && formData.value.type !== 'faq') {
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
updateConfig.wiki_config = {
|
2026-04-20 11:16:46 +00:00
|
|
|
|
synthesis_model_id: formData.value.modelConfig?.wikiSynthesisModelId || '',
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
max_pages_per_ingest: formData.value.wikiConfig.maxPagesPerIngest || 0,
|
2026-04-22 12:27:19 +00:00
|
|
|
|
extraction_granularity: formData.value.wikiConfig.extractionGranularity || 'standard',
|
2026-07-13 03:57:30 +00:00
|
|
|
|
content_instructions: formData.value.wikiConfig.contentInstructions || '',
|
|
|
|
|
|
extraction_instructions: formData.value.wikiConfig.extractionInstructions || '',
|
feat: Implement comprehensive wiki feature for knowledge bases
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes:
**Backend Changes:**
- Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log)
- Database schema: wiki_pages table with full migration support
- WikiPageService: CRUD operations and page management
- WikiPageRepository: GORM-based persistence layer
- Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents
* Summary page generation using LLM
* Entity and concept extraction in a single LLM call
* Synthesis opportunity detection
* Index page rebuilding
* Log page maintenance
- Wiki boost feature: Enhance chat retrieval with wiki context
- Wiki linting: Maintenance and validation utilities
- Agent wiki tools: Enable agents to query and interact with wiki pages
- Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks
- Language support: Reuse existing middleware language infrastructure for LLM prompts
**Frontend Changes:**
- Wiki browser UI: View all wiki pages with filtering and search
- Wiki API client: Knowledge base wiki management endpoints
- Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model)
- i18n updates: Support for English, Korean, Russian, and Chinese interfaces
**Configuration:**
- Container DI: Wire up all wiki services
- Router: Register wiki API endpoints
- Task handling: Support async wiki ingest tasks
**Testing:**
- Unit tests for wiki page types
- Service layer tests
- Endpoint tests for wiki operations
- Integration tests with LLM mocking
**Documentation:**
- Language refactoring analysis and guides
- Implementation completion reports
- Quick reference guides for developers
**Key Features:**
✅ LLM-powered wiki page generation from documents
✅ Multi-language support (9+ languages)
✅ Automatic extraction of entities and concepts
✅ Synthesis opportunity detection
✅ Index and log page maintenance
✅ Progressive wiki building across multiple documents
✅ Agent-based wiki interaction
✅ Chat retrieval enhancement with wiki context
✅ Full frontend UI for wiki browsing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 05:56:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-20 11:16:46 +00:00
|
|
|
|
if (formData.value.type !== 'faq') {
|
2026-08-05 13:56:58 +00:00
|
|
|
|
updateConfig.auto_tag_config = data.auto_tag_config
|
2026-04-20 11:16:46 +00:00
|
|
|
|
updateConfig.indexing_strategy = {
|
|
|
|
|
|
vector_enabled: formData.value.indexingStrategy?.vectorEnabled ?? true,
|
|
|
|
|
|
keyword_enabled: formData.value.indexingStrategy?.keywordEnabled ?? true,
|
|
|
|
|
|
wiki_enabled: formData.value.indexingStrategy?.wikiEnabled ?? false,
|
|
|
|
|
|
graph_enabled: formData.value.indexingStrategy?.graphEnabled ?? false,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-07-31 03:42:09 +00:00
|
|
|
|
await updateKnowledgeBase(kbId, {
|
2025-11-06 13:12:26 +00:00
|
|
|
|
name: data.name,
|
|
|
|
|
|
description: data.description,
|
2025-11-14 17:30:17 +00:00
|
|
|
|
config: updateConfig
|
2025-11-06 13:12:26 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-02-28 05:22:07 +00:00
|
|
|
|
// 2. 更新完整配置(模型、分块、多模态、存储引擎、知识图谱等)
|
2025-11-06 13:12:26 +00:00
|
|
|
|
const config: KBModelConfigRequest = {
|
|
|
|
|
|
llmModelId: data.summary_model_id,
|
|
|
|
|
|
embeddingModelId: data.embedding_model_id,
|
2025-11-20 12:08:24 +00:00
|
|
|
|
vlm_config: data.vlm_config,
|
2026-04-02 08:43:37 +00:00
|
|
|
|
asr_config: data.asr_config,
|
2025-11-06 13:12:26 +00:00
|
|
|
|
documentSplitting: {
|
|
|
|
|
|
chunkSize: data.chunking_config.chunk_size,
|
|
|
|
|
|
chunkOverlap: data.chunking_config.chunk_overlap,
|
2026-02-28 05:22:07 +00:00
|
|
|
|
separators: data.chunking_config.separators,
|
2026-03-04 12:35:10 +00:00
|
|
|
|
parserEngineRules: data.chunking_config.parser_engine_rules || undefined,
|
|
|
|
|
|
enableParentChild: data.chunking_config.enable_parent_child || false,
|
2026-03-05 07:04:08 +00:00
|
|
|
|
parentChunkSize: data.chunking_config.parent_chunk_size || 4096,
|
2026-05-02 20:40:07 +00:00
|
|
|
|
childChunkSize: data.chunking_config.child_chunk_size || 384,
|
2026-05-03 07:01:20 +00:00
|
|
|
|
// Always send strategy / tokenLimit / languages — backend treats
|
|
|
|
|
|
// empty/0/[] as a valid clear, so we must include them in the
|
|
|
|
|
|
// payload to let users reset back to defaults.
|
|
|
|
|
|
strategy: formData.value?.chunkingConfig.strategy ?? '',
|
|
|
|
|
|
tokenLimit: formData.value?.chunkingConfig.tokenLimit ?? 0,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
languages: formData.value?.chunkingConfig.languages ?? [],
|
|
|
|
|
|
tableMetadataInstructions: formData.value?.chunkingConfig.tableMetadataInstructions ?? ''
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
|
|
|
|
|
multimodal: {
|
2026-02-28 05:22:07 +00:00
|
|
|
|
enabled: !!data.vlm_config?.enabled
|
2025-11-06 13:12:26 +00:00
|
|
|
|
},
|
2026-07-15 05:26:29 +00:00
|
|
|
|
storageBackendId: formData.value?.storageBackendId || '',
|
fix(frontend): use storage_provider_config instead of legacy storage_config
The backend introduced storage_provider_config as the authoritative
field in commit dbab7b0, but the frontend was never updated to use it.
This caused the UI to always display "local" regardless of the actual
storage provider, and saving KB settings could overwrite the correct
storage_provider_config with an incorrect value.
Changes:
- KnowledgeBaseEditorModal.vue: read from storage_provider_config with
storage_config fallback, dual-write both fields on save
- KnowledgeBaseList.vue: update feature badge logic and add type def
for storage_provider_config, exclude "local" from badge display
- api/knowledge-base/index.ts: add storage_provider_config to API type
- ko-KR.ts, ru-RU.ts: add missing i18n keys — multimodal section
(sidebar.multimodal, multimodal.title/description), channel labels
(channelLabel, channelWeb, channelApi, etc.), and agent.think
2026-04-01 07:37:13 +00:00
|
|
|
|
storageProvider: data.storage_provider_config?.provider || data.storage_config?.provider || 'local',
|
2025-11-06 13:12:26 +00:00
|
|
|
|
nodeExtract: {
|
|
|
|
|
|
enabled: data.extract_config?.enabled || false,
|
|
|
|
|
|
text: data.extract_config?.text || '',
|
|
|
|
|
|
tags: data.extract_config?.tags || [],
|
2025-11-25 08:44:44 +00:00
|
|
|
|
nodes: data.extract_config?.nodes || [],
|
2026-07-13 03:57:30 +00:00
|
|
|
|
relations: data.extract_config?.relations || [],
|
|
|
|
|
|
customInstructions: data.extract_config?.custom_instructions || ''
|
2025-12-02 17:42:31 +00:00
|
|
|
|
},
|
|
|
|
|
|
questionGeneration: {
|
|
|
|
|
|
enabled: data.question_generation_config?.enabled || false,
|
2026-07-13 03:57:30 +00:00
|
|
|
|
questionCount: data.question_generation_config?.question_count || 3,
|
|
|
|
|
|
customInstructions: data.question_generation_config?.custom_instructions || ''
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-31 03:42:09 +00:00
|
|
|
|
await updateKBConfig(kbId, config)
|
2025-11-13 11:34:33 +00:00
|
|
|
|
MessagePlugin.success(t('knowledgeEditor.messages.updateSuccess'))
|
2026-04-20 11:16:46 +00:00
|
|
|
|
|
|
|
|
|
|
// Check if indexing strategy changed and offer rebuild
|
|
|
|
|
|
if (hasFiles.value && initialIndexingStrategy.value && formData.value) {
|
|
|
|
|
|
const curr = formData.value.indexingStrategy
|
|
|
|
|
|
const prev = initialIndexingStrategy.value
|
|
|
|
|
|
const strategyChanged = (
|
|
|
|
|
|
curr.vectorEnabled !== prev.vectorEnabled ||
|
|
|
|
|
|
curr.keywordEnabled !== prev.keywordEnabled ||
|
|
|
|
|
|
curr.wikiEnabled !== prev.wikiEnabled ||
|
|
|
|
|
|
curr.graphEnabled !== prev.graphEnabled
|
|
|
|
|
|
)
|
|
|
|
|
|
if (strategyChanged) {
|
|
|
|
|
|
const dialog = DialogPlugin.confirm({
|
|
|
|
|
|
header: t('knowledgeEditor.indexing.rebuildConfirmTitle'),
|
|
|
|
|
|
body: t('knowledgeEditor.indexing.rebuildConfirmBody', { count: '...' }),
|
|
|
|
|
|
confirmBtn: t('common.confirm'),
|
|
|
|
|
|
cancelBtn: t('common.cancel'),
|
|
|
|
|
|
onConfirm: async () => {
|
|
|
|
|
|
dialog.destroy()
|
|
|
|
|
|
try {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
const result: any = await rebuildKBIndex(kbId)
|
2026-04-20 11:16:46 +00:00
|
|
|
|
const count = result?.data?.document_count ?? 0
|
|
|
|
|
|
MessagePlugin.success(t('knowledgeEditor.indexing.rebuildSuccess', { count }))
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error('Rebuild index failed:', e)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onCancel: () => {
|
|
|
|
|
|
dialog.destroy()
|
|
|
|
|
|
MessagePlugin.info(t('knowledgeEditor.indexing.rebuildSkip'))
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-31 03:42:09 +00:00
|
|
|
|
emit('success', kbId)
|
|
|
|
|
|
handleClose()
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
} catch (error: any) {
|
2025-11-13 11:34:33 +00:00
|
|
|
|
console.error('Knowledge base operation failed:', error)
|
feat: expose KB ↔ vector store binding in list, editor, and detail UI
Backend
-------
ListKnowledgeBases now enriches each row with the resolved vector_store
metadata (name / source / engine_type / status) via a new
buildKBListResponse helper. Store views are batch-resolved once per
request through BatchResolveStoreView so an N-KB list costs one
vector-store service call rather than N — closing the N+1 limitation
flagged in #1372's known-limitations section. Cross-tenant shared KBs
continue to render via SharedStoreDisplay so the owning tenant's store
inventory cannot be correlated across rows; the underlying vector_store_id
UUID is stripped from those responses.
Resolver failures degrade gracefully: bound KBs render as unavailable
instead of breaking the list. Test coverage pins the env / bound /
shared distinction, the batch-call-count invariant, and the
graceful-failure path.
Frontend
--------
KB editor modal gains a new "Vector Store" section. Create mode shows a
dropdown that combines the system default (env store) and the tenant's
configured user stores, fetched once at mount via the existing
listVectorStores API. Edit mode shows the bound store read-only via a
new VectorStoreBadge component with an explicit immutability hint —
matching the backend's `<-:create` GORM tag and the service-layer
UpdateKnowledgeBaseRequest DTO that already omit the field.
KB list cards surface a small engine-type badge for own-tenant bound
KBs, and a warning badge when the bound store is unavailable. Env-bound
and shared KBs render no badge (visual noise control). KB detail header
shows the bound store via the same VectorStoreBadge component; shared
KBs fall through to the badge's internal "shared" branch with no name /
engine / id rendered.
The KB editor's create-time error handler translates the typed
ErrVectorStoreBindingInvalid (2200) and ErrVectorStoreUnavailable
(2201) into localized messages and jumps the user back to the
VectorStore section so they can pick a different store or fall back to
the system default.
The KB row type gains five optional fields (vector_store_id / name /
engine_type / source / status). i18n: 18 new keys added to en-US,
ko-KR, zh-CN; ru-RU receives English placeholders pending translation
(consistent with prior PRs in this locale).
Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 5 (KB binding UI + list-response enrichment).
Depends on #994, #1310, #1372, #1386 (all backend in the Phase 2 series).
2026-05-18 14:50:09 +00:00
|
|
|
|
// 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'))
|
|
|
|
|
|
}
|
2025-11-06 13:12:26 +00:00
|
|
|
|
} finally {
|
|
|
|
|
|
saving.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重置所有状态
|
|
|
|
|
|
const resetState = () => {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
savedKbId.value = null
|
2025-11-06 13:12:26 +00:00
|
|
|
|
currentSection.value = 'basic'
|
|
|
|
|
|
formData.value = null
|
|
|
|
|
|
hasFiles.value = false
|
2026-03-09 12:27:24 +00:00
|
|
|
|
initialStorageProvider.value = ''
|
2026-05-29 05:36:06 +00:00
|
|
|
|
tenantDefaultStorageProvider.value = 'local'
|
2026-04-20 11:16:46 +00:00
|
|
|
|
initialIndexingStrategy.value = null
|
2025-11-06 13:12:26 +00:00
|
|
|
|
saving.value = false
|
|
|
|
|
|
loading.value = false
|
2026-04-23 03:21:28 +00:00
|
|
|
|
chunkingDirty.value = false
|
2026-05-15 09:56:58 +00:00
|
|
|
|
kbCreatorId.value = ''
|
2026-07-22 11:15:27 +00:00
|
|
|
|
kbTenantId.value = 0
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭弹窗
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
|
emit('update:visible', false)
|
|
|
|
|
|
setTimeout(() => {
|
2026-09-02 09:20:37 +00:00
|
|
|
|
if (props.visible) return
|
2025-11-06 13:12:26 +00:00
|
|
|
|
resetState()
|
|
|
|
|
|
}, 300)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 监听弹窗打开/关闭
|
|
|
|
|
|
watch(() => props.visible, async (newVal) => {
|
2026-09-02 09:20:37 +00:00
|
|
|
|
const generation = ++kbEditorLoadGeneration
|
2025-11-06 13:12:26 +00:00
|
|
|
|
if (newVal) {
|
|
|
|
|
|
// 打开弹窗时,先重置状态
|
|
|
|
|
|
resetState()
|
2026-09-02 09:20:37 +00:00
|
|
|
|
loading.value = true
|
|
|
|
|
|
const targetKbId = props.kbId
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
2025-11-07 08:40:53 +00:00
|
|
|
|
// 检查是否有初始 section,如果有则跳转
|
|
|
|
|
|
if (uiStore.kbEditorInitialSection) {
|
|
|
|
|
|
currentSection.value = uiStore.kbEditorInitialSection
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-14 08:13:49 +00:00
|
|
|
|
// 加载模型列表与空间默认存储引擎(创建 KB 时即使用,不依赖是否打开「存储引擎」Tab)
|
2026-05-29 05:36:06 +00:00
|
|
|
|
await Promise.all([loadAllModels(), loadTenantDefaultStorageProvider()])
|
2026-09-02 09:20:37 +00:00
|
|
|
|
|
|
|
|
|
|
if (generation !== kbEditorLoadGeneration || !props.visible) return
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
// 根据模式加载数据
|
2026-09-02 09:20:37 +00:00
|
|
|
|
if (props.mode === 'edit' && targetKbId) {
|
|
|
|
|
|
await loadKBData(targetKbId, generation)
|
2025-11-06 13:12:26 +00:00
|
|
|
|
} else {
|
2026-07-14 08:13:49 +00:00
|
|
|
|
// 创建模式:初始化空表单,并预填空间默认存储引擎
|
2025-11-14 17:30:17 +00:00
|
|
|
|
formData.value = initFormData(props.initialType || 'document')
|
2026-05-29 05:36:06 +00:00
|
|
|
|
formData.value.storageProvider = tenantDefaultStorageProvider.value
|
2025-11-06 13:12:26 +00:00
|
|
|
|
hasFiles.value = false
|
2026-06-03 06:41:12 +00:00
|
|
|
|
applyDefaultModelsIfEmpty()
|
2026-09-02 09:20:37 +00:00
|
|
|
|
loading.value = false
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 关闭弹窗时,延迟重置状态(等待动画结束)
|
|
|
|
|
|
setTimeout(() => {
|
2026-09-02 09:20:37 +00:00
|
|
|
|
if (props.visible) return
|
2025-11-06 13:12:26 +00:00
|
|
|
|
resetState()
|
2025-11-07 08:40:53 +00:00
|
|
|
|
currentSection.value = 'basic' // 重置为默认 section
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}, 300)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-11-14 04:09:52 +00:00
|
|
|
|
|
|
|
|
|
|
// 监听全局设置弹窗关闭后刷新模型列表
|
|
|
|
|
|
watch(
|
|
|
|
|
|
() => uiStore.showSettingsModal,
|
|
|
|
|
|
async (visible, previous) => {
|
|
|
|
|
|
if (!visible && previous && props.visible) {
|
2026-06-08 12:55:54 +00:00
|
|
|
|
await loadAllModels(true)
|
2025-11-14 04:09:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="less">
|
|
|
|
|
|
// 复用创建知识库的样式
|
|
|
|
|
|
.settings-overlay {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
background: rgba(0, 0, 0, 0.5);
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
z-index: 1000;
|
|
|
|
|
|
backdrop-filter: blur(4px);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.settings-modal {
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
width: 90vw;
|
2026-03-27 07:02:40 +00:00
|
|
|
|
max-width: 1000px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
height: 85vh;
|
|
|
|
|
|
max-height: 750px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-container);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-09-02 09:20:37 +00:00
|
|
|
|
.editor-initializing {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
inset: 0;
|
|
|
|
|
|
z-index: 20;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
background: var(--td-bg-color-container);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
.close-btn {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 20px;
|
|
|
|
|
|
right: 20px;
|
|
|
|
|
|
width: 32px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
border: none;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-secondary);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
|
z-index: 10;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.settings-container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
height: 100%;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
width: 100%;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-12 14:40:18 +00:00
|
|
|
|
/* 左侧导航:与 AgentEditorModal 对齐 */
|
2025-11-06 13:12:26 +00:00
|
|
|
|
.settings-sidebar {
|
2026-06-12 14:40:18 +00:00
|
|
|
|
width: 208px;
|
|
|
|
|
|
background-color: var(--td-bg-color-settings-modal);
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-right: 1px solid var(--td-component-stroke);
|
2026-06-12 14:40:18 +00:00
|
|
|
|
flex-shrink: 0;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
overflow: hidden;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.sidebar-header {
|
2026-06-12 14:40:18 +00:00
|
|
|
|
padding: 16px 14px 12px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-bottom: 1px solid var(--td-component-stroke);
|
2026-06-12 14:40:18 +00:00
|
|
|
|
flex-shrink: 0;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.sidebar-title {
|
|
|
|
|
|
margin: 0;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
font-size: 16px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
font-weight: 600;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.settings-nav {
|
|
|
|
|
|
flex: 1;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
padding: 8px 8px 12px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
overflow-y: auto;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
min-height: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-group-title {
|
|
|
|
|
|
padding: 6px 14px 2px;
|
|
|
|
|
|
color: var(--td-text-color-placeholder);
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
letter-spacing: 0.02em;
|
|
|
|
|
|
|
|
|
|
|
|
.settings-nav > &:first-child {
|
|
|
|
|
|
padding-top: 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.settings-nav > &:not(:first-child) {
|
|
|
|
|
|
padding-top: 8px;
|
|
|
|
|
|
}
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
padding: 6px 12px;
|
|
|
|
|
|
margin-bottom: 2px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
|
font-size: 14px;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
|
|
|
|
|
user-select: none;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
&:hover {
|
2026-06-22 06:32:21 +00:00
|
|
|
|
background-color: var(--td-bg-color-container-hover);
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.active {
|
2026-06-22 06:32:21 +00:00
|
|
|
|
background-color: var(--td-bg-color-secondarycontainer);
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-brand-color);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-icon {
|
2026-06-12 14:40:18 +00:00
|
|
|
|
margin-right: 9px;
|
|
|
|
|
|
font-size: 16px;
|
2025-11-06 15:13:13 +00:00
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
color: inherit;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-label {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-30 05:32:39 +00:00
|
|
|
|
.nav-badge {
|
2026-06-12 14:40:18 +00:00
|
|
|
|
flex-shrink: 0;
|
2026-06-23 06:58:45 +00:00
|
|
|
|
margin-left: 2px;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
padding: 0 6px;
|
2026-06-23 06:58:45 +00:00
|
|
|
|
border-radius: 8px;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
2026-06-23 06:58:45 +00:00
|
|
|
|
color: var(--td-text-color-secondary);
|
2026-03-30 05:32:39 +00:00
|
|
|
|
font-size: 11px;
|
2026-06-23 06:58:45 +00:00
|
|
|
|
line-height: 16px;
|
|
|
|
|
|
font-weight: 500;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
text-align: center;
|
2026-03-30 05:32:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
.settings-content {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.content-wrapper {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
padding: 24px 32px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section {
|
|
|
|
|
|
margin-bottom: 32px;
|
|
|
|
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-content {
|
|
|
|
|
|
.section-header {
|
2026-06-12 14:40:18 +00:00
|
|
|
|
margin-bottom: 16px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-title {
|
2026-06-12 14:40:18 +00:00
|
|
|
|
margin: 0 0 6px 0;
|
2026-05-02 08:06:56 +00:00
|
|
|
|
font-family: var(--app-font-family);
|
2026-03-27 07:02:40 +00:00
|
|
|
|
font-size: 20px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
font-weight: 600;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-desc {
|
|
|
|
|
|
margin: 0;
|
2026-05-02 08:06:56 +00:00
|
|
|
|
font-family: var(--app-font-family);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
font-size: 14px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-placeholder);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
line-height: 22px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-body {
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-container);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-item {
|
2026-04-20 11:16:46 +00:00
|
|
|
|
margin-bottom: 16px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.form-label {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
margin-bottom: 8px;
|
2026-05-02 08:06:56 +00:00
|
|
|
|
font-family: var(--app-font-family);
|
2026-03-27 07:02:40 +00:00
|
|
|
|
font-size: 15px;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
font-weight: 500;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-primary);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
|
|
|
|
|
|
&.required::after {
|
|
|
|
|
|
content: '*';
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-error-color);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
.form-tip {
|
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
|
font-size: 12px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
color: var(--td-text-color-placeholder);
|
2025-11-14 17:30:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-28 12:53:34 +00:00
|
|
|
|
.kb-id-field {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
max-width: 480px;
|
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
padding: 6px 8px 6px 12px;
|
|
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
|
|
|
|
|
border: 1px solid var(--td-component-stroke);
|
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
|
|
|
|
|
|
|
.kb-id-value {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
background: none;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
font-family: var(--app-font-family-mono);
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.kb-id-copy {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
color: var(--td-text-color-secondary);
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
color: var(--td-brand-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-22 12:27:19 +00:00
|
|
|
|
.granularity-radio-group {
|
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.granularity-hint {
|
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
|
color: var(--td-text-color-secondary);
|
|
|
|
|
|
white-space: normal;
|
|
|
|
|
|
word-break: break-word;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-20 11:16:46 +00:00
|
|
|
|
.indexing-checks {
|
2026-04-20 13:54:54 +00:00
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.indexing-check-item {
|
2026-04-20 11:16:46 +00:00
|
|
|
|
display: flex;
|
2026-04-20 13:54:54 +00:00
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
padding: 12px 14px;
|
|
|
|
|
|
border: 1px solid var(--td-component-stroke);
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
background: var(--td-bg-color-container);
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
user-select: none;
|
|
|
|
|
|
transition: border-color 0.2s ease, background 0.2s ease;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
border-color: var(--td-brand-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.is-checked {
|
|
|
|
|
|
border-color: var(--td-brand-color);
|
|
|
|
|
|
background: var(--td-brand-color-light);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-21 06:46:41 +00:00
|
|
|
|
&.is-disabled {
|
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
border-color: var(--td-component-stroke);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&.is-checked:hover {
|
|
|
|
|
|
border-color: var(--td-brand-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-20 13:54:54 +00:00
|
|
|
|
:deep(.t-checkbox__label) {
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-21 06:46:41 +00:00
|
|
|
|
.locked-tip {
|
|
|
|
|
|
color: var(--td-warning-color);
|
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-20 13:54:54 +00:00
|
|
|
|
// 禁用内部 checkbox 自身的点击事件,统一由卡片处理
|
|
|
|
|
|
.indexing-check-box {
|
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.indexing-check-title {
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.indexing-new-badge {
|
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
padding: 0 6px;
|
|
|
|
|
|
height: 16px;
|
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
line-height: 1;
|
|
|
|
|
|
letter-spacing: 0.4px;
|
|
|
|
|
|
color: var(--td-brand-color);
|
|
|
|
|
|
background: var(--td-brand-color-light);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.indexing-check-desc {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
padding-left: 24px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
line-height: 18px;
|
|
|
|
|
|
color: var(--td-text-color-placeholder);
|
2026-04-20 11:16:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 17:30:17 +00:00
|
|
|
|
.faq-guide {
|
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
|
padding: 12px 16px;
|
|
|
|
|
|
border-radius: 8px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
background: var(--td-bg-color-secondarycontainer);
|
|
|
|
|
|
color: var(--td-text-color-secondary);
|
2025-11-14 17:30:17 +00:00
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
line-height: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-06 13:12:26 +00:00
|
|
|
|
.settings-footer {
|
2026-07-31 03:42:09 +00:00
|
|
|
|
padding: 12px 40px;
|
2026-03-05 03:19:36 +00:00
|
|
|
|
border-top: 1px solid var(--td-component-stroke);
|
2025-11-06 13:12:26 +00:00
|
|
|
|
display: flex;
|
2026-07-31 03:42:09 +00:00
|
|
|
|
align-items: center;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
justify-content: flex-end;
|
2026-07-31 03:42:09 +00:00
|
|
|
|
gap: 16px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.settings-footer-note {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
margin-right: auto;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
line-height: 20px;
|
|
|
|
|
|
color: var(--td-text-color-secondary);
|
|
|
|
|
|
|
|
|
|
|
|
strong {
|
|
|
|
|
|
margin-right: 4px;
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
&__icon {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
margin-top: 2px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: var(--td-success-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.settings-footer-actions {
|
|
|
|
|
|
display: flex;
|
2025-11-06 13:12:26 +00:00
|
|
|
|
gap: 12px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 过渡动画
|
|
|
|
|
|
.modal-enter-active,
|
|
|
|
|
|
.modal-leave-active {
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.modal-enter-from,
|
|
|
|
|
|
.modal-leave-to {
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
|
|
|
|
|
|
.settings-modal {
|
|
|
|
|
|
transform: scale(0.95);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-14 17:30:17 +00:00
|
|
|
|
|
2026-03-11 13:16:23 +00:00
|
|
|
|
// 多模态配置内联样式(与子组件 KBStorageSettings/KBAdvancedSettings 一致)
|
|
|
|
|
|
.kb-multimodal-settings {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
.section-header {
|
2026-06-12 14:40:18 +00:00
|
|
|
|
margin-bottom: 20px;
|
2026-03-11 13:16:23 +00:00
|
|
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
2026-06-12 14:40:18 +00:00
|
|
|
|
margin: 0 0 6px 0;
|
2026-03-11 13:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-description {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: var(--td-text-color-secondary);
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.settings-group {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.setting-row {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
justify-content: space-between;
|
2026-06-12 14:40:18 +00:00
|
|
|
|
padding: 16px 0;
|
2026-03-11 13:16:23 +00:00
|
|
|
|
border-bottom: 1px solid var(--td-component-stroke);
|
|
|
|
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.setting-info {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
max-width: 65%;
|
|
|
|
|
|
padding-right: 24px;
|
|
|
|
|
|
|
|
|
|
|
|
label {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: var(--td-text-color-primary);
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.desc {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
color: var(--td-text-color-secondary);
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.setting-control {
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
min-width: 280px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.required {
|
|
|
|
|
|
color: var(--td-error-color);
|
|
|
|
|
|
margin-left: 2px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-06 13:12:26 +00:00
|
|
|
|
</style>
|