feat(client): enhance knowledge file upload with process configuration support
- Updated the `CreateKnowledgeFromFile` function to accept an optional `processConfig` parameter for per-upload parse configuration overrides. - Introduced the `KnowledgeProcessOverrides` type to define various parsing settings, including parser engine rules and chunking configurations. - Modified the API client and related components to handle the new process configuration, improving flexibility in knowledge file uploads. - Updated documentation and API specifications to reflect the new `process_config` parameter in the upload process. - Added a new `UploadConfirmHost` component to facilitate user confirmation for uploads, integrating with the updated upload logic. - Enhanced user experience by providing detailed configuration options during the upload process.
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
<template>
|
||||
<div class="graph-settings">
|
||||
<div class="section-header">
|
||||
<div class="graph-settings" :class="{ 'graph-settings--embedded': embedded }">
|
||||
<div v-if="!embedded" class="section-header">
|
||||
<h2>{{ t('graphSettings.title') }}</h2>
|
||||
<p class="section-description">{{ t('graphSettings.description') }}</p>
|
||||
|
||||
<!-- Warning message when graph database is not enabled -->
|
||||
|
||||
<t-alert
|
||||
v-if="!isGraphDatabaseEnabled"
|
||||
theme="warning"
|
||||
@@ -18,6 +17,15 @@
|
||||
</template>
|
||||
</t-alert>
|
||||
</div>
|
||||
<t-alert
|
||||
v-else-if="!isGraphDatabaseEnabled"
|
||||
theme="warning"
|
||||
class="embedded-graph-alert"
|
||||
>
|
||||
<template #message>
|
||||
<div>{{ t('graphSettings.disabledWarning') }}</div>
|
||||
</template>
|
||||
</t-alert>
|
||||
|
||||
<div v-if="isGraphDatabaseEnabled" class="settings-group">
|
||||
<!-- 启用实体关系提取 -->
|
||||
@@ -296,7 +304,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted, computed } from 'vue'
|
||||
import { ref, watch, onMounted, computed, withDefaults } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { extractTextRelations, fabriText, fabriTag, type Node, type Relation } from '@/api/initialization'
|
||||
@@ -323,9 +331,12 @@ interface Props {
|
||||
graphExtract: GraphExtractConfig
|
||||
modelId: string
|
||||
allModels?: any[]
|
||||
embedded?: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
embedded: false,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:graphExtract': [value: GraphExtractConfig]
|
||||
@@ -766,4 +777,27 @@ onMounted(async () => {
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.graph-settings--embedded {
|
||||
.embedded-graph-alert {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.setting-row:not(.vertical) {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.setting-row:not(.vertical) .setting-info {
|
||||
flex: none;
|
||||
max-width: none;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.setting-row:not(.vertical) .setting-control {
|
||||
align-self: flex-start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="kb-advanced-settings">
|
||||
<div class="section-header">
|
||||
<div class="kb-advanced-settings" :class="{ 'kb-advanced-settings--embedded': embedded }">
|
||||
<div v-if="!embedded" class="section-header">
|
||||
<h2>{{ $t('knowledgeEditor.advanced.title') }}</h2>
|
||||
<p class="section-description">{{ $t('knowledgeEditor.advanced.description') }}</p>
|
||||
</div>
|
||||
@@ -49,7 +49,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, withDefaults } from 'vue'
|
||||
|
||||
interface QuestionGenerationConfig {
|
||||
enabled: boolean
|
||||
@@ -60,9 +60,12 @@ interface Props {
|
||||
questionGeneration?: QuestionGenerationConfig
|
||||
ragEnabled?: boolean
|
||||
allModels?: any[]
|
||||
embedded?: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
embedded: false,
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:questionGeneration': [value: QuestionGenerationConfig]
|
||||
@@ -182,4 +185,51 @@ const handleQuestionGenerationChange = () => {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.kb-advanced-settings--embedded {
|
||||
.setting-row {
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.setting-row:has(.t-switch) {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex: none;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
.subsection .setting-row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
|
||||
.setting-info {
|
||||
flex: none;
|
||||
max-width: none;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
align-self: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.subsection {
|
||||
margin-top: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="kb-chunking-settings">
|
||||
<div class="section-header">
|
||||
<div class="kb-chunking-settings" :class="{ 'kb-chunking-settings--embedded': embedded }">
|
||||
<div v-if="!embedded" class="section-header">
|
||||
<div class="section-header-text">
|
||||
<h2>{{ $t('knowledgeEditor.chunking.title') }}</h2>
|
||||
<p class="section-description">{{ $t('knowledgeEditor.chunking.description') }}</p>
|
||||
@@ -21,12 +21,12 @@
|
||||
:placeholder="$t('knowledgeEditor.chunking.strategyPlaceholder')"
|
||||
:clearable="true"
|
||||
@change="handleStrategyChange"
|
||||
style="width: 280px;"
|
||||
:style="selectStyle"
|
||||
/>
|
||||
<!-- Test trigger sits right next to the strategy picker so users
|
||||
discover it exactly when they're deciding which strategy to
|
||||
use on their content. -->
|
||||
<KBChunkingDebug :config="debugConfig" />
|
||||
<KBChunkingDebug v-if="!embedded" :config="debugConfig" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -51,9 +51,9 @@
|
||||
:min="100"
|
||||
:max="4000"
|
||||
:step="50"
|
||||
:marks="{ 100: '100', 1000: '1000', 2000: '2000', 4000: '4000' }"
|
||||
:marks="embedded ? undefined : chunkSizeMarks"
|
||||
@change="handleChunkSizeChange"
|
||||
style="width: 200px;"
|
||||
:style="sliderStyle"
|
||||
/>
|
||||
<span class="value-display">{{ localChunkSize }} {{ $t('knowledgeEditor.chunking.characters') }}</span>
|
||||
</div>
|
||||
@@ -74,9 +74,9 @@
|
||||
:min="0"
|
||||
:max="500"
|
||||
:step="20"
|
||||
:marks="{ 0: '0', 250: '250', 500: '500' }"
|
||||
:marks="embedded ? undefined : chunkOverlapMarks"
|
||||
@change="handleChunkOverlapChange"
|
||||
style="width: 200px;"
|
||||
:style="sliderStyle"
|
||||
/>
|
||||
<span class="value-display">{{ localChunkOverlap }} {{ $t('knowledgeEditor.chunking.characters') }}</span>
|
||||
</div>
|
||||
@@ -84,7 +84,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Separators -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-row setting-row--separators">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.chunking.separatorsLabel') }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.chunking.separatorsDescription') }}</p>
|
||||
@@ -98,13 +98,13 @@
|
||||
filterable
|
||||
:placeholder="$t('knowledgeEditor.chunking.separatorsPlaceholder')"
|
||||
@change="handleSeparatorsChange"
|
||||
style="width: 280px;"
|
||||
:style="selectStyle"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Parent-Child Chunking -->
|
||||
<div class="setting-row">
|
||||
<div class="setting-row setting-row--toggle">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeEditor.chunking.parentChildLabel') }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.chunking.parentChildDescription') }}</p>
|
||||
@@ -130,9 +130,9 @@
|
||||
:min="512"
|
||||
:max="8192"
|
||||
:step="64"
|
||||
:marks="{ 512: '512', 2048: '2048', 4096: '4096', 8192: '8192' }"
|
||||
:marks="embedded ? undefined : parentChunkSizeMarks"
|
||||
@change="handleParentChunkSizeChange"
|
||||
style="width: 200px;"
|
||||
:style="sliderStyle"
|
||||
/>
|
||||
<span class="value-display">{{ localParentChunkSize }} {{ $t('knowledgeEditor.chunking.characters') }}</span>
|
||||
</div>
|
||||
@@ -152,9 +152,9 @@
|
||||
:min="64"
|
||||
:max="2048"
|
||||
:step="32"
|
||||
:marks="{ 64: '64', 384: '384', 1024: '1024', 2048: '2048' }"
|
||||
:marks="embedded ? undefined : childChunkSizeMarks"
|
||||
@change="handleChildChunkSizeChange"
|
||||
style="width: 200px;"
|
||||
:style="sliderStyle"
|
||||
/>
|
||||
<span class="value-display">{{ localChildChunkSize }} {{ $t('knowledgeEditor.chunking.characters') }}</span>
|
||||
</div>
|
||||
@@ -201,7 +201,7 @@
|
||||
:disabled="advancedDisabled"
|
||||
:placeholder="$t('knowledgeEditor.chunking.languagesPlaceholder')"
|
||||
@change="handleLanguagesChange"
|
||||
style="width: 280px;"
|
||||
:style="selectStyle"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -212,7 +212,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed } from 'vue'
|
||||
import { ref, watch, computed, withDefaults } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ChevronRightIcon } from 'tdesign-icons-vue-next'
|
||||
import KBChunkingDebug from './KBChunkingDebug.vue'
|
||||
@@ -253,9 +253,20 @@ interface ChunkingConfig {
|
||||
|
||||
interface Props {
|
||||
config: ChunkingConfig
|
||||
embedded?: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
embedded: false,
|
||||
})
|
||||
|
||||
const selectStyle = computed(() => (props.embedded ? { width: '100%' } : { width: '280px' }))
|
||||
const sliderStyle = computed(() => (props.embedded ? { width: '100%' } : { width: '200px' }))
|
||||
|
||||
const chunkSizeMarks = { 100: '100', 1000: '1000', 2000: '2000', 4000: '4000' }
|
||||
const chunkOverlapMarks = { 0: '0', 250: '250', 500: '500' }
|
||||
const parentChunkSizeMarks = { 512: '512', 2048: '2048', 4096: '4096', 8192: '8192' }
|
||||
const childChunkSizeMarks = { 64: '64', 384: '384', 1024: '1024', 2048: '2048' }
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:config': [value: ChunkingConfig]
|
||||
@@ -563,4 +574,102 @@ const emitUpdate = () => {
|
||||
// panel edge and looks detached from the rest of the form.
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.kb-chunking-settings--embedded {
|
||||
.setting-row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 10px;
|
||||
padding: 14px 0;
|
||||
}
|
||||
|
||||
.setting-row--toggle {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
|
||||
.setting-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex: none;
|
||||
width: auto;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-row--separators {
|
||||
padding-bottom: 18px;
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: none;
|
||||
max-width: none;
|
||||
padding-right: 0;
|
||||
|
||||
label {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex: none;
|
||||
max-width: none;
|
||||
justify-content: flex-start;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.strategy-control {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.strategy-info-panel {
|
||||
margin: -4px 0 10px;
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.slider-container {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.value-display {
|
||||
order: -1;
|
||||
text-align: left;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
:deep(.t-slider) {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
:deep(.t-select__wrap) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
:deep(.t-tag) {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.advanced-toggle {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.advanced-section .setting-row {
|
||||
padding: 14px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="kb-parser-settings">
|
||||
<div class="section-header">
|
||||
<div class="kb-parser-settings" :class="{ 'kb-parser-settings--embedded': embedded }">
|
||||
<div v-if="!embedded" class="section-header">
|
||||
<h2>{{ $t('kbSettings.parser.title') }}</h2>
|
||||
<p class="section-description">{{ $t('kbSettings.parser.description') }}</p>
|
||||
</div>
|
||||
@@ -33,7 +33,7 @@
|
||||
<t-select
|
||||
:value="getEngineForGroup(group.extensions) || undefined"
|
||||
@change="(val: string) => handleEngineChange(group.extensions, val)"
|
||||
style="width: 280px;"
|
||||
:style="embedded ? { width: '100%' } : { width: '280px' }"
|
||||
:status="hasAvailableEngine(group.extensions) ? 'default' : 'warning'"
|
||||
:placeholder="$t('kbSettings.parser.noEngine')"
|
||||
>
|
||||
@@ -123,10 +123,16 @@ interface EngineOption {
|
||||
|
||||
interface Props {
|
||||
parserEngineRules?: ParserEngineRule[]
|
||||
/** Compact layout for upload-confirm dialog */
|
||||
embedded?: boolean
|
||||
/** When set, only show file-type groups matching these extensions */
|
||||
relevantExtensions?: string[]
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
parserEngineRules: () => []
|
||||
parserEngineRules: () => [],
|
||||
embedded: false,
|
||||
relevantExtensions: () => [],
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -182,7 +188,11 @@ const fileTypeGroups = computed(() => {
|
||||
})
|
||||
}
|
||||
|
||||
return groups
|
||||
const rel = props.relevantExtensions
|
||||
if (!rel?.length) return groups
|
||||
const relSet = new Set(rel)
|
||||
const filtered = groups.filter(g => g.extensions.some(e => relSet.has(e)))
|
||||
return filtered.length > 0 ? filtered : groups
|
||||
})
|
||||
|
||||
function getEngineOptions(extensions: string[]): EngineOption[] {
|
||||
@@ -468,6 +478,46 @@ watch(() => props.parserEngineRules, (v) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.kb-parser-settings--embedded {
|
||||
.setting-row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 10px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.setting-info {
|
||||
flex: none;
|
||||
max-width: none;
|
||||
padding-right: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px 10px;
|
||||
}
|
||||
|
||||
.setting-control {
|
||||
flex: none;
|
||||
max-width: none;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.group-label {
|
||||
font-size: 14px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.ext-tags {
|
||||
margin-top: 0;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.ext-tag {
|
||||
font-size: 11px;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
|
||||
Reference in New Issue
Block a user