balibabu
commited on
Commit
·
e536bf7
1
Parent(s):
642f6fd
feat: If the tts model is not set, the Text to Speech switch is not allowed to be turned on #1877 (#2446)
Browse files### 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)
web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx
CHANGED
@@ -1,14 +1,17 @@
|
|
1 |
import { PlusOutlined } from '@ant-design/icons';
|
2 |
-
import { Form, Input, Select, Switch, Upload } from 'antd';
|
3 |
import classNames from 'classnames';
|
4 |
import { ISegmentedContentProps } from '../interface';
|
5 |
|
6 |
import KnowledgeBaseItem from '@/components/knowledge-base-item';
|
7 |
import { useTranslate } from '@/hooks/common-hooks';
|
|
|
|
|
8 |
import styles from './index.less';
|
9 |
|
10 |
-
const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
11 |
const { t } = useTranslate('chat');
|
|
|
12 |
|
13 |
const normFile = (e: any) => {
|
14 |
if (Array.isArray(e)) {
|
@@ -17,6 +20,17 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
|
17 |
return e?.fileList;
|
18 |
};
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
const uploadButtion = (
|
21 |
<button style={{ border: 0, background: 'none' }} type="button">
|
22 |
<PlusOutlined />
|
@@ -106,7 +120,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
|
106 |
tooltip={t('ttsTip')}
|
107 |
initialValue={false}
|
108 |
>
|
109 |
-
<Switch />
|
110 |
</Form.Item>
|
111 |
<KnowledgeBaseItem></KnowledgeBaseItem>
|
112 |
</section>
|
|
|
1 |
import { PlusOutlined } from '@ant-design/icons';
|
2 |
+
import { Form, Input, message, Select, Switch, Upload } from 'antd';
|
3 |
import classNames from 'classnames';
|
4 |
import { ISegmentedContentProps } from '../interface';
|
5 |
|
6 |
import KnowledgeBaseItem from '@/components/knowledge-base-item';
|
7 |
import { useTranslate } from '@/hooks/common-hooks';
|
8 |
+
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
|
9 |
+
import { useCallback } from 'react';
|
10 |
import styles from './index.less';
|
11 |
|
12 |
+
const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
|
13 |
const { t } = useTranslate('chat');
|
14 |
+
const { data } = useFetchTenantInfo();
|
15 |
|
16 |
const normFile = (e: any) => {
|
17 |
if (Array.isArray(e)) {
|
|
|
20 |
return e?.fileList;
|
21 |
};
|
22 |
|
23 |
+
const handleTtsChange = useCallback(
|
24 |
+
(checked: boolean) => {
|
25 |
+
if (checked && !data.tts_id) {
|
26 |
+
message.error(`Please set TTS model firstly.
|
27 |
+
Setting >> Model Providers >> System model settings`);
|
28 |
+
form.setFieldValue(['prompt_config', 'tts'], false);
|
29 |
+
}
|
30 |
+
},
|
31 |
+
[data, form],
|
32 |
+
);
|
33 |
+
|
34 |
const uploadButtion = (
|
35 |
<button style={{ border: 0, background: 'none' }} type="button">
|
36 |
<PlusOutlined />
|
|
|
120 |
tooltip={t('ttsTip')}
|
121 |
initialValue={false}
|
122 |
>
|
123 |
+
<Switch onChange={handleTtsChange} />
|
124 |
</Form.Item>
|
125 |
<KnowledgeBaseItem></KnowledgeBaseItem>
|
126 |
</section>
|