2026-02-02 14:04:37 +08:00
|
|
|
|
import { newService } from '/@/utils/request';
|
|
|
|
|
|
|
|
|
|
|
|
// 文档查询参数
|
|
|
|
|
|
export interface DocumentQueryParams {
|
|
|
|
|
|
keyword?: string;
|
|
|
|
|
|
datasetId?: string;
|
|
|
|
|
|
pageNum: number;
|
|
|
|
|
|
pageSize: number;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-24 18:00:17 +08:00
|
|
|
|
// 创建文档参数
|
|
|
|
|
|
export interface CreateDocumentParams {
|
2026-03-30 17:35:05 +08:00
|
|
|
|
datasetId: string; // 必传
|
|
|
|
|
|
filePath: string; // 必传
|
|
|
|
|
|
fileSize: number; // 必传
|
|
|
|
|
|
format: string; // 必传
|
|
|
|
|
|
title: string; // 必传
|
2026-03-24 18:00:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 更新文档参数
|
|
|
|
|
|
export interface UpdateDocumentParams {
|
2026-03-30 17:35:05 +08:00
|
|
|
|
id: string; // 必传
|
|
|
|
|
|
datasetId?: string;
|
|
|
|
|
|
filePath?: string;
|
|
|
|
|
|
fileSize?: number;
|
|
|
|
|
|
format?: string;
|
|
|
|
|
|
title?: string;
|
2026-03-24 18:00:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-02 14:04:37 +08:00
|
|
|
|
// 文档信息
|
|
|
|
|
|
export interface DocumentInfo {
|
|
|
|
|
|
id?: string;
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
datasetId: string;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
fileType: string;
|
2026-02-02 14:04:37 +08:00
|
|
|
|
fileSize?: number;
|
|
|
|
|
|
filePath?: string;
|
|
|
|
|
|
chunkCount?: number;
|
2026-03-30 17:35:05 +08:00
|
|
|
|
parseStatus?: string;
|
|
|
|
|
|
enabled?: boolean;
|
2026-02-02 14:04:37 +08:00
|
|
|
|
createdAt?: string;
|
|
|
|
|
|
updatedAt?: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取文档列表
|
|
|
|
|
|
export function listDocuments(params: DocumentQueryParams) {
|
|
|
|
|
|
return newService({
|
2026-03-30 17:35:05 +08:00
|
|
|
|
url: '/rag-knowledge/document/listDocument',
|
2026-02-02 14:04:37 +08:00
|
|
|
|
method: 'get',
|
|
|
|
|
|
params,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取文档详情
|
|
|
|
|
|
export function getDocument(id: string) {
|
|
|
|
|
|
return newService({
|
2026-03-30 17:35:05 +08:00
|
|
|
|
url: '/rag-knowledge/document/getDocument',
|
2026-02-02 14:04:37 +08:00
|
|
|
|
method: 'get',
|
|
|
|
|
|
params: { id },
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-30 17:35:05 +08:00
|
|
|
|
// 创建文档
|
2026-03-24 18:00:17 +08:00
|
|
|
|
export function createDocument(data: CreateDocumentParams) {
|
|
|
|
|
|
return newService({
|
2026-03-30 17:35:05 +08:00
|
|
|
|
url: '/rag-knowledge/document/createDocument',
|
2026-03-24 18:00:17 +08:00
|
|
|
|
method: 'post',
|
|
|
|
|
|
data,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 更新文档
|
|
|
|
|
|
export function updateDocument(data: UpdateDocumentParams) {
|
|
|
|
|
|
return newService({
|
2026-03-30 17:35:05 +08:00
|
|
|
|
url: '/rag-knowledge/document/updateDocument',
|
2026-03-24 18:00:17 +08:00
|
|
|
|
method: 'put',
|
|
|
|
|
|
data,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-30 17:35:05 +08:00
|
|
|
|
// 公共文件上传(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' },
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-02 14:04:37 +08:00
|
|
|
|
// 上传文档
|
|
|
|
|
|
export function uploadDocument(data: FormData) {
|
|
|
|
|
|
return newService({
|
2026-03-30 17:35:05 +08:00
|
|
|
|
url: '/rag-knowledge/document/createDocument',
|
2026-02-02 14:04:37 +08:00
|
|
|
|
method: 'post',
|
|
|
|
|
|
data,
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
'Content-Type': 'multipart/form-data',
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 删除文档
|
|
|
|
|
|
export function deleteDocument(id: string) {
|
|
|
|
|
|
return newService({
|
2026-03-30 17:35:05 +08:00
|
|
|
|
url: '/rag-knowledge/document/deleteDocument',
|
2026-02-02 14:04:37 +08:00
|
|
|
|
method: 'delete',
|
|
|
|
|
|
params: { id },
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-30 17:35:05 +08:00
|
|
|
|
// 获取文件向量化处理进度
|
|
|
|
|
|
export function getDocumentProcess(id: string) {
|
2026-02-02 14:04:37 +08:00
|
|
|
|
return newService({
|
2026-03-30 17:35:05 +08:00
|
|
|
|
url: '/rag-knowledge/document/getProcess',
|
2026-02-02 14:04:37 +08:00
|
|
|
|
method: 'get',
|
|
|
|
|
|
params: { id },
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|