feat(asr): integrate Automatic Speech Recognition (ASR) support
- Added ASR configuration options to the knowledge base and model settings. - Implemented ASR model selection and transcription capabilities in the knowledge processing pipeline. - Enhanced file upload support to include audio formats for ASR processing. - Updated localization files to include ASR-related labels and descriptions. - Refactored model handling to accommodate ASR as a new model type.
This commit is contained in:
@@ -1514,7 +1514,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
ref="uploadInputRef"
|
||||
type="file"
|
||||
class="document-upload-input"
|
||||
:accept="acceptFileTypes || '.pdf,.docx,.doc,.txt,.md,.json,.jpg,.jpeg,.png,.csv,.xlsx,.xls,.pptx,.ppt'"
|
||||
:accept="acceptFileTypes || '.pdf,.docx,.doc,.txt,.md,.json,.jpg,.jpeg,.png,.csv,.xlsx,.xls,.pptx,.ppt,.mp3,.wav,.m4a,.flac,.ogg'"
|
||||
multiple
|
||||
@change="handleDocumentUpload"
|
||||
/>
|
||||
|
||||
@@ -202,6 +202,49 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ASR 语音识别设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'asr'" class="section">
|
||||
<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 }"
|
||||
:placeholder="$t('knowledgeEditor.asr.modelPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 高级设置 -->
|
||||
<div v-if="!isFAQ" v-show="currentSection === 'advanced'" class="section">
|
||||
<KBAdvancedSettings
|
||||
@@ -298,6 +341,7 @@ const navItems = computed(() => {
|
||||
{ key: 'chunking', icon: 'file-copy', label: t('knowledgeEditor.sidebar.chunking') },
|
||||
{ key: 'graph', icon: 'chart-bubble', label: t('knowledgeEditor.sidebar.graph') },
|
||||
{ key: 'multimodal', icon: 'image', label: t('knowledgeEditor.sidebar.multimodal') },
|
||||
{ key: 'asr', icon: 'sound', label: t('knowledgeEditor.sidebar.asr') },
|
||||
{ key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
|
||||
)
|
||||
if (props.mode === 'edit' && props.kbId) {
|
||||
@@ -363,6 +407,11 @@ const initFormData = (type: 'document' | 'faq' = 'document') => {
|
||||
enabled: false,
|
||||
vllmModelId: ''
|
||||
},
|
||||
asrConfig: {
|
||||
enabled: false,
|
||||
modelId: '',
|
||||
language: ''
|
||||
},
|
||||
nodeExtractConfig: {
|
||||
enabled: false,
|
||||
text: '',
|
||||
@@ -443,6 +492,11 @@ const loadKBData = async () => {
|
||||
enabled: !!kb.vlm_config?.enabled,
|
||||
vllmModelId: kb.vlm_config?.model_id || ''
|
||||
},
|
||||
asrConfig: {
|
||||
enabled: !!kb.asr_config?.enabled,
|
||||
modelId: kb.asr_config?.model_id || '',
|
||||
language: kb.asr_config?.language || ''
|
||||
},
|
||||
nodeExtractConfig: {
|
||||
enabled: kb.extract_config?.enabled || false,
|
||||
text: kb.extract_config?.text || '',
|
||||
@@ -593,6 +647,15 @@ const buildSubmitData = () => {
|
||||
: ''
|
||||
}
|
||||
|
||||
// 添加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 || ''
|
||||
}
|
||||
|
||||
// 存储引擎:仅传 provider,参数从全局设置读取
|
||||
// Write to storage_provider_config (authoritative) + storage_config (legacy dual-write)
|
||||
data.storage_provider_config = {
|
||||
@@ -705,6 +768,7 @@ const doSubmit = async () => {
|
||||
llmModelId: data.summary_model_id,
|
||||
embeddingModelId: data.embedding_model_id,
|
||||
vlm_config: data.vlm_config,
|
||||
asr_config: data.asr_config,
|
||||
documentSplitting: {
|
||||
chunkSize: data.chunking_config.chunk_size,
|
||||
chunkOverlap: data.chunking_config.chunk_overlap,
|
||||
|
||||
@@ -221,6 +221,54 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- STT 语音模型 -->
|
||||
<div class="model-category-section" data-model-type="asr">
|
||||
<div class="category-header">
|
||||
<div class="header-info">
|
||||
<h3>{{ $t('modelSettings.asr.title') }}</h3>
|
||||
<p>{{ $t('modelSettings.asr.desc') }}</p>
|
||||
</div>
|
||||
<t-button size="small" theme="primary" @click="openAddDialog('asr')" class="add-model-btn">
|
||||
<template #icon>
|
||||
<t-icon name="add" class="add-icon" />
|
||||
</template>
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<div v-if="asrModels.length > 0" class="model-list-container">
|
||||
<div v-for="model in asrModels" :key="model.id" class="model-card" :class="{ 'builtin-model': model.isBuiltin }">
|
||||
<div class="model-info">
|
||||
<div class="model-name">
|
||||
{{ model.name }}
|
||||
<t-tag v-if="model.isBuiltin" theme="primary" size="small">{{ $t('modelSettings.builtinTag') }}</t-tag>
|
||||
</div>
|
||||
<div class="model-meta">
|
||||
<span class="source-tag">{{ model.source === 'local' ? 'Ollama' : $t('modelSettings.source.openaiCompatible') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="model-actions">
|
||||
<t-dropdown
|
||||
:options="getModelOptions('asr', model)"
|
||||
@click="(data: any) => handleMenuAction(data, 'asr', model)"
|
||||
placement="bottom-right"
|
||||
attach="body"
|
||||
>
|
||||
<t-button variant="text" shape="square" size="small" class="more-btn">
|
||||
<t-icon name="more" />
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<p class="empty-text">{{ $t('modelSettings.asr.empty') }}</p>
|
||||
<t-button theme="default" variant="outline" size="small" @click="openAddDialog('asr')">
|
||||
{{ $t('modelSettings.actions.addModel') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 模型编辑器弹窗 -->
|
||||
<ModelEditorDialog
|
||||
v-model:visible="showDialog"
|
||||
@@ -242,7 +290,7 @@ import { listModels, createModel, updateModel as updateModelAPI, deleteModel as
|
||||
const { t } = useI18n()
|
||||
|
||||
const showDialog = ref(false)
|
||||
const currentModelType = ref<'chat' | 'embedding' | 'rerank' | 'vllm'>('chat')
|
||||
const currentModelType = ref<'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'>('chat')
|
||||
const editingModel = ref<any>(null)
|
||||
const loading = ref(true)
|
||||
|
||||
@@ -268,12 +316,18 @@ const rerankModels = computed(() =>
|
||||
.map(convertToLegacyFormat)
|
||||
)
|
||||
|
||||
const vllmModels = computed(() =>
|
||||
const vllmModels = computed(() =>
|
||||
allModels.value
|
||||
.filter(m => m.type === 'VLLM')
|
||||
.map(convertToLegacyFormat)
|
||||
)
|
||||
|
||||
const asrModels = computed(() =>
|
||||
allModels.value
|
||||
.filter(m => m.type === 'ASR')
|
||||
.map(convertToLegacyFormat)
|
||||
)
|
||||
|
||||
// 将后端模型格式转换为旧的前端格式
|
||||
function convertToLegacyFormat(model: ModelConfig) {
|
||||
return {
|
||||
@@ -306,14 +360,14 @@ const loadModels = async () => {
|
||||
}
|
||||
|
||||
// 打开添加对话框
|
||||
const openAddDialog = (type: 'chat' | 'embedding' | 'rerank' | 'vllm') => {
|
||||
const openAddDialog = (type: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr') => {
|
||||
currentModelType.value = type
|
||||
editingModel.value = null
|
||||
showDialog.value = true
|
||||
}
|
||||
|
||||
// 编辑模型
|
||||
const editModel = (type: 'chat' | 'embedding' | 'rerank' | 'vllm', model: any) => {
|
||||
const editModel = (type: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr', model: any) => {
|
||||
// 内置模型不能编辑
|
||||
if (model.isBuiltin) {
|
||||
MessagePlugin.warning(t('modelSettings.toasts.builtinCannotEdit'))
|
||||
@@ -405,7 +459,7 @@ const handleModelSave = async (modelData: any) => {
|
||||
}
|
||||
|
||||
// 删除模型
|
||||
const deleteModel = async (type: 'chat' | 'embedding' | 'rerank' | 'vllm', modelId: string) => {
|
||||
const deleteModel = async (type: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr', modelId: string) => {
|
||||
// 检查是否是内置模型
|
||||
const model = allModels.value.find(m => m.id === modelId)
|
||||
if (model?.is_builtin) {
|
||||
@@ -425,7 +479,7 @@ const deleteModel = async (type: 'chat' | 'embedding' | 'rerank' | 'vllm', model
|
||||
}
|
||||
|
||||
// 获取模型操作菜单选项
|
||||
const getModelOptions = (type: 'chat' | 'embedding' | 'rerank' | 'vllm', model: any) => {
|
||||
const getModelOptions = (type: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr', model: any) => {
|
||||
const options: any[] = []
|
||||
|
||||
// 内置模型不能编辑和删除
|
||||
@@ -450,7 +504,7 @@ const getModelOptions = (type: 'chat' | 'embedding' | 'rerank' | 'vllm', model:
|
||||
}
|
||||
|
||||
// 处理菜单操作
|
||||
const handleMenuAction = (data: { value: string }, type: 'chat' | 'embedding' | 'rerank' | 'vllm', model: any) => {
|
||||
const handleMenuAction = (data: { value: string }, type: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr', model: any) => {
|
||||
const value = data.value
|
||||
|
||||
if (value.indexOf('edit-') === 0) {
|
||||
@@ -464,12 +518,13 @@ const handleMenuAction = (data: { value: string }, type: 'chat' | 'embedding' |
|
||||
}
|
||||
|
||||
// 获取后端模型类型
|
||||
function getModelType(type: 'chat' | 'embedding' | 'rerank' | 'vllm'): 'KnowledgeQA' | 'Embedding' | 'Rerank' | 'VLLM' {
|
||||
function getModelType(type: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'): 'KnowledgeQA' | 'Embedding' | 'Rerank' | 'VLLM' | 'ASR' {
|
||||
const typeMap = {
|
||||
chat: 'KnowledgeQA' as const,
|
||||
embedding: 'Embedding' as const,
|
||||
rerank: 'Rerank' as const,
|
||||
vllm: 'VLLM' as const
|
||||
vllm: 'VLLM' as const,
|
||||
asr: 'ASR' as const
|
||||
}
|
||||
return typeMap[type]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user