重构知识库相关接口,更新数据结构和命名,移除示例文件,调整组件和视图以支持新命名,优化文档和数据集管理功能。
This commit is contained in:
@@ -4,29 +4,27 @@ import { newService } from '/@/utils/request';
|
||||
export interface DocumentQueryParams {
|
||||
keyword?: string;
|
||||
datasetId?: string;
|
||||
status?: string;
|
||||
fileType?: string;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
// 创建文档参数
|
||||
export interface CreateDocumentParams {
|
||||
KnowledgeId: number; // 必传
|
||||
filePath: string; // 必传
|
||||
fileSize: number; // 必传
|
||||
format: string; // 必传
|
||||
title: string; // 必传
|
||||
datasetId: string; // 必传
|
||||
filePath: string; // 必传
|
||||
fileSize: number; // 必传
|
||||
format: string; // 必传
|
||||
title: string; // 必传
|
||||
}
|
||||
|
||||
// 更新文档参数
|
||||
export interface UpdateDocumentParams {
|
||||
id: string; // 必传
|
||||
KnowledgeId?: number; // 可选
|
||||
filePath?: string; // 可选
|
||||
fileSize?: number; // 可选
|
||||
format?: string; // 可选
|
||||
title?: string; // 可选
|
||||
id: string; // 必传
|
||||
datasetId?: string;
|
||||
filePath?: string;
|
||||
fileSize?: number;
|
||||
format?: string;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
// 文档信息
|
||||
@@ -34,35 +32,20 @@ export interface DocumentInfo {
|
||||
id?: string;
|
||||
name: string;
|
||||
datasetId: string;
|
||||
datasetName?: string;
|
||||
fileType: string; // pdf, docx, txt, md, html
|
||||
fileType: string;
|
||||
fileSize?: number;
|
||||
filePath?: string;
|
||||
charCount?: number;
|
||||
chunkCount?: number;
|
||||
status: string; // pending, processing, completed, failed
|
||||
indexStatus?: string; // not_indexed, indexing, indexed, failed
|
||||
errorMessage?: string;
|
||||
parseStatus?: string;
|
||||
enabled?: boolean;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
// 文档分段信息
|
||||
export interface DocumentChunk {
|
||||
id: string;
|
||||
documentId: string;
|
||||
content: string;
|
||||
chunkIndex: number;
|
||||
charCount: number;
|
||||
tokenCount?: number;
|
||||
embedding?: number[];
|
||||
createdAt?: string;
|
||||
}
|
||||
|
||||
// 获取文档列表
|
||||
export function listDocuments(params: DocumentQueryParams) {
|
||||
return newService({
|
||||
url: '/knowledge/document/list',
|
||||
url: '/rag-knowledge/document/listDocument',
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
@@ -71,16 +54,16 @@ export function listDocuments(params: DocumentQueryParams) {
|
||||
// 获取文档详情
|
||||
export function getDocument(id: string) {
|
||||
return newService({
|
||||
url: '/knowledge/document/detail',
|
||||
url: '/rag-knowledge/document/getDocument',
|
||||
method: 'get',
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
// 创建文档(JSON格式)
|
||||
// 创建文档
|
||||
export function createDocument(data: CreateDocumentParams) {
|
||||
return newService({
|
||||
url: '/knowledge/document/create',
|
||||
url: '/rag-knowledge/document/createDocument',
|
||||
method: 'post',
|
||||
data,
|
||||
});
|
||||
@@ -89,16 +72,28 @@ export function createDocument(data: CreateDocumentParams) {
|
||||
// 更新文档
|
||||
export function updateDocument(data: UpdateDocumentParams) {
|
||||
return newService({
|
||||
url: '/knowledge/document/update',
|
||||
url: '/rag-knowledge/document/updateDocument',
|
||||
method: 'put',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 公共文件上传(OSS),返回文件路径
|
||||
export function uploadFile(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return newService({
|
||||
url: '/oss/file/uploadFile',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
}
|
||||
|
||||
// 上传文档
|
||||
export function uploadDocument(data: FormData) {
|
||||
return newService({
|
||||
url: '/knowledge/document/upload',
|
||||
url: '/rag-knowledge/document/createDocument',
|
||||
method: 'post',
|
||||
data,
|
||||
headers: {
|
||||
@@ -110,61 +105,16 @@ export function uploadDocument(data: FormData) {
|
||||
// 删除文档
|
||||
export function deleteDocument(id: string) {
|
||||
return newService({
|
||||
url: '/knowledge/document/delete',
|
||||
url: '/rag-knowledge/document/deleteDocument',
|
||||
method: 'delete',
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
// 批量删除文档
|
||||
export function batchDeleteDocuments(ids: string[]) {
|
||||
// 获取文件向量化处理进度
|
||||
export function getDocumentProcess(id: string) {
|
||||
return newService({
|
||||
url: '/knowledge/document/batchDelete',
|
||||
method: 'delete',
|
||||
data: { ids },
|
||||
});
|
||||
}
|
||||
|
||||
// 重新处理文档
|
||||
export function reprocessDocument(id: string) {
|
||||
return newService({
|
||||
url: '/knowledge/document/reprocess',
|
||||
method: 'post',
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
// 获取文档分段列表
|
||||
export function listDocumentChunks(params: { documentId: string; pageNum: number; pageSize: number }) {
|
||||
return newService({
|
||||
url: '/knowledge/document/chunks',
|
||||
method: 'get',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
// 更新文档分段
|
||||
export function updateDocumentChunk(data: { id: string; content: string }) {
|
||||
return newService({
|
||||
url: '/knowledge/document/chunk/update',
|
||||
method: 'put',
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除文档分段
|
||||
export function deleteDocumentChunk(id: string) {
|
||||
return newService({
|
||||
url: '/knowledge/document/chunk/delete',
|
||||
method: 'delete',
|
||||
params: { id },
|
||||
});
|
||||
}
|
||||
|
||||
// 预览文档内容
|
||||
export function previewDocument(id: string) {
|
||||
return newService({
|
||||
url: '/knowledge/document/preview',
|
||||
url: '/rag-knowledge/document/getProcess',
|
||||
method: 'get',
|
||||
params: { id },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user