@glodon-aiot/apis 3.0.11-alpha.3 → 3.0.11-beta.0
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/dist/es/aecpilot/index.mjs +119 -131
- package/dist/es/auth/index.mjs +25 -20
- package/dist/lib/index.js +27 -27
- package/dist/src/aecpilot/model.d.ts +1 -2
- package/dist/src/auth/index.d.ts +1 -0
- package/dist/src/cvforce/model.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
var
|
|
1
|
+
var P = Object.defineProperty, K = Object.defineProperties;
|
|
2
2
|
var E = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var I = Object.getOwnPropertySymbols;
|
|
4
|
+
var b = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var T = (m, e, t) => e in m ? P(m, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[e] = t, f = (m, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, S = (
|
|
13
|
-
var r = (
|
|
7
|
+
b.call(e, t) && T(m, t, e[t]);
|
|
8
|
+
if (I)
|
|
9
|
+
for (var t of I(e))
|
|
10
|
+
F.call(e, t) && T(m, t, e[t]);
|
|
11
|
+
return m;
|
|
12
|
+
}, S = (m, e) => K(m, E(e));
|
|
13
|
+
var r = (m, e, t) => new Promise((o, n) => {
|
|
14
14
|
var s = (i) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
n(
|
|
16
|
+
g(t.next(i));
|
|
17
|
+
} catch (a) {
|
|
18
|
+
n(a);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, h = (i) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
n(
|
|
22
|
+
g(t.throw(i));
|
|
23
|
+
} catch (a) {
|
|
24
|
+
n(a);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, g = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(s, h);
|
|
27
|
+
g((t = t.apply(m, e)).next());
|
|
28
28
|
});
|
|
29
|
-
import
|
|
30
|
-
import { BaseApi as
|
|
31
|
-
import { m as
|
|
32
|
-
import { IHistoryRole as
|
|
33
|
-
import { IFileOrigin as
|
|
34
|
-
import { fetchEventSource as
|
|
35
|
-
import
|
|
36
|
-
import { PROMPT_SEARCH_MAX_LENGTH as
|
|
37
|
-
import { PROMPT_TITLE_MAX_LENGTH as
|
|
38
|
-
import
|
|
39
|
-
class
|
|
29
|
+
import O from "axios";
|
|
30
|
+
import { BaseApi as v } from "../base/index.mjs";
|
|
31
|
+
import { m as $ } from "../node_modules/@glodon-aiot/minio/dist/minio-zj.mjs";
|
|
32
|
+
import { IHistoryRole as k, AecKnowledgeFileStatus as R } from "./model.mjs";
|
|
33
|
+
import { IFileOrigin as G, ISourceType as V, IThinkingStatus as W, IversionInfo as X } from "./model.mjs";
|
|
34
|
+
import { fetchEventSource as w } from "../utils/fetchEventSource/fetch.mjs";
|
|
35
|
+
import C from "dayjs";
|
|
36
|
+
import { PROMPT_SEARCH_MAX_LENGTH as H } from "./cosntant.mjs";
|
|
37
|
+
import { PROMPT_TITLE_MAX_LENGTH as q } from "./cosntant.mjs";
|
|
38
|
+
import A from "../node_modules/uuid/dist/esm-browser/v4.mjs";
|
|
39
|
+
class J extends v {
|
|
40
40
|
constructor(e, t, o) {
|
|
41
|
-
super(e != null ? e :
|
|
41
|
+
super(e != null ? e : O.create(), o), this.axiosInstance = e, this.getToken = t;
|
|
42
42
|
}
|
|
43
43
|
// 会话
|
|
44
44
|
getSessions() {
|
|
@@ -159,19 +159,19 @@ class Y extends C {
|
|
|
159
159
|
return r(this, null, function* () {
|
|
160
160
|
return new Promise((o, n) => {
|
|
161
161
|
const s = new FileReader();
|
|
162
|
-
s.readAsArrayBuffer(t), s.onload = (
|
|
163
|
-
|
|
162
|
+
s.readAsArrayBuffer(t), s.onload = (h) => {
|
|
163
|
+
$.initMinio({
|
|
164
164
|
endPoint: e.endpoints[0],
|
|
165
165
|
useSSL: e.useSSL,
|
|
166
166
|
accessKey: e.accessKey,
|
|
167
167
|
secretKey: e.secretKey
|
|
168
168
|
});
|
|
169
|
-
const
|
|
169
|
+
const g = Buffer.from(h.target.result), i = {
|
|
170
170
|
"Content-Type": "application/octet-stream"
|
|
171
171
|
};
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
throw console.error(
|
|
172
|
+
$.putObjectBuffer(e.bucket, e.fileKeys[0], g, i, (a) => {
|
|
173
|
+
if (a)
|
|
174
|
+
throw console.error(a), Error(a);
|
|
175
175
|
o(e.fileKeys[0]);
|
|
176
176
|
});
|
|
177
177
|
};
|
|
@@ -229,30 +229,30 @@ class Y extends C {
|
|
|
229
229
|
// 文件详情
|
|
230
230
|
checkFileReady(e, t, o = () => !0, n = 1e4, s) {
|
|
231
231
|
return r(this, null, function* () {
|
|
232
|
-
return new Promise((
|
|
232
|
+
return new Promise((h, g) => {
|
|
233
233
|
const i = () => {
|
|
234
234
|
if (!o()) {
|
|
235
|
-
clearInterval(
|
|
235
|
+
clearInterval(a);
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
|
-
t ? this.getSessionKnowledgeFile(e, t).then((
|
|
239
|
-
if (s == null || s(
|
|
240
|
-
clearInterval(
|
|
241
|
-
const
|
|
242
|
-
|
|
238
|
+
t ? this.getSessionKnowledgeFile(e, t).then((c) => {
|
|
239
|
+
if (s == null || s(c), c.status === R.Success && (clearInterval(a), h(c)), c.status === R.Failed) {
|
|
240
|
+
clearInterval(a);
|
|
241
|
+
const d = "该文件无法读取,请上传可编辑pdf,doc,docx文档";
|
|
242
|
+
g(Error(d, {
|
|
243
243
|
cause: {
|
|
244
244
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
245
245
|
// @ts-ignore
|
|
246
246
|
code: -101,
|
|
247
|
-
message:
|
|
248
|
-
data:
|
|
247
|
+
message: d,
|
|
248
|
+
data: c
|
|
249
249
|
}
|
|
250
250
|
}));
|
|
251
251
|
}
|
|
252
|
-
}).catch((
|
|
253
|
-
clearInterval(
|
|
254
|
-
}) :
|
|
255
|
-
},
|
|
252
|
+
}).catch((c) => {
|
|
253
|
+
clearInterval(a), g(c);
|
|
254
|
+
}) : h(null);
|
|
255
|
+
}, a = setInterval(i, n);
|
|
256
256
|
i();
|
|
257
257
|
});
|
|
258
258
|
});
|
|
@@ -268,9 +268,9 @@ class Y extends C {
|
|
|
268
268
|
var i;
|
|
269
269
|
const s = {
|
|
270
270
|
code: 0,
|
|
271
|
-
messageId:
|
|
271
|
+
messageId: A(),
|
|
272
272
|
content: "",
|
|
273
|
-
role:
|
|
273
|
+
role: k.Robot,
|
|
274
274
|
sessionId: "",
|
|
275
275
|
reference: [],
|
|
276
276
|
searchReference: [],
|
|
@@ -280,49 +280,49 @@ class Y extends C {
|
|
|
280
280
|
isAgree: 0
|
|
281
281
|
},
|
|
282
282
|
isReplying: !1
|
|
283
|
-
},
|
|
283
|
+
}, h = yield this.getToken(), g = S(f({}, t), {
|
|
284
284
|
stream: !0
|
|
285
285
|
});
|
|
286
|
-
|
|
286
|
+
w(`${(i = this.axiosInstance) == null ? void 0 : i.defaults.baseURL}/chat?sessionId=${e}`, {
|
|
287
287
|
method: "POST",
|
|
288
288
|
headers: {
|
|
289
|
-
Authorization: `Bearer ${
|
|
289
|
+
Authorization: `Bearer ${h}`,
|
|
290
290
|
"Content-Type": "application/json"
|
|
291
291
|
},
|
|
292
|
-
body: JSON.stringify(
|
|
292
|
+
body: JSON.stringify(g),
|
|
293
293
|
openWhenHidden: !0,
|
|
294
294
|
signal: o,
|
|
295
|
-
onopen(
|
|
296
|
-
return
|
|
295
|
+
onopen(a) {
|
|
296
|
+
return a.ok && n != null && n.onopen && n.onopen(), Promise.resolve();
|
|
297
297
|
},
|
|
298
|
-
onmessage(
|
|
299
|
-
if (!
|
|
298
|
+
onmessage(a) {
|
|
299
|
+
if (!a.data && !a.event && !a.id && !a.retry)
|
|
300
300
|
return;
|
|
301
|
-
if (!
|
|
302
|
-
let
|
|
301
|
+
if (!a.data.includes('{"code": ')) {
|
|
302
|
+
let c = {};
|
|
303
303
|
try {
|
|
304
|
-
|
|
304
|
+
c = JSON.parse(a.data);
|
|
305
305
|
} catch (u) {
|
|
306
306
|
}
|
|
307
|
-
(
|
|
308
|
-
const
|
|
307
|
+
(c == null ? void 0 : c.mtype) === "search" ? s.searchReference.push(c) : s.content = s.content + a.data;
|
|
308
|
+
const d = {
|
|
309
309
|
content: s.content,
|
|
310
310
|
role: 1,
|
|
311
311
|
reference: s.reference,
|
|
312
312
|
searchReference: s.searchReference,
|
|
313
313
|
messageId: s.messageId,
|
|
314
314
|
sessionId: e,
|
|
315
|
-
messageTime:
|
|
315
|
+
messageTime: C(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
|
|
316
316
|
comment: {
|
|
317
317
|
isAgree: 0
|
|
318
318
|
},
|
|
319
319
|
isReplying: !0
|
|
320
320
|
};
|
|
321
|
-
return (n == null ? void 0 : n.onmessage) && n.onmessage(
|
|
321
|
+
return (n == null ? void 0 : n.onmessage) && n.onmessage(d);
|
|
322
322
|
}
|
|
323
|
-
const
|
|
324
|
-
if (s.reference =
|
|
325
|
-
const
|
|
323
|
+
const l = JSON.parse(a.data);
|
|
324
|
+
if (s.reference = l.data.reference, s.messageTime = l.data.messageTime, s.messageId = l.data.messageId, s.llmModel = l.data.llmModel, s.code = l.code, l.code === 200) {
|
|
325
|
+
const c = {
|
|
326
326
|
code: s.code,
|
|
327
327
|
content: s.content,
|
|
328
328
|
role: 1,
|
|
@@ -333,14 +333,14 @@ class Y extends C {
|
|
|
333
333
|
messageTime: s.messageTime,
|
|
334
334
|
isReplying: !0
|
|
335
335
|
};
|
|
336
|
-
n != null && n.onmessage && n.onmessage(
|
|
336
|
+
n != null && n.onmessage && n.onmessage(c);
|
|
337
337
|
}
|
|
338
338
|
},
|
|
339
339
|
onerror() {
|
|
340
340
|
n != null && n.onerror && n.onerror();
|
|
341
341
|
},
|
|
342
342
|
onclose() {
|
|
343
|
-
const
|
|
343
|
+
const a = {
|
|
344
344
|
code: s.code,
|
|
345
345
|
content: s.content,
|
|
346
346
|
role: 1,
|
|
@@ -354,19 +354,19 @@ class Y extends C {
|
|
|
354
354
|
},
|
|
355
355
|
isReplying: !1
|
|
356
356
|
};
|
|
357
|
-
n != null && n.onclose && n.onclose(
|
|
357
|
+
n != null && n.onclose && n.onclose(a);
|
|
358
358
|
}
|
|
359
359
|
});
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
362
|
postChatV3EventSource(e, t, o, n) {
|
|
363
363
|
return r(this, null, function* () {
|
|
364
|
-
var i,
|
|
364
|
+
var i, a;
|
|
365
365
|
const s = {
|
|
366
366
|
code: 0,
|
|
367
|
-
messageId:
|
|
367
|
+
messageId: A(),
|
|
368
368
|
content: "",
|
|
369
|
-
role:
|
|
369
|
+
role: k.Robot,
|
|
370
370
|
sessionId: "",
|
|
371
371
|
reference: [],
|
|
372
372
|
searchReference: [],
|
|
@@ -378,63 +378,51 @@ class Y extends C {
|
|
|
378
378
|
isReplying: !1,
|
|
379
379
|
reasoningContent: "",
|
|
380
380
|
thinkingSecs: "",
|
|
381
|
-
thinkingStatus: ""
|
|
382
|
-
|
|
383
|
-
}, m = yield this.getToken(), h = S(y({}, t), {
|
|
381
|
+
thinkingStatus: ""
|
|
382
|
+
}, h = yield this.getToken(), g = S(f({}, t), {
|
|
384
383
|
stream: !0
|
|
385
384
|
});
|
|
386
|
-
|
|
385
|
+
w(`${(a = (i = this.axiosInstance) == null ? void 0 : i.defaults.baseURL) == null ? void 0 : a.replace("/v1", "/v3")}/chat?sessionId=${e}`, {
|
|
387
386
|
method: "POST",
|
|
388
387
|
headers: {
|
|
389
|
-
Authorization: `Bearer ${
|
|
388
|
+
Authorization: `Bearer ${h}`,
|
|
390
389
|
"Content-Type": "application/json"
|
|
391
390
|
},
|
|
392
|
-
body: JSON.stringify(
|
|
391
|
+
body: JSON.stringify(g),
|
|
393
392
|
openWhenHidden: !0,
|
|
394
393
|
signal: o,
|
|
395
|
-
onopen(
|
|
396
|
-
return
|
|
394
|
+
onopen(l) {
|
|
395
|
+
return l.ok && n != null && n.onopen && n.onopen(), Promise.resolve();
|
|
397
396
|
},
|
|
398
|
-
onmessage(
|
|
399
|
-
if (!
|
|
397
|
+
onmessage(l) {
|
|
398
|
+
if (!l.data && !l.event && !l.id && !l.retry)
|
|
400
399
|
return;
|
|
401
|
-
let
|
|
400
|
+
let c = {};
|
|
402
401
|
try {
|
|
403
|
-
|
|
404
|
-
} catch (
|
|
405
|
-
console.log("eventData",
|
|
402
|
+
c = JSON.parse(l.data);
|
|
403
|
+
} catch (p) {
|
|
404
|
+
console.log("eventData", l.data);
|
|
406
405
|
}
|
|
407
|
-
const
|
|
408
|
-
s.isReplying = !0,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
if (s.searchingStatus === "start") {
|
|
415
|
-
s.searchingStatus = "end";
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
if (l === "beforeSearch" && I(), l === "search" && (s.code = a.code, s.message = a.message, s.searchReference.push(u)), l === "thinking") {
|
|
420
|
-
I(), s.code = a.code, s.message = a.message, s.thinkingStatus = "start";
|
|
421
|
-
const p = u.choices[0];
|
|
422
|
-
s.reasoningContent = s.reasoningContent + p.delta.reasoningContent;
|
|
406
|
+
const d = c.data.type, u = c.data.payload;
|
|
407
|
+
if (s.isReplying = !0, d === "error" && (s.code = c.code, s.message = c.message), d === "search" && (s.code = c.code, s.message = c.message, s.searchReference.push(u)), d === "thinking") {
|
|
408
|
+
s.code = c.code, s.message = c.message, s.thinkingStatus = "start";
|
|
409
|
+
const y = u.choices[0];
|
|
410
|
+
s.reasoningContent = s.reasoningContent + y.delta.reasoningContent;
|
|
423
411
|
}
|
|
424
|
-
if (
|
|
425
|
-
s.code =
|
|
426
|
-
const
|
|
427
|
-
s.thinkingSecs =
|
|
412
|
+
if (d === "thinkingOver") {
|
|
413
|
+
s.code = c.code, s.message = c.message, s.thinkingStatus = "end";
|
|
414
|
+
const p = u.thinkingSecs;
|
|
415
|
+
s.thinkingSecs = p;
|
|
428
416
|
}
|
|
429
|
-
if (
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
s.content = s.content +
|
|
417
|
+
if (d === "text") {
|
|
418
|
+
s.code = c.code, s.message = c.message;
|
|
419
|
+
const y = u.choices[0];
|
|
420
|
+
s.content = s.content + y.delta.content;
|
|
433
421
|
}
|
|
434
|
-
if (
|
|
435
|
-
s.code =
|
|
436
|
-
const
|
|
437
|
-
s.messageId =
|
|
422
|
+
if (d === "reference" && (s.code = c.code, s.message = c.message, s.reference = u), d === "result") {
|
|
423
|
+
s.code = c.code, s.message = c.message;
|
|
424
|
+
const p = u.messageId, y = u.llmModel, M = u.messageTime;
|
|
425
|
+
s.messageId = p, s.llmModel = y, s.messageTime = M, s.sessionId = e;
|
|
438
426
|
}
|
|
439
427
|
n != null && n.onmessage && n.onmessage(s);
|
|
440
428
|
},
|
|
@@ -442,10 +430,10 @@ class Y extends C {
|
|
|
442
430
|
n != null && n.onerror && n.onerror();
|
|
443
431
|
},
|
|
444
432
|
onclose() {
|
|
445
|
-
const
|
|
433
|
+
const l = S(f({}, s), {
|
|
446
434
|
isReplying: !1
|
|
447
435
|
});
|
|
448
|
-
n != null && n.onclose && n.onclose(
|
|
436
|
+
n != null && n.onclose && n.onclose(l);
|
|
449
437
|
}
|
|
450
438
|
});
|
|
451
439
|
});
|
|
@@ -468,7 +456,7 @@ class Y extends C {
|
|
|
468
456
|
}
|
|
469
457
|
listPrompt(e) {
|
|
470
458
|
return r(this, null, function* () {
|
|
471
|
-
return e != null && e.title && e.title.length >
|
|
459
|
+
return e != null && e.title && e.title.length > H ? [] : this.get("/prompts", e);
|
|
472
460
|
});
|
|
473
461
|
}
|
|
474
462
|
getPrompt(e) {
|
|
@@ -510,13 +498,13 @@ class Y extends C {
|
|
|
510
498
|
}
|
|
511
499
|
}
|
|
512
500
|
export {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
501
|
+
J as AECPilotApi,
|
|
502
|
+
R as AecKnowledgeFileStatus,
|
|
503
|
+
G as IFileOrigin,
|
|
504
|
+
k as IHistoryRole,
|
|
505
|
+
V as ISourceType,
|
|
506
|
+
W as IThinkingStatus,
|
|
507
|
+
X as IversionInfo,
|
|
508
|
+
H as PROMPT_SEARCH_MAX_LENGTH,
|
|
509
|
+
q as PROMPT_TITLE_MAX_LENGTH
|
|
522
510
|
};
|
package/dist/es/auth/index.mjs
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
var
|
|
2
|
-
var p = (
|
|
1
|
+
var r = (h, t, e) => new Promise((n, s) => {
|
|
2
|
+
var p = (o) => {
|
|
3
3
|
try {
|
|
4
|
-
|
|
5
|
-
} catch (
|
|
6
|
-
s(
|
|
4
|
+
u(e.next(o));
|
|
5
|
+
} catch (g) {
|
|
6
|
+
s(g);
|
|
7
7
|
}
|
|
8
|
-
}, i = (
|
|
8
|
+
}, i = (o) => {
|
|
9
9
|
try {
|
|
10
|
-
|
|
11
|
-
} catch (
|
|
12
|
-
s(
|
|
10
|
+
u(e.throw(o));
|
|
11
|
+
} catch (g) {
|
|
12
|
+
s(g);
|
|
13
13
|
}
|
|
14
|
-
},
|
|
15
|
-
|
|
14
|
+
}, u = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(p, i);
|
|
15
|
+
u((e = e.apply(h, t)).next());
|
|
16
16
|
});
|
|
17
|
-
import
|
|
18
|
-
import { BaseApi as
|
|
19
|
-
class
|
|
17
|
+
import c from "axios";
|
|
18
|
+
import { BaseApi as l } from "../base/index.mjs";
|
|
19
|
+
class y extends l {
|
|
20
20
|
constructor(t, e) {
|
|
21
|
-
super(t != null ? t :
|
|
21
|
+
super(t != null ? t : c.create(), e);
|
|
22
22
|
}
|
|
23
23
|
getLoginUrl() {
|
|
24
|
-
return
|
|
24
|
+
return r(this, null, function* () {
|
|
25
25
|
return this.get("/openAddress");
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
getToken(t, e) {
|
|
29
|
-
return
|
|
29
|
+
return r(this, null, function* () {
|
|
30
30
|
return this.get(t, e);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
getAIoTTokenByGTeamToken(t) {
|
|
34
|
-
return
|
|
34
|
+
return r(this, null, function* () {
|
|
35
35
|
return this.post("/validate/glodonCloud", t).then((e) => e.accessToken);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
postRefreshToken(t, e, n, s = "3600", p) {
|
|
39
|
-
return
|
|
39
|
+
return r(this, null, function* () {
|
|
40
40
|
return this.post("/refresh-token", {
|
|
41
41
|
oldToken: t,
|
|
42
42
|
tenant: e,
|
|
@@ -46,7 +46,12 @@ class m extends c {
|
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
logout() {
|
|
50
|
+
return r(this, null, function* () {
|
|
51
|
+
return this.post("/logout", {});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
export {
|
|
51
|
-
|
|
56
|
+
y as AuthApi
|
|
52
57
|
};
|