feat:create cusotm text dataset
This commit is contained in:
@@ -552,8 +552,8 @@ const CreateDataset = () => {
|
|||||||
{rechunkFileIds.length > 0 ? (
|
{rechunkFileIds.length > 0 ? (
|
||||||
<Table
|
<Table
|
||||||
ref={tableRef}
|
ref={tableRef}
|
||||||
apiUrl={`/documents/${knowledgeBaseId}/${parentId}/documents`}
|
apiUrl={`/documents/${knowledgeBaseId}/documents`}
|
||||||
apiParams={{
|
apiParams={{
|
||||||
document_ids: rechunkFileIds.join(','),
|
document_ids: rechunkFileIds.join(','),
|
||||||
}}
|
}}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
|||||||
@@ -605,6 +605,7 @@ const Private: FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleRefreshTable = () => {
|
const handleRefreshTable = () => {
|
||||||
|
debugger
|
||||||
// 刷新表格数据
|
// 刷新表格数据
|
||||||
tableRef.current?.loadData();
|
tableRef.current?.loadData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { Form, Input } from 'antd';
|
import { Form, Input } from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import RbModal from '@/components/RbModal';
|
import RbModal from '@/components/RbModal';
|
||||||
@@ -12,6 +14,7 @@ interface ContentFormData {
|
|||||||
const CreateContentModal = forwardRef<CreateSetModalRef, CreateSetMoealRefProps>(
|
const CreateContentModal = forwardRef<CreateSetModalRef, CreateSetMoealRefProps>(
|
||||||
({ refreshTable }, ref) => {
|
({ refreshTable }, ref) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const navigate = useNavigate();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [form] = Form.useForm<ContentFormData>();
|
const [form] = Form.useForm<ContentFormData>();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -45,13 +48,11 @@ const CreateContentModal = forwardRef<CreateSetModalRef, CreateSetMoealRefProps>
|
|||||||
parent_id: parentId,
|
parent_id: parentId,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 模拟API调用
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
||||||
await createDocumentAndUpload(values, params)
|
|
||||||
if (refreshTable) {
|
|
||||||
await refreshTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const response = await createDocumentAndUpload(values, params)
|
||||||
|
if(response){
|
||||||
|
handleChunking(response.kb_id,parentId,response.id)
|
||||||
|
}
|
||||||
handleClose();
|
handleClose();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('创建内容失败:', err);
|
console.error('创建内容失败:', err);
|
||||||
@@ -59,7 +60,19 @@ const CreateContentModal = forwardRef<CreateSetModalRef, CreateSetMoealRefProps>
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const handleChunking = (kb_id: string, parent_id: string, file_id: string) => {
|
||||||
|
if (!kb_id) return;
|
||||||
|
const targetFileId = file_id
|
||||||
|
navigate(`/knowledge-base/${kb_id}/create-dataset`, {
|
||||||
|
state: {
|
||||||
|
source: 'local',
|
||||||
|
knowledgeBaseId: kb_id,
|
||||||
|
parentId: parent_id ?? kb_id,
|
||||||
|
startStep: 'parameterSettings',
|
||||||
|
fileId: targetFileId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
handleOpen,
|
handleOpen,
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user