mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-20 21:06:54 +08:00
feat: locate the specific location of the document based on the coordinates of the chunk and add Upload to AssistantSetting (#92)
* feat: add Upload to AssistantSetting * feat: locate the specific location of the document based on the coordinates of the chunk
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
import { Form, Input, Select } from 'antd';
|
||||
import { Form, Input, Select, Upload } from 'antd';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { ISegmentedContentProps } from '../interface';
|
||||
|
||||
import { useFetchKnowledgeList } from '@/hooks/knowledgeHook';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import styles from './index.less';
|
||||
|
||||
const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
||||
@ -13,6 +14,13 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
||||
value: x.id,
|
||||
}));
|
||||
|
||||
const normFile = (e: any) => {
|
||||
if (Array.isArray(e)) {
|
||||
return e;
|
||||
}
|
||||
return e?.fileList;
|
||||
};
|
||||
|
||||
return (
|
||||
<section
|
||||
className={classNames({
|
||||
@ -26,8 +34,22 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
||||
>
|
||||
<Input placeholder="e.g. Resume Jarvis" />
|
||||
</Form.Item>
|
||||
<Form.Item name={'icon'} label="Assistant avatar">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="icon"
|
||||
label="Assistant avatar"
|
||||
valuePropName="fileList"
|
||||
getValueFromEvent={normFile}
|
||||
>
|
||||
<Upload
|
||||
listType="picture-card"
|
||||
maxCount={1}
|
||||
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={'language'} label="Language" initialValue={'Chinese'}>
|
||||
<Select
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ReactComponent as ChatConfigurationAtom } from '@/assets/svg/chat-configuration-atom.svg';
|
||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||
import { Divider, Flex, Form, Modal, Segmented } from 'antd';
|
||||
import { Divider, Flex, Form, Modal, Segmented, UploadFile } from 'antd';
|
||||
import { SegmentedValue } from 'antd/es/segmented';
|
||||
import omit from 'lodash/omit';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
@ -67,6 +67,14 @@ const ChatConfigurationModal = ({ visible, hideModal, id }: IProps) => {
|
||||
...excludeUnEnabledVariables(values),
|
||||
]);
|
||||
const emptyResponse = nextValues.prompt_config?.empty_response ?? '';
|
||||
|
||||
const fileList = values.icon;
|
||||
let icon;
|
||||
|
||||
if (Array.isArray(fileList) && fileList.length > 0) {
|
||||
icon = fileList[0].thumbUrl;
|
||||
}
|
||||
|
||||
const finalValues = {
|
||||
dialog_id: id,
|
||||
...nextValues,
|
||||
@ -75,6 +83,7 @@ const ChatConfigurationModal = ({ visible, hideModal, id }: IProps) => {
|
||||
parameters: promptEngineRef.current,
|
||||
empty_response: emptyResponse,
|
||||
},
|
||||
icon,
|
||||
};
|
||||
console.info(promptEngineRef.current);
|
||||
console.info(nextValues);
|
||||
@ -112,7 +121,13 @@ const ChatConfigurationModal = ({ visible, hideModal, id }: IProps) => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue(currentDialog);
|
||||
const icon = currentDialog.icon;
|
||||
let fileList: UploadFile[] = [];
|
||||
|
||||
if (icon) {
|
||||
fileList = [{ uid: '1', name: 'file', thumbUrl: icon, status: 'done' }];
|
||||
}
|
||||
form.setFieldsValue({ ...currentDialog, icon: fileList });
|
||||
}, [currentDialog, form]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user