liudong
2024-08-01 5ff5e947cbd5cc0d0819be8da5bbc18df8965a06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import axios from "axios";
import qs from "query-string";
import type { DescData } from "@arco-design/web-vue/es/descriptions/interface";
 
export interface PolicyRecord {
  id: string;
  number: number;
  name: string;
  contentType: "img" | "horizontalVideo" | "verticalVideo";
  filterType: "artificial" | "rules";
  count: number;
  status: "online" | "offline";
  createdTime: string;
}
 
export interface PolicyParams extends Partial<PolicyRecord> {
  current: number;
  pageSize: number;
}
 
export interface PolicyListRes {
  list: PolicyRecord[];
  total: number;
}
 
// 知识库列表接口
export function queryKbList(params) {
  return axios.get("/api/v1/kb/list", {
    params
  });
}
 
// 知识库详情接口
export function queryKbdetail(params) {
  return axios.get("/api/v1/kb/detail", {
    params
  });
}
 
// 信息接口
export function queryKbtenantInfo(params) {
  return axios.get("/api/v1/user/tenant_info", {
    params
  });
}
 
// 文档列表接口
export function queryKbDocumentList(params) {
  return axios.get("/api/v1/document/list", {
    params
  });
}
 
// 知识库创建接口
export function kbcreate(params) {
  return axios.post("/api/v1/kb/create", params);
}
 
// 知识库删除接口
export function deleteKnow(params) {
  return axios.post("/api/v1/kb/rm", params);
}
 
//知识库更新接口
 
export function querykbupdate(params) {
  return axios.post("/api/v1/kb/update", params);
}
 
// 文档上传接口
 
// export function kbdocumentupload(params) {
//   return axios.post('/api/v1/document/upload', params);
// }
 
export function kbdocumentupload(params) {
  const config = {
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
      // token: token,
    }
  };
  return axios.post(
    "/api/v1/document/upload",
    params,
    config
  );
}
 
 
// 文档启动/取消解析接口
 
export function kbdocumentrun(params) {
  return axios.post("/api/v1/document/run", params);
}
 
// 文档删除接口
 
export function kbdocumentrm(params) {
  return axios.post("/api/v1/document/rm", params);
}
 
 
// 文档重命名接口
export function kbdocumentrename(params) {
  return axios.post("/api/v1/document/rename", params);
}
 
// 文件解析方法接口
export function kbdocumentchangeparser(params) {
  return axios.post("/api/v1/document/change_parser", params);
}
 
// 文档启用/禁用接口
export function kbdocumentchangeStatus(params) {
  return axios.post("/api/v1/document/change_status", params);
}
 
// 模型列表接口
export function queryModelList(params) {
  return axios.get("/api/v1/llm/list", {
    params
  });
}
 
 
// 测试接口
export function kbretrievalTest(params) {
  return axios.post("/api/v1/chunk/retrieval_test", params);
}
 
 
// 配置接口
export function kbUpdate(params) {
  return axios.post("/api/v1/kb/update", params);
}
 
 
// 文档下载接口
 
export const downloadFile = ({
                               url,
                               filename,
                               target
                             }: {
  url: string;
  filename?: string;
  target?: string;
}) => {
  const downloadElement = document.createElement("a");
  downloadElement.style.display = "none";
  downloadElement.href = url;
  if (target) {
    downloadElement.target = "_blank";
  }
  downloadElement.rel = "noopener noreferrer";
  if (filename) {
    downloadElement.download = filename;
  }
  document.body.appendChild(downloadElement);
  downloadElement.click();
  document.body.removeChild(downloadElement);
};