From f34a1cc246ab6cd87bdfe14c53ca657877f8ce6c Mon Sep 17 00:00:00 2001 From: bill Date: Sat, 14 Sep 2024 17:44:03 +0800 Subject: [PATCH] feat: If the tts model is not set, the Text to Speech switch is not allowed to be turned on #1877 --- .../assistant-setting.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx index fc0e3f1febe..262fe0bba02 100644 --- a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx @@ -1,14 +1,17 @@ import { PlusOutlined } from '@ant-design/icons'; -import { Form, Input, Select, Switch, Upload } from 'antd'; +import { Form, Input, message, Select, Switch, Upload } from 'antd'; import classNames from 'classnames'; import { ISegmentedContentProps } from '../interface'; import KnowledgeBaseItem from '@/components/knowledge-base-item'; import { useTranslate } from '@/hooks/common-hooks'; +import { useFetchTenantInfo } from '@/hooks/user-setting-hooks'; +import { useCallback } from 'react'; import styles from './index.less'; -const AssistantSetting = ({ show }: ISegmentedContentProps) => { +const AssistantSetting = ({ show, form }: ISegmentedContentProps) => { const { t } = useTranslate('chat'); + const { data } = useFetchTenantInfo(); const normFile = (e: any) => { if (Array.isArray(e)) { @@ -17,6 +20,17 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => { return e?.fileList; }; + const handleTtsChange = useCallback( + (checked: boolean) => { + if (checked && !data.tts_id) { + message.error(`Please set TTS model firstly. + Setting >> Model Providers >> System model settings`); + form.setFieldValue(['prompt_config', 'tts'], false); + } + }, + [data, form], + ); + const uploadButtion = (