Sfoglia il codice sorgente

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)
tags/v0.11.0
balibabu 1 anno fa
parent
commit
3b1375ef99
Nessun account collegato all'indirizzo email del committer

+ 17
- 3
web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx Vedi File

import { PlusOutlined } from '@ant-design/icons'; 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 classNames from 'classnames';
import { ISegmentedContentProps } from '../interface'; import { ISegmentedContentProps } from '../interface';


import KnowledgeBaseItem from '@/components/knowledge-base-item'; import KnowledgeBaseItem from '@/components/knowledge-base-item';
import { useTranslate } from '@/hooks/common-hooks'; import { useTranslate } from '@/hooks/common-hooks';
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
import { useCallback } from 'react';
import styles from './index.less'; import styles from './index.less';


const AssistantSetting = ({ show }: ISegmentedContentProps) => {
const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
const { t } = useTranslate('chat'); const { t } = useTranslate('chat');
const { data } = useFetchTenantInfo();


const normFile = (e: any) => { const normFile = (e: any) => {
if (Array.isArray(e)) { if (Array.isArray(e)) {
return e?.fileList; 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 = ( const uploadButtion = (
<button style={{ border: 0, background: 'none' }} type="button"> <button style={{ border: 0, background: 'none' }} type="button">
<PlusOutlined /> <PlusOutlined />
tooltip={t('ttsTip')} tooltip={t('ttsTip')}
initialValue={false} initialValue={false}
> >
<Switch />
<Switch onChange={handleTtsChange} />
</Form.Item> </Form.Item>
<KnowledgeBaseItem></KnowledgeBaseItem> <KnowledgeBaseItem></KnowledgeBaseItem>
</section> </section>

Loading…
Annulla
Salva