73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
import { l as httpRequest } from "./index.CMd5bD1r.js";
|
|
const API_PATH = "/application/ai/knowledge";
|
|
const KnowledgeBaseAPI = {
|
|
// 列表查询
|
|
list(query) {
|
|
return httpRequest({
|
|
url: `${API_PATH}/list`,
|
|
method: "get",
|
|
params: query
|
|
});
|
|
},
|
|
// 详情查询
|
|
detail(id) {
|
|
return httpRequest({
|
|
url: `${API_PATH}/detail/${id}`,
|
|
method: "get"
|
|
});
|
|
},
|
|
// 新增(支持文件上传)
|
|
create(body, files) {
|
|
const formData = new FormData();
|
|
if (body.name) formData.append("name", body.name);
|
|
if (body.embedding_config_id) formData.append("embedding_config_id", String(body.embedding_config_id));
|
|
if (body.description) formData.append("description", body.description);
|
|
if (files && files.length > 0) {
|
|
files.forEach((file) => {
|
|
formData.append("files", file);
|
|
});
|
|
}
|
|
return httpRequest({
|
|
url: `${API_PATH}/create`,
|
|
method: "post",
|
|
data: formData,
|
|
headers: {
|
|
"Content-Type": "multipart/form-data"
|
|
}
|
|
});
|
|
},
|
|
// 修改
|
|
update(id, body) {
|
|
return httpRequest({
|
|
url: `${API_PATH}/update/${id}`,
|
|
method: "put",
|
|
data: body
|
|
});
|
|
},
|
|
// 删除
|
|
delete(ids) {
|
|
return httpRequest({
|
|
url: `${API_PATH}/delete`,
|
|
method: "delete",
|
|
data: ids
|
|
});
|
|
},
|
|
// 重试向量化
|
|
retry(id) {
|
|
return httpRequest({
|
|
url: `${API_PATH}/retry/${id}`,
|
|
method: "post"
|
|
});
|
|
}
|
|
};
|
|
const KB_STATUS_MAP = {
|
|
0: { label: "待处理", type: "info" },
|
|
1: { label: "处理中", type: "warning" },
|
|
2: { label: "已完成", type: "success" },
|
|
3: { label: "处理失败", type: "danger" }
|
|
};
|
|
export {
|
|
KnowledgeBaseAPI as K,
|
|
KB_STATUS_MAP as a
|
|
};
|