@glodon-aiot/apis 2.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.git.md +73 -0
- package/README.lib.md +135 -0
- package/dist/es/aecpilot/cosntant.mjs +5 -0
- package/dist/es/aecpilot/index.mjs +510 -0
- package/dist/es/aecpilot/model.mjs +9 -0
- package/dist/es/aecpilotui/index.mjs +607 -0
- package/dist/es/agentcliui/index.mjs +418 -0
- package/dist/es/aishop/index.mjs +97 -0
- package/dist/es/aishop/model.mjs +5 -0
- package/dist/es/auth/index.mjs +52 -0
- package/dist/es/base/index.mjs +158 -0
- package/dist/es/contralyze/index.mjs +91 -0
- package/dist/es/cvforce/index.mjs +431 -0
- package/dist/es/cvforce/model.mjs +12 -0
- package/dist/es/cvforce-datahub/index.mjs +435 -0
- package/dist/es/cvforce-datahub/model.mjs +8 -0
- package/dist/es/cvforce-modelservice/index.mjs +114 -0
- package/dist/es/cvforce-modelservice/model.mjs +4 -0
- package/dist/es/index.mjs +62 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +6 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +10 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +9 -0
- package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +19 -0
- package/dist/es/panorama/index.mjs +136 -0
- package/dist/es/panorama/model.mjs +5 -0
- package/dist/es/pluginmgr/index.mjs +85 -0
- package/dist/es/user/index.mjs +193 -0
- package/dist/es/utils/fetchEventSource/fetch.mjs +112 -0
- package/dist/es/utils/fetchEventSource/parse.mjs +97 -0
- package/dist/es/utils/index.mjs +9 -0
- package/dist/lib/index.js +3 -0
- package/dist/src/aecpilot/cosntant.d.ts +8 -0
- package/dist/src/aecpilot/index.d.ts +79 -0
- package/dist/src/aecpilot/model.d.ts +350 -0
- package/dist/src/aecpilotui/index.d.ts +72 -0
- package/dist/src/aecpilotui/model.d.ts +63 -0
- package/dist/src/agentcliui/index.d.ts +72 -0
- package/dist/src/agentcliui/model.d.ts +39 -0
- package/dist/src/aishop/index.d.ts +26 -0
- package/dist/src/aishop/model.d.ts +111 -0
- package/dist/src/auth/index.d.ts +17 -0
- package/dist/src/auth/model.d.ts +24 -0
- package/dist/src/base/index.d.ts +41 -0
- package/dist/src/base/model.d.ts +20 -0
- package/dist/src/contralyze/index.d.ts +24 -0
- package/dist/src/contralyze/model.d.ts +75 -0
- package/dist/src/cvforce/index.d.ts +130 -0
- package/dist/src/cvforce/model.d.ts +519 -0
- package/dist/src/cvforce-datahub/index.d.ts +186 -0
- package/dist/src/cvforce-datahub/model.d.ts +438 -0
- package/dist/src/cvforce-modelservice/index.d.ts +23 -0
- package/dist/src/cvforce-modelservice/model.d.ts +156 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/panorama/index.d.ts +42 -0
- package/dist/src/panorama/model.d.ts +263 -0
- package/dist/src/pluginmgr/index.d.ts +28 -0
- package/dist/src/pluginmgr/model.d.ts +48 -0
- package/dist/src/user/index.d.ts +42 -0
- package/dist/src/user/model.d.ts +247 -0
- package/dist/src/utils/fetchEventSource/fetch.d.ts +44 -0
- package/dist/src/utils/fetchEventSource/index.d.ts +1 -0
- package/dist/src/utils/fetchEventSource/parse.d.ts +36 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/package.json +88 -0
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
var v = Object.defineProperty, S = Object.defineProperties;
|
|
2
|
+
var A = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var h = Object.getOwnPropertySymbols;
|
|
4
|
+
var w = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var f = (p, e, t) => e in p ? v(p, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[e] = t, y = (p, e) => {
|
|
6
|
+
for (var t in e || (e = {}))
|
|
7
|
+
w.call(e, t) && f(p, t, e[t]);
|
|
8
|
+
if (h)
|
|
9
|
+
for (var t of h(e))
|
|
10
|
+
R.call(e, t) && f(p, t, e[t]);
|
|
11
|
+
return p;
|
|
12
|
+
}, $ = (p, e) => S(p, A(e));
|
|
13
|
+
var s = (p, e, t) => new Promise((a, i) => {
|
|
14
|
+
var r = (d) => {
|
|
15
|
+
try {
|
|
16
|
+
m(t.next(d));
|
|
17
|
+
} catch (l) {
|
|
18
|
+
i(l);
|
|
19
|
+
}
|
|
20
|
+
}, n = (d) => {
|
|
21
|
+
try {
|
|
22
|
+
m(t.throw(d));
|
|
23
|
+
} catch (l) {
|
|
24
|
+
i(l);
|
|
25
|
+
}
|
|
26
|
+
}, m = (d) => d.done ? a(d.value) : Promise.resolve(d.value).then(r, n);
|
|
27
|
+
m((t = t.apply(p, e)).next());
|
|
28
|
+
});
|
|
29
|
+
import K from "axios";
|
|
30
|
+
import { BaseApi as T } from "../base/index.mjs";
|
|
31
|
+
import { initMinio as b, putObjectBuffer as P } from "@glodon-aiot/minio";
|
|
32
|
+
import { IHistoryRole as k, AecKnowledgeFileStatus as I } from "../aecpilot/model.mjs";
|
|
33
|
+
import { fetchEventSource as M } from "../utils/fetchEventSource/fetch.mjs";
|
|
34
|
+
import F from "dayjs";
|
|
35
|
+
import { Buffer as B } from "buffer";
|
|
36
|
+
import { PROMPT_SEARCH_MAX_LENGTH as H } from "../aecpilot/cosntant.mjs";
|
|
37
|
+
import E from "../node_modules/uuid/dist/esm-browser/v4.mjs";
|
|
38
|
+
globalThis.Buffer = B;
|
|
39
|
+
class J extends T {
|
|
40
|
+
constructor(e, t, a) {
|
|
41
|
+
super(e != null ? e : K.create(), a), this.axiosInstance = e, this.getToken = t;
|
|
42
|
+
}
|
|
43
|
+
// async postChatV2EventSource1(
|
|
44
|
+
// applicationId: string,
|
|
45
|
+
// sessionId: string,
|
|
46
|
+
// params: any,
|
|
47
|
+
// signal: AbortSignal,
|
|
48
|
+
// options: { onopen?: any; onmessage?: any; onerror?: any; onclose?: any }
|
|
49
|
+
// ) {
|
|
50
|
+
// const tempMessage: any = {
|
|
51
|
+
// code: 0,
|
|
52
|
+
// messageId: uuidv4(),
|
|
53
|
+
// content: '',
|
|
54
|
+
// role: IHistoryRole.Robot,
|
|
55
|
+
// sessionId: '',
|
|
56
|
+
// reference: [],
|
|
57
|
+
// searchReference: [],
|
|
58
|
+
// messageTime: '',
|
|
59
|
+
// llmModel: '',
|
|
60
|
+
// comment: {
|
|
61
|
+
// isAgree: 0,
|
|
62
|
+
// },
|
|
63
|
+
// isReplying: false,
|
|
64
|
+
// };
|
|
65
|
+
// const token = await this.getToken();
|
|
66
|
+
// const body = { ...params, stream: true };
|
|
67
|
+
// fetchEventSource(
|
|
68
|
+
// `https://aiot-dev.glodon.com/api/cvforcepd/chat/v2/chat?applicationId=${applicationId}&sessionId=${sessionId}`,
|
|
69
|
+
// {
|
|
70
|
+
// method: 'POST',
|
|
71
|
+
// headers: {
|
|
72
|
+
// Authorization: `Bearer ${token}`,
|
|
73
|
+
// 'Content-Type': 'application/json',
|
|
74
|
+
// },
|
|
75
|
+
// body: JSON.stringify(body),
|
|
76
|
+
// openWhenHidden: true,
|
|
77
|
+
// signal: signal,
|
|
78
|
+
// onopen(response) {
|
|
79
|
+
// console.log('onopen');
|
|
80
|
+
// if (response.ok) {
|
|
81
|
+
// options?.onopen && options.onopen();
|
|
82
|
+
// }
|
|
83
|
+
// return Promise.resolve();
|
|
84
|
+
// },
|
|
85
|
+
// onmessage(event) {
|
|
86
|
+
// if (!event.data.includes('{"code": ')) {
|
|
87
|
+
// let eventData: any = {};
|
|
88
|
+
// try {
|
|
89
|
+
// eventData = JSON.parse(event.data);
|
|
90
|
+
// } catch (error) {}
|
|
91
|
+
// if (eventData?.mtype === 'search') {
|
|
92
|
+
// tempMessage.searchReference.push(eventData);
|
|
93
|
+
// } else {
|
|
94
|
+
// tempMessage.content = tempMessage.content + event.data;
|
|
95
|
+
// }
|
|
96
|
+
// const responseMsg: any = {
|
|
97
|
+
// content: tempMessage.content,
|
|
98
|
+
// role: 1,
|
|
99
|
+
// reference: tempMessage.reference,
|
|
100
|
+
// searchReference: tempMessage.searchReference,
|
|
101
|
+
// messageId: tempMessage.messageId,
|
|
102
|
+
// sessionId: sessionId,
|
|
103
|
+
// messageTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
|
|
104
|
+
// comment: {
|
|
105
|
+
// isAgree: 0,
|
|
106
|
+
// },
|
|
107
|
+
// isReplying: true,
|
|
108
|
+
// };
|
|
109
|
+
// return options?.onmessage && options.onmessage(responseMsg);
|
|
110
|
+
// }
|
|
111
|
+
// const structure = JSON.parse(event.data);
|
|
112
|
+
// tempMessage.reference = structure.data.reference;
|
|
113
|
+
// tempMessage.searchReference = structure.data.searchReference;
|
|
114
|
+
// tempMessage.messageTime = structure.data.messageTime;
|
|
115
|
+
// tempMessage.messageId = structure.data.messageId;
|
|
116
|
+
// tempMessage.llmModel = structure.data.llmModel;
|
|
117
|
+
// tempMessage.content = structure.data.content;
|
|
118
|
+
// tempMessage.code = structure.code;
|
|
119
|
+
// if (structure.code === 200) {
|
|
120
|
+
// const responseMsg: any = {
|
|
121
|
+
// code: tempMessage.code,
|
|
122
|
+
// content: tempMessage.content,
|
|
123
|
+
// role: 1,
|
|
124
|
+
// reference: tempMessage.reference,
|
|
125
|
+
// searchReference: tempMessage.searchReference,
|
|
126
|
+
// messageId: tempMessage.messageId,
|
|
127
|
+
// sessionId: sessionId,
|
|
128
|
+
// messageTime: tempMessage.messageTime,
|
|
129
|
+
// isReplying: true,
|
|
130
|
+
// };
|
|
131
|
+
// options?.onmessage && options.onmessage(responseMsg);
|
|
132
|
+
// } else {
|
|
133
|
+
// return notification.error({
|
|
134
|
+
// message: structure.message,
|
|
135
|
+
// });
|
|
136
|
+
// }
|
|
137
|
+
// },
|
|
138
|
+
// onerror() {
|
|
139
|
+
// options?.onerror && options.onerror();
|
|
140
|
+
// },
|
|
141
|
+
// onclose() {
|
|
142
|
+
// const responseMsg: any = {
|
|
143
|
+
// code: tempMessage.code,
|
|
144
|
+
// content: tempMessage.content,
|
|
145
|
+
// role: 1,
|
|
146
|
+
// reference: tempMessage.reference,
|
|
147
|
+
// searchReference: tempMessage.searchReference,
|
|
148
|
+
// messageId: tempMessage.messageId,
|
|
149
|
+
// sessionId: sessionId,
|
|
150
|
+
// messageTime: tempMessage.messageTime,
|
|
151
|
+
// comment: {
|
|
152
|
+
// isAgree: 0,
|
|
153
|
+
// },
|
|
154
|
+
// isReplying: false,
|
|
155
|
+
// };
|
|
156
|
+
// options?.onclose && options.onclose(responseMsg);
|
|
157
|
+
// },
|
|
158
|
+
// }
|
|
159
|
+
// );
|
|
160
|
+
// }
|
|
161
|
+
// async getKnowledgeIdFileIdData(id: string, fid: string, did: string) {
|
|
162
|
+
// return this.get<IFileDataParam[]>(
|
|
163
|
+
// `/knowledge/${id}/file/${fid}/data/${did}`
|
|
164
|
+
// );
|
|
165
|
+
// }
|
|
166
|
+
// async getKnowledgeIdFileId(id: string, fid: string) {
|
|
167
|
+
// return this.get<IFile>(`/knowledge/${id}/file/${fid}`);
|
|
168
|
+
// }
|
|
169
|
+
// async getKnowledgeId(id: string) {
|
|
170
|
+
// return this.get<IKnowledge>(`/knowledge/${id}`);
|
|
171
|
+
// }
|
|
172
|
+
// async getSessionKnowledgeFile(sessionId: string, fileId: string) {
|
|
173
|
+
// return this.get<KnowledgeFileMetadata>(
|
|
174
|
+
// `chatSession/${sessionId}/file/${fileId}`
|
|
175
|
+
// );
|
|
176
|
+
// }
|
|
177
|
+
// async sleep(ms: number) {
|
|
178
|
+
// return new Promise((reslove) => {
|
|
179
|
+
// setTimeout(() => {
|
|
180
|
+
// reslove('');
|
|
181
|
+
// }, ms);
|
|
182
|
+
// });
|
|
183
|
+
// }
|
|
184
|
+
// async uploadFiles(path: string, files: File[]) {
|
|
185
|
+
// const parmas = {
|
|
186
|
+
// files: files.map((i) => i.name),
|
|
187
|
+
// isv: 'minio',
|
|
188
|
+
// knowledgeId: path,
|
|
189
|
+
// };
|
|
190
|
+
// return this.postUploadTicket(parmas)
|
|
191
|
+
// .then((data) =>
|
|
192
|
+
// Promise.all(files.map((file) => this.uploadMinioFile(data.minio, file)))
|
|
193
|
+
// )
|
|
194
|
+
// .catch((e) => {
|
|
195
|
+
// throw Error(e);
|
|
196
|
+
// });
|
|
197
|
+
// }
|
|
198
|
+
// async postFile(path: string, file: File, type?: number) {
|
|
199
|
+
// const parmas = {
|
|
200
|
+
// files: [file.name],
|
|
201
|
+
// isv: 'minio',
|
|
202
|
+
// knowledgeId: path,
|
|
203
|
+
// type: type,
|
|
204
|
+
// };
|
|
205
|
+
// return this.postTicket(parmas)
|
|
206
|
+
// .then((data) => this.uploadMinioFile(data.minio, file))
|
|
207
|
+
// .catch((e) => {
|
|
208
|
+
// throw Error(e);
|
|
209
|
+
// });
|
|
210
|
+
// }
|
|
211
|
+
// async postTicket(params: IUploadParam) {
|
|
212
|
+
// return this.post<IUploadTicket>(`/ticket`, params);
|
|
213
|
+
// }
|
|
214
|
+
// async uploadFile(path: string, file: File) {
|
|
215
|
+
// const parmas = {
|
|
216
|
+
// files: [file.name],
|
|
217
|
+
// isv: 'minio',
|
|
218
|
+
// knowledgeId: path,
|
|
219
|
+
// };
|
|
220
|
+
// return this.postUploadTicket(parmas)
|
|
221
|
+
// .then((data) => this.uploadMinioFile(data.minio, file))
|
|
222
|
+
// .catch((e) => {
|
|
223
|
+
// throw Error(e);
|
|
224
|
+
// });
|
|
225
|
+
// }
|
|
226
|
+
// async postUploadTicket(params: IUploadParam) {
|
|
227
|
+
// return this.post<IUploadTicket>(`/upload/ticket`, params);
|
|
228
|
+
// }
|
|
229
|
+
// async uploadMinioFile(minioConfig: MinioConfig, file: File) {
|
|
230
|
+
// return new Promise<string>((resolve, reject) => {
|
|
231
|
+
// const fr = new FileReader();
|
|
232
|
+
// fr.readAsArrayBuffer(file);
|
|
233
|
+
// fr.onload = (e: any) => {
|
|
234
|
+
// initMinio({
|
|
235
|
+
// endPoint: minioConfig.endpoints[0],
|
|
236
|
+
// useSSL: minioConfig.useSSL,
|
|
237
|
+
// accessKey: minioConfig.accessKey,
|
|
238
|
+
// secretKey: minioConfig.secretKey,
|
|
239
|
+
// });
|
|
240
|
+
// const buffer = Buffer.from(e.target.result);
|
|
241
|
+
// const metaData = {
|
|
242
|
+
// 'Content-Type': 'application/octet-stream',
|
|
243
|
+
// };
|
|
244
|
+
// putObjectBuffer(
|
|
245
|
+
// minioConfig.bucket,
|
|
246
|
+
// minioConfig.fileKeys[0],
|
|
247
|
+
// buffer,
|
|
248
|
+
// metaData,
|
|
249
|
+
// (err) => {
|
|
250
|
+
// if (err) {
|
|
251
|
+
// console.error(err);
|
|
252
|
+
// throw Error(err);
|
|
253
|
+
// } else {
|
|
254
|
+
// resolve(minioConfig.fileKeys[0]);
|
|
255
|
+
// }
|
|
256
|
+
// }
|
|
257
|
+
// );
|
|
258
|
+
// };
|
|
259
|
+
// });
|
|
260
|
+
// }
|
|
261
|
+
// 接口
|
|
262
|
+
getBaseModelInfo(e) {
|
|
263
|
+
return s(this, null, function* () {
|
|
264
|
+
return this.get("/data/v1/baseModelInfo", {
|
|
265
|
+
serviceId: e
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
postGeneques(e) {
|
|
270
|
+
return s(this, null, function* () {
|
|
271
|
+
return this.post("/data/v1/geneques", e);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
getApplicationId(e) {
|
|
275
|
+
return s(this, null, function* () {
|
|
276
|
+
return this.get(`/data/v1/applications/${e}`);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
getApplicationIdSessions(e, t) {
|
|
280
|
+
return s(this, null, function* () {
|
|
281
|
+
return this.get(`/data/v1/application/${e}/sessionsa`, t);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
postApplicationIdSession(e) {
|
|
285
|
+
return s(this, null, function* () {
|
|
286
|
+
return this.post(`/data/v1/application/${e.applicationId}/sessions`, e);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
getApplicationIdSessionsId(e, t) {
|
|
290
|
+
return s(this, null, function* () {
|
|
291
|
+
return this.get(`/data/v1/application/${e}/sessions/${t}`);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
patchApplicationIdSessionsId(e, t, a) {
|
|
295
|
+
return s(this, null, function* () {
|
|
296
|
+
return this.patch(`/data/v1/application/${e}/sessions/${t}`, a);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
delApplicationIdSessionsId(e, t) {
|
|
300
|
+
return s(this, null, function* () {
|
|
301
|
+
return this.delete(`/data/v1/application/${e}/sessions/${t}`);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
getApplicationIdPromptVariables(e, t) {
|
|
305
|
+
return s(this, null, function* () {
|
|
306
|
+
return this.get(`/data/v1/application/${e}/promptVariables`, t);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
getApplicationIdSessionIdPromptVariables(e, t) {
|
|
310
|
+
return s(this, null, function* () {
|
|
311
|
+
return this.get(`/data/v1/application/${e}/session/${t}/promptVariables`);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
patchApplicationIdSessionpromptVariablesId(e, t, a, i) {
|
|
315
|
+
return s(this, null, function* () {
|
|
316
|
+
return this.patch(`/data/v1/application/${e}/session/${t}/promptVariables/${a}`, i);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
deleteSessionKnowledgeFiles(e, t) {
|
|
320
|
+
return s(this, null, function* () {
|
|
321
|
+
return this.delete(`/data/v1/chatSession/${e}/file`, t);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
getRecommendQues(e) {
|
|
325
|
+
return s(this, null, function* () {
|
|
326
|
+
return this.get(`/data/v1/application/${e}/recommendQues`);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
postRecommendQues(e, t) {
|
|
330
|
+
return s(this, null, function* () {
|
|
331
|
+
return this.post(`/data/v1/application/${e}/recommendQues`, t);
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
delRecommendQues(e, t) {
|
|
335
|
+
return s(this, null, function* () {
|
|
336
|
+
return this.delete(`/data/v1/application/${e}/recommendQues/${t}`);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
getChatHistorySessionId(e, t) {
|
|
340
|
+
return s(this, null, function* () {
|
|
341
|
+
return this.get(`/data/v1/application/${e}/chatHistory/${t}`);
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
//常用提示词
|
|
345
|
+
postPrompts(e, t) {
|
|
346
|
+
return s(this, null, function* () {
|
|
347
|
+
return this.post(`/data/v1/application/${e}/prompts`, t);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
listPrompt(e, t) {
|
|
351
|
+
return s(this, null, function* () {
|
|
352
|
+
return t != null && t.title && t.title.length > H ? [] : this.get(`/data/v1/application/${e}/prompts`, t);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
getPrompt(e, t) {
|
|
356
|
+
return s(this, null, function* () {
|
|
357
|
+
return this.get(`/data/v1/application/${e}/prompts/${t}`);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
updatePrompt(e, t, a) {
|
|
361
|
+
return s(this, null, function* () {
|
|
362
|
+
return this.put(`/data/v1/application/${e}/prompts/${t}`, a);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
deletePrompt(e, t) {
|
|
366
|
+
return s(this, null, function* () {
|
|
367
|
+
return this.delete(`/data/v1/application/${e}/prompts/${t}`);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
patchApplicationIdSessionsIdContext(e, t) {
|
|
371
|
+
return s(this, null, function* () {
|
|
372
|
+
return this.patch(`/data/v1/application/${e}/sessions/${t}/context`, {});
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
getApplicationIdSessionKnowledgeFiles(e, t, a) {
|
|
376
|
+
return s(this, null, function* () {
|
|
377
|
+
return this.get(`/data/v1/application/${e}/session/${t}/file`, a);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
postApplicationIdSessionKnowledgeFile(e, t, a) {
|
|
381
|
+
return s(this, null, function* () {
|
|
382
|
+
return this.post(`/data/v1/application/${e}/session/${t}/file`, a);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
postApplicationIdSessionKnowledgeSessionFile(e, t, a) {
|
|
386
|
+
return s(this, null, function* () {
|
|
387
|
+
return this.post(`/data/v1/application/${e}/session/${t}/sessionfile`, a);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
delApplicationIdSessionKnowledgeFile(e, t, a) {
|
|
391
|
+
return s(this, null, function* () {
|
|
392
|
+
return this.delete(`/data/v1/application/${e}/session/${t}/file`, a);
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
getApplicationIdSessionKnowledgeFileId(e, t, a, i, r) {
|
|
396
|
+
return s(this, null, function* () {
|
|
397
|
+
return this.get(`/data/v1/application/${e}/session/${t}/file/${a}`, i, r);
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
delApplicationIdSessionKnowledgeFileId(e, t, a) {
|
|
401
|
+
return s(this, null, function* () {
|
|
402
|
+
return this.delete(`/data/v1/application/${e}/session/${t}/file/${a}`);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
patchApplicationIdKnowledgeIdFileId(e, t, a, i) {
|
|
406
|
+
return s(this, null, function* () {
|
|
407
|
+
return this.patch(`/data/v1/application/${e}/session/${t}/file/${a}`, i);
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
checkFileReady(e, t, a, i = () => !0, r = 1e4, n) {
|
|
411
|
+
return s(this, null, function* () {
|
|
412
|
+
return new Promise((m, d) => {
|
|
413
|
+
const l = () => {
|
|
414
|
+
if (!i()) {
|
|
415
|
+
clearInterval(o);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
a ? this.getApplicationIdSessionKnowledgeFileId(e, t, a, {}, !0).then((c) => {
|
|
419
|
+
if (n == null || n(c), c.status === I.Success && (clearInterval(o), m(c)), c.status === I.Failed) {
|
|
420
|
+
clearInterval(o);
|
|
421
|
+
const g = "该文件无法读取,请上传可编辑pdf,doc,docx文档";
|
|
422
|
+
d(Error(g, {
|
|
423
|
+
cause: {
|
|
424
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
425
|
+
// @ts-ignore
|
|
426
|
+
code: -101,
|
|
427
|
+
message: g,
|
|
428
|
+
data: c
|
|
429
|
+
}
|
|
430
|
+
}));
|
|
431
|
+
}
|
|
432
|
+
}).catch((c) => {
|
|
433
|
+
clearInterval(o), d(c);
|
|
434
|
+
}) : m(null);
|
|
435
|
+
}, o = setInterval(l, r);
|
|
436
|
+
l();
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
uploadFile(e, t) {
|
|
441
|
+
return s(this, null, function* () {
|
|
442
|
+
const a = {
|
|
443
|
+
files: [t.name],
|
|
444
|
+
isv: "minio",
|
|
445
|
+
knowledgeId: e
|
|
446
|
+
};
|
|
447
|
+
return this.postUploadTicket(a).then((i) => this.uploadMinioFile(i.minio, t)).catch((i) => {
|
|
448
|
+
throw Error(i);
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
postUploadTicket(e) {
|
|
453
|
+
return s(this, null, function* () {
|
|
454
|
+
return this.post("/data/v1/ticket", e);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
uploadMinioFile(e, t) {
|
|
458
|
+
return s(this, null, function* () {
|
|
459
|
+
return new Promise((a, i) => {
|
|
460
|
+
const r = new FileReader();
|
|
461
|
+
r.readAsArrayBuffer(t), r.onload = (n) => {
|
|
462
|
+
b({
|
|
463
|
+
endPoint: e.endpoints[0],
|
|
464
|
+
useSSL: e.useSSL,
|
|
465
|
+
accessKey: e.accessKey,
|
|
466
|
+
secretKey: e.secretKey
|
|
467
|
+
});
|
|
468
|
+
const m = Buffer.from(n.target.result), d = {
|
|
469
|
+
"Content-Type": "application/octet-stream"
|
|
470
|
+
};
|
|
471
|
+
P(e.bucket, e.fileKeys[0], m, d, (l) => {
|
|
472
|
+
if (l)
|
|
473
|
+
throw console.error(l), Error(l);
|
|
474
|
+
a(e.fileKeys[0]);
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
postComments(e, t, a) {
|
|
481
|
+
return s(this, null, function* () {
|
|
482
|
+
return this.post(`/data/v1/application/${e}/sessions/${t}/comments`, a);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
getKnowledgeId(e) {
|
|
486
|
+
return s(this, null, function* () {
|
|
487
|
+
return this.get(`/data/v1/knowledge/${e}`);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
getKnowledgeIdFileId(e, t) {
|
|
491
|
+
return s(this, null, function* () {
|
|
492
|
+
return this.get(`/data/v1/knowledge/${e}/file/${t}`);
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
getKnowledgeIdFileIdData(e, t, a) {
|
|
496
|
+
return s(this, null, function* () {
|
|
497
|
+
return this.get(`/data/v1/knowledge/${e}/file/${t}/data/${a}`);
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
postChatV2EventSource(e, t, a, i, r) {
|
|
501
|
+
return s(this, null, function* () {
|
|
502
|
+
var l;
|
|
503
|
+
const n = {
|
|
504
|
+
code: 0,
|
|
505
|
+
messageId: E(),
|
|
506
|
+
content: "",
|
|
507
|
+
role: k.Robot,
|
|
508
|
+
sessionId: "",
|
|
509
|
+
reference: [],
|
|
510
|
+
searchReference: [],
|
|
511
|
+
messageTime: "",
|
|
512
|
+
llmModel: "",
|
|
513
|
+
comment: {
|
|
514
|
+
isAgree: 0
|
|
515
|
+
},
|
|
516
|
+
isReplying: !1,
|
|
517
|
+
message: ""
|
|
518
|
+
}, m = yield this.getToken(), d = $(y({}, a), {
|
|
519
|
+
stream: !0
|
|
520
|
+
});
|
|
521
|
+
M(`${(l = this.axiosInstance) == null ? void 0 : l.defaults.baseURL}/chat/v2/chat?applicationId=${e}&sessionId=${t}`, {
|
|
522
|
+
method: "POST",
|
|
523
|
+
headers: {
|
|
524
|
+
Authorization: `Bearer ${m}`,
|
|
525
|
+
"Content-Type": "application/json"
|
|
526
|
+
},
|
|
527
|
+
body: JSON.stringify(d),
|
|
528
|
+
openWhenHidden: !0,
|
|
529
|
+
signal: i,
|
|
530
|
+
onopen(o) {
|
|
531
|
+
return console.log("onopen"), o.ok && r != null && r.onopen && r.onopen(), Promise.resolve();
|
|
532
|
+
},
|
|
533
|
+
onmessage(o) {
|
|
534
|
+
if (!o.data && !o.event && !o.id && !o.retry)
|
|
535
|
+
return;
|
|
536
|
+
if (!o.data.includes('{"code": ')) {
|
|
537
|
+
let c = {};
|
|
538
|
+
try {
|
|
539
|
+
c = JSON.parse(o.data);
|
|
540
|
+
} catch (V) {
|
|
541
|
+
}
|
|
542
|
+
(c == null ? void 0 : c.mtype) === "search" ? n.searchReference.push(c) : n.content = n.content + o.data;
|
|
543
|
+
const g = {
|
|
544
|
+
content: n.content,
|
|
545
|
+
role: 1,
|
|
546
|
+
reference: n.reference,
|
|
547
|
+
searchReference: n.searchReference,
|
|
548
|
+
messageId: n.messageId,
|
|
549
|
+
sessionId: t,
|
|
550
|
+
messageTime: F(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
|
|
551
|
+
comment: {
|
|
552
|
+
isAgree: 0
|
|
553
|
+
},
|
|
554
|
+
isReplying: !0
|
|
555
|
+
};
|
|
556
|
+
return (r == null ? void 0 : r.onmessage) && r.onmessage(g);
|
|
557
|
+
}
|
|
558
|
+
const u = JSON.parse(o.data);
|
|
559
|
+
if (n.reference = u.data.reference, n.messageTime = u.data.messageTime, n.messageId = u.data.messageId, n.llmModel = u.data.llmModel, n.code = u.code, n.message = u.message, u.code === 200) {
|
|
560
|
+
const c = {
|
|
561
|
+
code: n.code,
|
|
562
|
+
content: n.content,
|
|
563
|
+
role: 1,
|
|
564
|
+
reference: n.reference,
|
|
565
|
+
searchReference: n.searchReference,
|
|
566
|
+
messageId: n.messageId,
|
|
567
|
+
sessionId: t,
|
|
568
|
+
messageTime: n.messageTime,
|
|
569
|
+
isReplying: !0
|
|
570
|
+
};
|
|
571
|
+
r != null && r.onmessage && r.onmessage(c);
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
onerror() {
|
|
575
|
+
r != null && r.onerror && r.onerror();
|
|
576
|
+
},
|
|
577
|
+
onclose() {
|
|
578
|
+
const o = {
|
|
579
|
+
code: n.code,
|
|
580
|
+
content: n.content,
|
|
581
|
+
role: 1,
|
|
582
|
+
reference: n.reference,
|
|
583
|
+
searchReference: n.searchReference,
|
|
584
|
+
messageId: n.messageId,
|
|
585
|
+
sessionId: t,
|
|
586
|
+
messageTime: n.messageTime,
|
|
587
|
+
comment: {
|
|
588
|
+
isAgree: 0
|
|
589
|
+
},
|
|
590
|
+
isReplying: !1,
|
|
591
|
+
message: n.message
|
|
592
|
+
};
|
|
593
|
+
r != null && r.onclose && r.onclose(o);
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
postChat(e, t) {
|
|
599
|
+
return s(this, null, function* () {
|
|
600
|
+
var a;
|
|
601
|
+
return this.post(`${(a = this.axiosInstance) == null ? void 0 : a.defaults.baseURL}/chat/v2/chat`, e, t);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
export {
|
|
606
|
+
J as AecpilotUIApi
|
|
607
|
+
};
|