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:
@@ -81,6 +81,11 @@ export interface KBModelConfigRequest {
|
||||
enabled: boolean
|
||||
model_id?: string
|
||||
}
|
||||
asr_config?: {
|
||||
enabled: boolean
|
||||
model_id?: string
|
||||
language?: string
|
||||
}
|
||||
documentSplitting: {
|
||||
chunkSize: number
|
||||
chunkOverlap: number
|
||||
|
||||
@@ -21,6 +21,11 @@ export function createKnowledgeBase(data: {
|
||||
};
|
||||
storage_provider_config?: { provider: string };
|
||||
storage_config?: any; // legacy, kept for backward compat (dual-write)
|
||||
asr_config?: {
|
||||
enabled: boolean;
|
||||
model_id?: string;
|
||||
language?: string;
|
||||
};
|
||||
extract_config?: any;
|
||||
faq_config?: { index_mode: string; question_index_mode?: string };
|
||||
}) {
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface ModelConfig {
|
||||
id?: string;
|
||||
tenant_id?: number;
|
||||
name: string;
|
||||
type: 'KnowledgeQA' | 'Embedding' | 'Rerank' | 'VLLM';
|
||||
type: 'KnowledgeQA' | 'Embedding' | 'Rerank' | 'VLLM' | 'ASR';
|
||||
source: 'local' | 'remote';
|
||||
description?: string;
|
||||
parameters: {
|
||||
|
||||
@@ -280,7 +280,7 @@ interface ModelFormData {
|
||||
|
||||
interface Props {
|
||||
visible: boolean
|
||||
modelType: 'chat' | 'embedding' | 'rerank' | 'vllm'
|
||||
modelType: 'chat' | 'embedding' | 'rerank' | 'vllm' | 'asr'
|
||||
modelData?: ModelFormData | null
|
||||
}
|
||||
|
||||
@@ -303,29 +303,31 @@ const loadingProviders = ref(false)
|
||||
|
||||
// 硬编码的后备 Provider 配置 (当 API 不可用时使用)
|
||||
const fallbackProviderOptions = computed(() => [
|
||||
{
|
||||
value: 'openai',
|
||||
label: t('model.editor.providers.openai.label'),
|
||||
{
|
||||
value: 'openai',
|
||||
label: t('model.editor.providers.openai.label'),
|
||||
defaultUrls: {
|
||||
chat: 'https://api.openai.com/v1',
|
||||
embedding: 'https://api.openai.com/v1',
|
||||
rerank: 'https://api.openai.com/v1',
|
||||
vllm: 'https://api.openai.com/v1'
|
||||
vllm: 'https://api.openai.com/v1',
|
||||
asr: 'https://api.openai.com/v1'
|
||||
},
|
||||
description: t('model.editor.providers.openai.description'),
|
||||
modelTypes: ['chat', 'embedding', 'vllm']
|
||||
modelTypes: ['chat', 'embedding', 'vllm', 'asr']
|
||||
},
|
||||
{
|
||||
value: 'aliyun',
|
||||
label: t('model.editor.providers.aliyun.label'),
|
||||
{
|
||||
value: 'aliyun',
|
||||
label: t('model.editor.providers.aliyun.label'),
|
||||
defaultUrls: {
|
||||
chat: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
||||
embedding: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
||||
rerank: 'https://dashscope.aliyuncs.com/api/v1/services/rerank/text-rerank/text-rerank',
|
||||
vllm: 'https://dashscope.aliyuncs.com/compatible-mode/v1'
|
||||
vllm: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
||||
asr: 'https://dashscope.aliyuncs.com/compatible-mode/v1'
|
||||
},
|
||||
description: t('model.editor.providers.aliyun.description'),
|
||||
modelTypes: ['chat', 'embedding', 'rerank', 'vllm']
|
||||
modelTypes: ['chat', 'embedding', 'rerank', 'vllm', 'asr']
|
||||
},
|
||||
{
|
||||
value: 'zhipu',
|
||||
@@ -394,10 +396,10 @@ const fallbackProviderOptions = computed(() => [
|
||||
},
|
||||
{
|
||||
value: 'generic',
|
||||
label: t('model.editor.providers.generic.label'),
|
||||
label: t('model.editor.providers.generic.label'),
|
||||
defaultUrls: {},
|
||||
description: t('model.editor.providers.generic.description'),
|
||||
modelTypes: ['chat', 'embedding', 'rerank', 'vllm']
|
||||
modelTypes: ['chat', 'embedding', 'rerank', 'vllm', 'asr']
|
||||
},
|
||||
])
|
||||
|
||||
@@ -536,15 +538,22 @@ const getModelNamePlaceholder = () => {
|
||||
? t('model.editor.modelNamePlaceholder.localVllm')
|
||||
: t('model.editor.modelNamePlaceholder.remoteVllm')
|
||||
}
|
||||
if (props.modelType === 'asr') {
|
||||
return t('model.editor.modelNamePlaceholder.remoteAsr')
|
||||
}
|
||||
return formData.value.source === 'local'
|
||||
? t('model.editor.modelNamePlaceholder.local')
|
||||
: t('model.editor.modelNamePlaceholder.remote')
|
||||
}
|
||||
|
||||
const getBaseUrlPlaceholder = () => {
|
||||
return props.modelType === 'vllm'
|
||||
? t('model.editor.baseUrlPlaceholderVllm')
|
||||
: t('model.editor.baseUrlPlaceholder')
|
||||
if (props.modelType === 'vllm') {
|
||||
return t('model.editor.baseUrlPlaceholderVllm')
|
||||
}
|
||||
if (props.modelType === 'asr') {
|
||||
return t('model.editor.baseUrlPlaceholderAsr')
|
||||
}
|
||||
return t('model.editor.baseUrlPlaceholder')
|
||||
}
|
||||
|
||||
// 检查Ollama服务状态
|
||||
@@ -840,7 +849,17 @@ const checkRemoteAPI = async () => {
|
||||
apiKey: formData.value.apiKey || ''
|
||||
})
|
||||
break
|
||||
|
||||
|
||||
case 'asr':
|
||||
// ASR 模型(语音识别)
|
||||
// ASR 使用 checkRemoteModel 进行基础连接测试
|
||||
result = await checkRemoteModel({
|
||||
modelName: formData.value.modelName,
|
||||
baseUrl: formData.value.baseUrl,
|
||||
apiKey: formData.value.apiKey || ''
|
||||
})
|
||||
break
|
||||
|
||||
default:
|
||||
MessagePlugin.error(t('model.editor.unsupportedModelType'))
|
||||
return
|
||||
|
||||
@@ -46,7 +46,7 @@ import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
interface Props {
|
||||
modelType: 'KnowledgeQA' | 'Embedding' | 'Rerank' | 'VLLM'
|
||||
modelType: 'KnowledgeQA' | 'Embedding' | 'Rerank' | 'VLLM' | 'ASR'
|
||||
selectedModelId?: string
|
||||
disabled?: boolean
|
||||
placeholder?: string
|
||||
|
||||
@@ -1471,6 +1471,7 @@ export default {
|
||||
graph: 'Knowledge Graph',
|
||||
multimodal: 'Multimodal',
|
||||
datasource: 'Data Sources',
|
||||
asr: 'Speech Recognition',
|
||||
share: 'Sharing'
|
||||
},
|
||||
basic: {
|
||||
@@ -1676,6 +1677,15 @@ export default {
|
||||
title: 'Multimodal Configuration',
|
||||
description: 'Configure multimodal content understanding for parsing and retrieving non-text content like images',
|
||||
},
|
||||
asr: {
|
||||
title: 'Speech Recognition Configuration',
|
||||
description: 'Configure speech recognition to upload audio files (mp3, wav, m4a, flac, ogg) and automatically transcribe to text',
|
||||
label: 'Enable Speech Recognition',
|
||||
desc: 'When enabled, audio files can be uploaded to the knowledge base and automatically transcribed to text',
|
||||
modelLabel: 'ASR Model',
|
||||
modelDescription: 'Speech-to-text model for audio transcription (e.g. OpenAI Whisper)',
|
||||
modelPlaceholder: 'Select an ASR model',
|
||||
},
|
||||
advanced: {
|
||||
title: 'Advanced Settings',
|
||||
description: 'Configure question generation and other advanced features',
|
||||
@@ -2076,17 +2086,20 @@ export default {
|
||||
embedding: 'Configure embedding models for text vectorization',
|
||||
rerank: 'Configure models for result re-ranking',
|
||||
vllm: 'Configure vision-language models for multimodal understanding',
|
||||
asr: 'Configure speech-to-text models for audio transcription',
|
||||
default: 'Configure model information'
|
||||
},
|
||||
modelNamePlaceholder: {
|
||||
local: 'e.g. llama2:latest',
|
||||
remote: 'e.g. gpt-4, claude-3-opus',
|
||||
localVllm: 'e.g. llava:latest',
|
||||
remoteVllm: 'e.g. gpt-4-vision-preview'
|
||||
remoteVllm: 'e.g. gpt-4-vision-preview',
|
||||
remoteAsr: 'e.g. whisper-1'
|
||||
},
|
||||
baseUrlLabel: 'Base URL',
|
||||
baseUrlPlaceholder: 'e.g. https://api.openai.com/v1',
|
||||
baseUrlPlaceholderVllm: 'e.g. http://localhost:11434/v1',
|
||||
baseUrlPlaceholderAsr: 'e.g. https://api.openai.com/v1',
|
||||
apiKeyOptional: 'API Key (optional)',
|
||||
apiKeyPlaceholder: 'Enter API Key',
|
||||
connectionTest: 'Connection Test',
|
||||
@@ -2582,6 +2595,11 @@ export default {
|
||||
desc: 'Configure vision-language models for multimodal understanding',
|
||||
empty: 'No VLLM models'
|
||||
},
|
||||
asr: {
|
||||
title: 'ASR Speech Models',
|
||||
desc: 'Configure speech-to-text models for audio transcription (e.g. OpenAI Whisper)',
|
||||
empty: 'No ASR models'
|
||||
},
|
||||
toasts: {
|
||||
nameRequired: 'Model name cannot be empty',
|
||||
nameTooLong: 'Model name cannot exceed 100 characters',
|
||||
|
||||
@@ -1534,6 +1534,7 @@ export default {
|
||||
embedding: "텍스트 벡터화용 임베딩 모델 설정",
|
||||
rerank: "결과 재정렬용 모델 설정",
|
||||
vllm: "시각 이해 및 멀티모달용 비전 언어 모델 설정",
|
||||
asr: "음성 인식 및 오디오 전사를 위한 음성 인식 모델 설정",
|
||||
default: "모델 정보 설정",
|
||||
},
|
||||
modelNamePlaceholder: {
|
||||
@@ -1541,10 +1542,12 @@ export default {
|
||||
remote: "예: gpt-4, claude-3-opus",
|
||||
localVllm: "예: llava:latest",
|
||||
remoteVllm: "예: gpt-4-vision-preview",
|
||||
remoteAsr: "예: whisper-1",
|
||||
},
|
||||
baseUrlLabel: "Base URL",
|
||||
baseUrlPlaceholder: "예: https://api.openai.com/v1",
|
||||
baseUrlPlaceholderVllm: "예: http://localhost:11434/v1",
|
||||
baseUrlPlaceholderAsr: "예: https://api.openai.com/v1",
|
||||
apiKeyOptional: "API 키 (선택)",
|
||||
apiKeyPlaceholder: "API 키 입력",
|
||||
connectionTest: "연결 테스트",
|
||||
@@ -1955,6 +1958,7 @@ export default {
|
||||
faq: "FAQ 설정",
|
||||
graph: "지식 그래프",
|
||||
multimodal: "멀티모달",
|
||||
asr: "음성 인식",
|
||||
share: "공유관리",
|
||||
storage: "스토리지 엔진",
|
||||
datasource: "데이터 소스",
|
||||
@@ -2170,7 +2174,16 @@ export default {
|
||||
},
|
||||
multimodal: {
|
||||
title: "멀티모달 설정",
|
||||
description: "멀티모달 콘텐츠 이해 기능을 설정합니다. 활성화하면 이미지 등 텍스트가 아닌 콘텐츠의 파싱 및 검색을 지원합니다.",
|
||||
description: "멀티모달 콘텐츠 이해 기능을 설정하여 이미지 등 비텍스트 콘텐츠의 파싱 및 검색을 지원합니다",
|
||||
},
|
||||
asr: {
|
||||
title: "음성 인식 설정",
|
||||
description: "음성 인식 기능을 설정하여 오디오 파일(mp3, wav, m4a, flac, ogg)을 업로드하고 자동으로 텍스트로 전사합니다",
|
||||
label: "음성 인식 활성화",
|
||||
desc: "활성화하면 오디오 파일을 지식베이스에 업로드하고 자동으로 텍스트로 전사할 수 있습니다",
|
||||
modelLabel: "ASR 모델",
|
||||
modelDescription: "오디오 전사를 위한 음성 인식 모델 (예: OpenAI Whisper)",
|
||||
modelPlaceholder: "ASR 모델을 선택해주세요",
|
||||
},
|
||||
advanced: {
|
||||
title: "고급 설정",
|
||||
@@ -2615,6 +2628,11 @@ export default {
|
||||
desc: "시각 이해 및 멀티모달용 비전 언어 모델 설정",
|
||||
empty: "VLLM 비전 모델 없음",
|
||||
},
|
||||
asr: {
|
||||
title: "ASR 음성 모델",
|
||||
desc: "음성 인식 및 오디오 전사를 위한 음성 인식 모델 설정 (예: OpenAI Whisper)",
|
||||
empty: "ASR 음성 모델 없음",
|
||||
},
|
||||
toasts: {
|
||||
nameRequired: "모델 이름은 비워둘 수 없습니다",
|
||||
nameTooLong: "모델 이름은 100자를 초과할 수 없습니다",
|
||||
|
||||
@@ -1381,17 +1381,20 @@ export default {
|
||||
embedding: 'Настройте модель встраивания для текстовой векторизации',
|
||||
rerank: 'Настройте модель для повторного ранжирования результатов',
|
||||
vllm: 'Настройте визуально-языковую модель для мультимодального понимания',
|
||||
asr: 'Настройте модель распознавания речи для транскрибации аудио',
|
||||
default: 'Настройте информацию о модели'
|
||||
},
|
||||
modelNamePlaceholder: {
|
||||
local: 'например: llama2:latest',
|
||||
remote: 'например: gpt-4, claude-3-opus',
|
||||
localVllm: 'например: llava:latest',
|
||||
remoteVllm: 'например: gpt-4-vision-preview'
|
||||
remoteVllm: 'например: gpt-4-vision-preview',
|
||||
remoteAsr: 'например: whisper-1'
|
||||
},
|
||||
baseUrlLabel: 'Base URL',
|
||||
baseUrlPlaceholder: 'например: https://api.openai.com/v1',
|
||||
baseUrlPlaceholderVllm: 'например: http://localhost:11434/v1',
|
||||
baseUrlPlaceholderAsr: 'например: https://api.openai.com/v1',
|
||||
apiKeyOptional: 'API Key (опционально)',
|
||||
apiKeyPlaceholder: 'Введите API Key',
|
||||
connectionTest: 'Проверка соединения',
|
||||
@@ -1641,6 +1644,7 @@ export default {
|
||||
faq: 'FAQ настройки',
|
||||
graph: 'Граф знаний',
|
||||
multimodal: 'Мультимодальность',
|
||||
asr: 'Распознавание речи',
|
||||
storage: 'Storage Engine',
|
||||
datasource: 'Источники данных',
|
||||
share: 'Sharing'
|
||||
@@ -1836,7 +1840,16 @@ export default {
|
||||
},
|
||||
multimodal: {
|
||||
title: 'Мультимодальная конфигурация',
|
||||
description: 'Настройка понимания мультимодального контента для парсинга и поиска нетекстового содержимого, такого как изображения',
|
||||
description: 'Настройте мультимодальное понимание контента для парсинга и поиска нетекстового контента, например изображений',
|
||||
},
|
||||
asr: {
|
||||
title: 'Конфигурация распознавания речи',
|
||||
description: 'Настройте распознавание речи для загрузки аудиофайлов (mp3, wav, m4a, flac, ogg) и автоматической транскрибации в текст',
|
||||
label: 'Включить распознавание речи',
|
||||
desc: 'При включении аудиофайлы могут быть загружены в базу знаний и автоматически транскрибированы в текст',
|
||||
modelLabel: 'Модель ASR',
|
||||
modelDescription: 'Модель распознавания речи для транскрибации аудио (например, OpenAI Whisper)',
|
||||
modelPlaceholder: 'Выберите модель ASR',
|
||||
},
|
||||
advanced: {
|
||||
title: 'Расширенные настройки',
|
||||
@@ -2380,6 +2393,11 @@ export default {
|
||||
desc: 'Визуально-языковые модели для мультимодального понимания',
|
||||
empty: 'Нет VLLM моделей'
|
||||
},
|
||||
asr: {
|
||||
title: 'ASR модели речи',
|
||||
desc: 'Модели распознавания речи для транскрибации аудио (например, OpenAI Whisper)',
|
||||
empty: 'Нет ASR моделей'
|
||||
},
|
||||
toasts: {
|
||||
nameRequired: 'Название модели не может быть пустым',
|
||||
nameTooLong: 'Название модели не может превышать 100 символов',
|
||||
|
||||
@@ -1528,6 +1528,7 @@ export default {
|
||||
embedding: "配置用于文本向量化的嵌入模型",
|
||||
rerank: "配置用于结果重排序的模型",
|
||||
vllm: "配置用于视觉理解和多模态的视觉语言模型",
|
||||
asr: "配置用于语音识别和音频转录的语音转文本模型",
|
||||
default: "配置模型信息",
|
||||
},
|
||||
modelNamePlaceholder: {
|
||||
@@ -1535,10 +1536,12 @@ export default {
|
||||
remote: "例如:gpt-4, claude-3-opus",
|
||||
localVllm: "例如:llava:latest",
|
||||
remoteVllm: "例如:gpt-4-vision-preview",
|
||||
remoteAsr: "例如:whisper-1",
|
||||
},
|
||||
baseUrlLabel: "Base URL",
|
||||
baseUrlPlaceholder: "例如:https://api.openai.com/v1",
|
||||
baseUrlPlaceholderVllm: "例如:http://localhost:11434/v1",
|
||||
baseUrlPlaceholderAsr: "例如:https://api.openai.com/v1",
|
||||
apiKeyOptional: "API Key(可选)",
|
||||
apiKeyPlaceholder: "输入 API Key",
|
||||
connectionTest: "连接测试",
|
||||
@@ -1943,6 +1946,7 @@ export default {
|
||||
graph: "知识图谱",
|
||||
multimodal: "多模态",
|
||||
datasource: "数据源",
|
||||
asr: "语音识别",
|
||||
share: "共享管理",
|
||||
},
|
||||
basic: {
|
||||
@@ -2145,6 +2149,15 @@ export default {
|
||||
title: "多模态配置",
|
||||
description: "配置多模态内容理解能力,启用后支持图片等非文本内容的解析和检索",
|
||||
},
|
||||
asr: {
|
||||
title: "语音识别配置",
|
||||
description: "配置语音识别功能,启用后支持上传音频文件(mp3、wav、m4a、flac、ogg)并自动转录为文本",
|
||||
label: "启用语音识别",
|
||||
desc: "启用后可以上传音频文件到知识库,系统将自动转录为文本进行处理",
|
||||
modelLabel: "ASR 模型",
|
||||
modelDescription: "用于语音转文本的语音识别模型(如 OpenAI Whisper)",
|
||||
modelPlaceholder: "请选择 ASR 模型",
|
||||
},
|
||||
advanced: {
|
||||
title: "高级设置",
|
||||
description: "配置问题生成等高级功能",
|
||||
@@ -2580,6 +2593,11 @@ export default {
|
||||
desc: "配置用于视觉理解和多模态的视觉语言模型",
|
||||
empty: "暂无 VLLM 视觉模型",
|
||||
},
|
||||
asr: {
|
||||
title: "ASR 语音模型",
|
||||
desc: "配置用于语音识别和音频转录的语音转文本模型(如 OpenAI Whisper)",
|
||||
empty: "暂无 ASR 语音模型",
|
||||
},
|
||||
toasts: {
|
||||
nameRequired: "模型名称不能为空",
|
||||
nameTooLong: "模型名称不能超过100个字符",
|
||||
|
||||
@@ -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