You've already forked DataMate
* feat: Update site name to DataMate and refine text for AI data processing * feat: Refactor settings page and implement model access functionality - Created a new ModelAccess component for managing model configurations. - Removed the old Settings component and replaced it with a new SettingsPage component that integrates ModelAccess, SystemConfig, and WebhookConfig. - Added SystemConfig component for managing system settings. - Implemented WebhookConfig component for managing webhook configurations. - Updated API functions for model management in settings.apis.ts. - Adjusted routing to point to the new SettingsPage component. * feat: Implement Data Collection Page with Task Management and Execution Log - Created DataCollectionPage component to manage data collection tasks. - Added TaskManagement and ExecutionLog components for task handling and logging. - Integrated task operations including start, stop, edit, and delete functionalities. - Implemented filtering and searching capabilities in task management. - Introduced SimpleCronScheduler for scheduling tasks with cron expressions. - Updated CreateTask component to utilize new scheduling and template features. - Enhanced BasicInformation component to conditionally render fields based on visibility settings. - Refactored ImportConfiguration component to remove NAS import section. * feat: Update task creation API endpoint and enhance task creation form with new fields and validation * Refactor file upload and operator management components - Removed unnecessary console logs from file download and export functions. - Added size property to TaskItem interface for better task management. - Simplified TaskUpload component by utilizing useFileSliceUpload hook for file upload logic. - Enhanced OperatorPluginCreate component to handle file uploads and parsing more efficiently. - Updated ConfigureStep component to use Ant Design Form for better data handling and validation. - Improved PreviewStep component to navigate back to the operator market. - Added support for additional file types in UploadStep component. - Implemented delete operator functionality in OperatorMarketPage with confirmation prompts. - Cleaned up unused API functions in operator.api.ts to streamline the codebase. - Fixed number formatting utility to handle zero values correctly. * Refactor Knowledge Generation to Knowledge Base - Created new API service for Knowledge Base operations including querying, creating, updating, and deleting knowledge bases and files. - Added constants for Knowledge Base status and type mappings. - Defined models for Knowledge Base and related files. - Removed obsolete Knowledge Base creation and home components, replacing them with new implementations under the Knowledge Base structure. - Updated routing to reflect the new Knowledge Base paths. - Adjusted menu items to align with the new Knowledge Base terminology. - Modified ModelAccess interface to include modelName and type properties. * feat: Implement Knowledge Base Page with CRUD operations and data management - Added KnowledgeBasePage component for displaying and managing knowledge bases. - Integrated search and filter functionalities with SearchControls component. - Implemented CreateKnowledgeBase component for creating and editing knowledge bases. - Enhanced AddDataDialog for file uploads and dataset selections. - Introduced TableTransfer component for managing data transfers between tables. - Updated API functions for knowledge base operations, including file management. - Refactored knowledge base model to include file status and metadata. - Adjusted routing to point to the new KnowledgeBasePage.
196 lines
5.0 KiB
TypeScript
196 lines
5.0 KiB
TypeScript
import { useState } from "react";
|
|
import { Card, Button, Table, Tooltip, message } from "antd";
|
|
import { DeleteOutlined, EditOutlined } from "@ant-design/icons";
|
|
import { SearchControls } from "@/components/SearchControls";
|
|
import { useNavigate } from "react-router";
|
|
import CardView from "@/components/CardView";
|
|
import {
|
|
deleteKnowledgeBaseByIdUsingDelete,
|
|
queryKnowledgeBasesUsingPost,
|
|
} from "../knowledge-base.api";
|
|
import useFetchData from "@/hooks/useFetchData";
|
|
import { KnowledgeBaseItem } from "../knowledge-base.model";
|
|
import CreateKnowledgeBase from "../components/CreateKnowledgeBase";
|
|
import { mapKnowledgeBase } from "../knowledge-base.const";
|
|
|
|
export default function KnowledgeBasePage() {
|
|
const navigate = useNavigate();
|
|
const [viewMode, setViewMode] = useState<"card" | "list">("card");
|
|
const [isEdit, setIsEdit] = useState(false);
|
|
const [currentKB, setCurrentKB] = useState<KnowledgeBaseItem | null>(null);
|
|
const {
|
|
loading,
|
|
tableData,
|
|
searchParams,
|
|
pagination,
|
|
fetchData,
|
|
setSearchParams,
|
|
handleFiltersChange,
|
|
} = useFetchData<KnowledgeBaseItem>(
|
|
queryKnowledgeBasesUsingPost,
|
|
mapKnowledgeBase
|
|
);
|
|
|
|
const handleDeleteKB = async (kb: KnowledgeBaseItem) => {
|
|
try {
|
|
await deleteKnowledgeBaseByIdUsingDelete(kb.id);
|
|
message.success("知识库删除成功");
|
|
fetchData();
|
|
} catch (error) {
|
|
message.error("知识库删除失败");
|
|
}
|
|
};
|
|
|
|
const operations = [
|
|
{
|
|
key: "edit",
|
|
label: "编辑",
|
|
icon: <EditOutlined />,
|
|
onClick: (item) => {
|
|
setIsEdit(true);
|
|
setCurrentKB(item);
|
|
},
|
|
},
|
|
{
|
|
key: "delete",
|
|
label: "删除",
|
|
danger: true,
|
|
icon: <DeleteOutlined />,
|
|
confirm: {
|
|
title: "确认删除",
|
|
description: "此操作不可撤销,是否继续?",
|
|
okText: "删除",
|
|
okType: "danger",
|
|
cancelText: "取消",
|
|
},
|
|
onClick: (item) => handleDeleteKB(item),
|
|
},
|
|
];
|
|
|
|
const columns = [
|
|
{
|
|
title: "知识库",
|
|
dataIndex: "name",
|
|
key: "name",
|
|
fixed: "left" as const,
|
|
width: 200,
|
|
ellipsis: true,
|
|
render: (_: any, kb: KnowledgeBaseItem) => (
|
|
<Button
|
|
type="link"
|
|
onClick={() => navigate(`/data/knowledge-base/detail/${kb.id}`)}
|
|
>
|
|
{kb.name}
|
|
</Button>
|
|
),
|
|
},
|
|
{
|
|
title: "向量数据库",
|
|
dataIndex: "embeddingModel",
|
|
key: "embeddingModel",
|
|
width: 150,
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "大语言模型",
|
|
dataIndex: "chatModel",
|
|
key: "chatModel",
|
|
width: 150,
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "创建时间",
|
|
dataIndex: "createdAt",
|
|
key: "createdAt",
|
|
ellipsis: true,
|
|
width: 150,
|
|
},
|
|
{
|
|
title: "更新时间",
|
|
dataIndex: "updatedAt",
|
|
key: "updatedAt",
|
|
ellipsis: true,
|
|
width: 150,
|
|
},
|
|
{
|
|
title: "描述",
|
|
dataIndex: "description",
|
|
key: "description",
|
|
width: 120,
|
|
ellipsis: true,
|
|
},
|
|
{
|
|
title: "操作",
|
|
key: "actions",
|
|
fixed: "right" as const,
|
|
width: 150,
|
|
render: (_: any, kb: KnowledgeBaseItem) => (
|
|
<div className="flex items-center gap-2">
|
|
{operations.map((op) => (
|
|
<Tooltip key={op.key} title={op.label}>
|
|
<Button
|
|
type="text"
|
|
icon={op.icon}
|
|
danger={op.danger}
|
|
onClick={() => op.onClick(kb)}
|
|
/>
|
|
</Tooltip>
|
|
))}
|
|
</div>
|
|
),
|
|
},
|
|
];
|
|
// Main list view
|
|
return (
|
|
<div className="h-full flex flex-col gap-4">
|
|
<div className="flex items-center justify-between">
|
|
<h1 className="text-xl font-bold">知识生成</h1>
|
|
<CreateKnowledgeBase
|
|
isEdit={isEdit}
|
|
data={currentKB}
|
|
onUpdate={() => {
|
|
fetchData();
|
|
}}
|
|
onClose={() => {
|
|
setIsEdit(false);
|
|
setCurrentKB(null);
|
|
}}
|
|
/>
|
|
</div>
|
|
|
|
<SearchControls
|
|
searchTerm={searchParams.keyword}
|
|
onSearchChange={(keyword) =>
|
|
setSearchParams({ ...searchParams, keyword })
|
|
}
|
|
searchPlaceholder="搜索知识库..."
|
|
filters={[]}
|
|
onFiltersChange={handleFiltersChange}
|
|
onClearFilters={() => setSearchParams({ ...searchParams, filter: {} })}
|
|
viewMode={viewMode}
|
|
onViewModeChange={setViewMode}
|
|
showViewToggle
|
|
onReload={fetchData}
|
|
/>
|
|
{viewMode === "card" ? (
|
|
<CardView
|
|
data={tableData}
|
|
operations={operations}
|
|
onView={(item) => navigate(`/data/knowledge-base/detail/${item.id}`)}
|
|
pagination={pagination}
|
|
/>
|
|
) : (
|
|
<Card>
|
|
<Table
|
|
loading={loading}
|
|
scroll={{ x: "max-content", y: "calc(100vh - 20rem)" }}
|
|
columns={columns}
|
|
dataSource={tableData}
|
|
rowKey="id"
|
|
/>
|
|
</Card>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|