2024-03-20 11:13:51 +08:00
|
|
|
import { normFile } from '@/utils/fileUtil';
|
2024-03-12 18:58:09 +08:00
|
|
|
import { PlusOutlined } from '@ant-design/icons';
|
2024-02-18 18:18:20 +08:00
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
Divider,
|
2024-03-11 16:13:34 +08:00
|
|
|
Flex,
|
2024-02-18 18:18:20 +08:00
|
|
|
Form,
|
|
|
|
Input,
|
2024-03-11 16:13:34 +08:00
|
|
|
InputNumber,
|
2024-02-18 18:18:20 +08:00
|
|
|
Radio,
|
|
|
|
Select,
|
2024-03-11 16:13:34 +08:00
|
|
|
Slider,
|
2024-02-18 18:18:20 +08:00
|
|
|
Space,
|
2024-03-20 11:13:51 +08:00
|
|
|
Spin,
|
2024-02-18 18:18:20 +08:00
|
|
|
Typography,
|
|
|
|
Upload,
|
|
|
|
} from 'antd';
|
2024-03-20 11:13:51 +08:00
|
|
|
import {
|
|
|
|
useFetchKnowledgeConfigurationOnMount,
|
|
|
|
useSubmitKnowledgeConfiguration,
|
|
|
|
} from './hooks';
|
2024-03-12 18:58:09 +08:00
|
|
|
|
2024-02-18 18:18:20 +08:00
|
|
|
import styles from './index.less';
|
|
|
|
|
|
|
|
const { Title } = Typography;
|
|
|
|
const { Option } = Select;
|
|
|
|
|
|
|
|
const Configuration = () => {
|
2024-03-20 11:13:51 +08:00
|
|
|
const { submitKnowledgeConfiguration, submitLoading } =
|
|
|
|
useSubmitKnowledgeConfiguration();
|
|
|
|
const { form, parserList, embeddingModelOptions, loading } =
|
|
|
|
useFetchKnowledgeConfigurationOnMount();
|
2024-02-18 18:18:20 +08:00
|
|
|
|
|
|
|
const onFinishFailed = (errorInfo: any) => {
|
|
|
|
console.log('Failed:', errorInfo);
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.configurationWrapper}>
|
|
|
|
<Title level={5}>Configuration</Title>
|
|
|
|
<p>Update your knowledge base details especially parsing method here.</p>
|
|
|
|
<Divider></Divider>
|
2024-03-20 11:13:51 +08:00
|
|
|
<Spin spinning={loading}>
|
|
|
|
<Form
|
|
|
|
form={form}
|
|
|
|
name="validateOnly"
|
|
|
|
layout="vertical"
|
|
|
|
autoComplete="off"
|
|
|
|
onFinish={submitKnowledgeConfiguration}
|
|
|
|
onFinishFailed={onFinishFailed}
|
2024-02-18 18:18:20 +08:00
|
|
|
>
|
2024-03-20 11:13:51 +08:00
|
|
|
<Form.Item
|
|
|
|
name="name"
|
|
|
|
label="Knowledge base name"
|
|
|
|
rules={[{ required: true }]}
|
2024-02-18 18:18:20 +08:00
|
|
|
>
|
2024-03-20 11:13:51 +08:00
|
|
|
<Input />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
name="avatar"
|
|
|
|
label="Knowledge base photo"
|
|
|
|
valuePropName="fileList"
|
|
|
|
getValueFromEvent={normFile}
|
|
|
|
>
|
|
|
|
<Upload
|
|
|
|
listType="picture-card"
|
|
|
|
maxCount={1}
|
|
|
|
beforeUpload={() => false}
|
|
|
|
showUploadList={{ showPreviewIcon: false, showRemoveIcon: false }}
|
|
|
|
>
|
|
|
|
<button style={{ border: 0, background: 'none' }} type="button">
|
|
|
|
<PlusOutlined />
|
|
|
|
<div style={{ marginTop: 8 }}>Upload</div>
|
|
|
|
</button>
|
|
|
|
</Upload>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item name="description" label="Description">
|
|
|
|
<Input />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
label="Language"
|
|
|
|
name="language"
|
|
|
|
initialValue={'Chinese'}
|
|
|
|
rules={[{ required: true, message: 'Please input your language!' }]}
|
|
|
|
>
|
|
|
|
<Select placeholder="select your language">
|
|
|
|
<Option value="English">English</Option>
|
|
|
|
<Option value="Chinese">Chinese</Option>
|
|
|
|
</Select>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
name="permission"
|
|
|
|
label="Permissions"
|
2024-03-20 18:20:42 +08:00
|
|
|
tooltip="coming soon"
|
2024-03-20 11:13:51 +08:00
|
|
|
rules={[{ required: true }]}
|
|
|
|
>
|
|
|
|
<Radio.Group>
|
|
|
|
<Radio value="me">Only me</Radio>
|
|
|
|
<Radio value="team">Team</Radio>
|
|
|
|
</Radio.Group>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
name="embd_id"
|
|
|
|
label="Embedding Model"
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
tooltip="xx"
|
|
|
|
>
|
|
|
|
<Select
|
|
|
|
placeholder="Please select a country"
|
|
|
|
options={embeddingModelOptions}
|
|
|
|
></Select>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
name="parser_id"
|
|
|
|
label="Knowledge base category"
|
|
|
|
tooltip="xx"
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
>
|
|
|
|
<Select placeholder="Please select a country">
|
|
|
|
{parserList.map((x) => (
|
|
|
|
<Option value={x.value} key={x.value}>
|
|
|
|
{x.label}
|
|
|
|
</Option>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item noStyle dependencies={['parser_id']}>
|
|
|
|
{({ getFieldValue }) => {
|
|
|
|
const parserId = getFieldValue('parser_id');
|
2024-03-11 16:13:34 +08:00
|
|
|
|
2024-03-20 11:13:51 +08:00
|
|
|
if (parserId === 'naive') {
|
|
|
|
return (
|
|
|
|
<Form.Item label="Chunk token number" tooltip="xxx">
|
|
|
|
<Flex gap={20} align="center">
|
|
|
|
<Flex flex={1}>
|
|
|
|
<Form.Item
|
|
|
|
name={['parser_config', 'chunk_token_num']}
|
|
|
|
noStyle
|
|
|
|
initialValue={128}
|
|
|
|
rules={[
|
|
|
|
{ required: true, message: 'Province is required' },
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
<Slider
|
|
|
|
className={styles.variableSlider}
|
|
|
|
max={2048}
|
|
|
|
/>
|
|
|
|
</Form.Item>
|
|
|
|
</Flex>
|
2024-03-11 16:13:34 +08:00
|
|
|
<Form.Item
|
|
|
|
name={['parser_config', 'chunk_token_num']}
|
|
|
|
noStyle
|
|
|
|
rules={[
|
2024-03-20 11:13:51 +08:00
|
|
|
{ required: true, message: 'Street is required' },
|
2024-03-11 16:13:34 +08:00
|
|
|
]}
|
|
|
|
>
|
2024-03-20 11:13:51 +08:00
|
|
|
<InputNumber
|
|
|
|
className={styles.sliderInputNumber}
|
|
|
|
max={2048}
|
|
|
|
min={0}
|
|
|
|
/>
|
2024-03-11 16:13:34 +08:00
|
|
|
</Form.Item>
|
|
|
|
</Flex>
|
2024-03-20 11:13:51 +08:00
|
|
|
</Form.Item>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}}
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
|
|
|
<div className={styles.buttonWrapper}>
|
|
|
|
<Space>
|
|
|
|
<Button htmlType="reset" size={'middle'}>
|
|
|
|
Cancel
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
htmlType="submit"
|
|
|
|
type="primary"
|
|
|
|
size={'middle'}
|
|
|
|
loading={submitLoading}
|
|
|
|
>
|
|
|
|
Save
|
|
|
|
</Button>
|
|
|
|
</Space>
|
|
|
|
</div>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
</Spin>
|
2024-02-18 18:18:20 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Configuration;
|