File size: 3,733 Bytes
e55650e e536bf7 452020d 058cd84 452020d be99f83 68ed806 e536bf7 452020d e536bf7 88e5a61 e536bf7 8c4ec99 3054c20 e536bf7 447b19b 48dcb0f 447b19b 452020d 88e5a61 7c07000 452020d 7c07000 452020d 3054c20 88e5a61 3054c20 48dcb0f 3054c20 447b19b 3054c20 452020d 84f80c5 88e5a61 0957ae0 84f80c5 88e5a61 84f80c5 8c4ec99 88e5a61 8c4ec99 88e5a61 8c4ec99 452020d ae21b62 88e5a61 ae21b62 452020d b916b29 f9e19e4 2df5d5b e08f767 2df5d5b f9e19e4 7b381b0 8ee6bdd e536bf7 7b381b0 be99f83 452020d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
import { PlusOutlined } from '@ant-design/icons';
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, form }: ISegmentedContentProps) => {
const { t } = useTranslate('chat');
const { data } = useFetchTenantInfo();
const normFile = (e: any) => {
if (Array.isArray(e)) {
return e;
}
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 />
<div style={{ marginTop: 8 }}>{t('upload', { keyPrefix: 'common' })}</div>
</button>
);
return (
<section
className={classNames({
[styles.segmentedHidden]: !show,
})}
>
<Form.Item
name={'name'}
label={t('assistantName')}
rules={[{ required: true, message: t('assistantNameMessage') }]}
>
<Input placeholder={t('namePlaceholder')} />
</Form.Item>
<Form.Item
name="icon"
label={t('assistantAvatar')}
valuePropName="fileList"
getValueFromEvent={normFile}
>
<Upload
listType="picture-card"
maxCount={1}
beforeUpload={() => false}
showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
>
{show ? uploadButtion : null}
</Upload>
</Form.Item>
<Form.Item
name={'language'}
label={t('language')}
initialValue={'English'}
tooltip="coming soon"
style={{ display: 'none' }}
>
<Select
options={[
{ value: 'Chinese', label: t('chinese', { keyPrefix: 'common' }) },
{ value: 'English', label: t('english', { keyPrefix: 'common' }) },
]}
/>
</Form.Item>
<Form.Item
name={['prompt_config', 'empty_response']}
label={t('emptyResponse')}
tooltip={t('emptyResponseTip')}
>
<Input placeholder="" />
</Form.Item>
<Form.Item
name={['prompt_config', 'prologue']}
label={t('setAnOpener')}
tooltip={t('setAnOpenerTip')}
initialValue={t('setAnOpenerInitial')}
>
<Input.TextArea autoSize={{ minRows: 5 }} />
</Form.Item>
<Form.Item
label={t('quote')}
valuePropName="checked"
name={['prompt_config', 'quote']}
tooltip={t('quoteTip')}
initialValue={true}
>
<Switch />
</Form.Item>
{/* <Form.Item
label={t('selfRag')}
valuePropName="checked"
name={['prompt_config', 'self_rag']}
tooltip={t('selfRagTip')}
initialValue={false}
>
<Switch />
</Form.Item> */}
<Form.Item
label={t('tts')}
valuePropName="checked"
name={['prompt_config', 'tts']}
tooltip={t('ttsTip')}
initialValue={false}
>
<Switch onChange={handleTtsChange} />
</Form.Item>
<KnowledgeBaseItem></KnowledgeBaseItem>
</section>
);
};
export default AssistantSetting;
|