mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Chat without KB. #5216 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,18 +1,40 @@
|
||||
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 { PlusOutlined } from '@ant-design/icons';
|
||||
import { Form, Input, message, Select, Switch, Upload } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import { useCallback } from 'react';
|
||||
import { ISegmentedContentProps } from '../interface';
|
||||
|
||||
import styles from './index.less';
|
||||
|
||||
const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
|
||||
const emptyResponseField = ['prompt_config', 'empty_response'];
|
||||
|
||||
const AssistantSetting = ({
|
||||
show,
|
||||
form,
|
||||
setHasError,
|
||||
}: ISegmentedContentProps) => {
|
||||
const { t } = useTranslate('chat');
|
||||
const { data } = useFetchTenantInfo(true);
|
||||
|
||||
const handleChange = useCallback(() => {
|
||||
const kbIds = form.getFieldValue('kb_ids');
|
||||
const emptyResponse = form.getFieldValue(emptyResponseField);
|
||||
|
||||
const required =
|
||||
emptyResponse && ((Array.isArray(kbIds) && kbIds.length === 0) || !kbIds);
|
||||
|
||||
setHasError(required);
|
||||
form.setFields([
|
||||
{
|
||||
name: emptyResponseField,
|
||||
errors: required ? [t('emptyResponseMessage')] : [],
|
||||
},
|
||||
]);
|
||||
}, [form, setHasError, t]);
|
||||
|
||||
const normFile = (e: any) => {
|
||||
if (Array.isArray(e)) {
|
||||
return e;
|
||||
@ -31,7 +53,7 @@ const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
|
||||
[data, form],
|
||||
);
|
||||
|
||||
const uploadButtion = (
|
||||
const uploadButton = (
|
||||
<button style={{ border: 0, background: 'none' }} type="button">
|
||||
<PlusOutlined />
|
||||
<div style={{ marginTop: 8 }}>{t('upload', { keyPrefix: 'common' })}</div>
|
||||
@ -66,7 +88,7 @@ const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
|
||||
beforeUpload={() => false}
|
||||
showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
|
||||
>
|
||||
{show ? uploadButtion : null}
|
||||
{show ? uploadButton : null}
|
||||
</Upload>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
@ -84,11 +106,11 @@ const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name={['prompt_config', 'empty_response']}
|
||||
name={emptyResponseField}
|
||||
label={t('emptyResponse')}
|
||||
tooltip={t('emptyResponseTip')}
|
||||
>
|
||||
<Input placeholder="" />
|
||||
<Input placeholder="" onChange={handleChange} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name={['prompt_config', 'prologue']}
|
||||
@ -116,15 +138,6 @@ const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
|
||||
>
|
||||
<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"
|
||||
@ -134,7 +147,10 @@ const AssistantSetting = ({ show, form }: ISegmentedContentProps) => {
|
||||
>
|
||||
<Switch onChange={handleTtsChange} />
|
||||
</Form.Item>
|
||||
<KnowledgeBaseItem></KnowledgeBaseItem>
|
||||
<KnowledgeBaseItem
|
||||
required={false}
|
||||
onChange={handleChange}
|
||||
></KnowledgeBaseItem>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user