Skip to content

Commit

Permalink
feat: If the tts model is not set, the Text to Speech switch is not a…
Browse files Browse the repository at this point in the history
…llowed to be turned on infiniflow#1877
  • Loading branch information
cike8899 committed Sep 14, 2024
1 parent 2c05e6e commit f34a1cc
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx
Original file line number Diff line number Diff line change
@@ -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)) {
Expand All @@ -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 />
Expand Down Expand Up @@ -106,7 +120,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
tooltip={t('ttsTip')}
initialValue={false}
>
<Switch />
<Switch onChange={handleTtsChange} />
</Form.Item>
<KnowledgeBaseItem></KnowledgeBaseItem>
</section>
Expand Down

0 comments on commit f34a1cc

Please sign in to comment.