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