feat: If the tts model is not set, the Text to Speech switch is not allowed to be turned on #1877 (#2446)

### What problem does this PR solve?

feat: If the tts model is not set, the Text to Speech switch is not
allowed to be turned on #1877

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2024-09-14 17:45:29 +08:00 committed by GitHub
parent 2c05e6e6bd
commit 3b1375ef99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 = (
<button style={{ border: 0, background: 'none' }} type="button">
<PlusOutlined />
@ -106,7 +120,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
tooltip={t('ttsTip')}
initialValue={false}
>
<Switch />
<Switch onChange={handleTtsChange} />
</Form.Item>
<KnowledgeBaseItem></KnowledgeBaseItem>
</section>