@glodon-aiot/apis 0.0.0-20251106104234

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.
Files changed (62) hide show
  1. package/README.git.md +73 -0
  2. package/README.lib.md +135 -0
  3. package/dist/es/aecpilot/cosntant.mjs +5 -0
  4. package/dist/es/aecpilot/index.mjs +522 -0
  5. package/dist/es/aecpilot/model.mjs +9 -0
  6. package/dist/es/aecpilotui/index.mjs +389 -0
  7. package/dist/es/aishop/index.mjs +97 -0
  8. package/dist/es/aishop/model.mjs +5 -0
  9. package/dist/es/auth/index.mjs +57 -0
  10. package/dist/es/base/index.mjs +158 -0
  11. package/dist/es/bot-client/index.mjs +418 -0
  12. package/dist/es/contralyze/index.mjs +91 -0
  13. package/dist/es/cvforce/index.mjs +440 -0
  14. package/dist/es/cvforce/model.mjs +13 -0
  15. package/dist/es/cvforce-datahub/index.mjs +431 -0
  16. package/dist/es/cvforce-datahub/model.mjs +8 -0
  17. package/dist/es/cvforce-modelservice/index.mjs +114 -0
  18. package/dist/es/cvforce-modelservice/model.mjs +4 -0
  19. package/dist/es/index.mjs +63 -0
  20. package/dist/es/panorama/index.mjs +136 -0
  21. package/dist/es/panorama/model.mjs +5 -0
  22. package/dist/es/pluginmgr/index.mjs +85 -0
  23. package/dist/es/user/index.mjs +193 -0
  24. package/dist/es/utils/fetchEventSource/fetch.mjs +112 -0
  25. package/dist/es/utils/fetchEventSource/parse.mjs +97 -0
  26. package/dist/es/utils/index.mjs +9 -0
  27. package/dist/lib/index.js +3 -0
  28. package/dist/src/aecpilot/cosntant.d.ts +8 -0
  29. package/dist/src/aecpilot/index.d.ts +79 -0
  30. package/dist/src/aecpilot/model.d.ts +359 -0
  31. package/dist/src/aecpilotui/index.d.ts +72 -0
  32. package/dist/src/aecpilotui/model.d.ts +66 -0
  33. package/dist/src/agentcliui/index.d.ts +72 -0
  34. package/dist/src/agentcliui/model.d.ts +39 -0
  35. package/dist/src/aishop/index.d.ts +26 -0
  36. package/dist/src/aishop/model.d.ts +111 -0
  37. package/dist/src/auth/index.d.ts +18 -0
  38. package/dist/src/auth/model.d.ts +24 -0
  39. package/dist/src/base/index.d.ts +41 -0
  40. package/dist/src/base/model.d.ts +21 -0
  41. package/dist/src/bot-client/index.d.ts +74 -0
  42. package/dist/src/bot-client/model.d.ts +39 -0
  43. package/dist/src/contralyze/index.d.ts +24 -0
  44. package/dist/src/contralyze/model.d.ts +75 -0
  45. package/dist/src/cvforce/index.d.ts +139 -0
  46. package/dist/src/cvforce/model.d.ts +529 -0
  47. package/dist/src/cvforce-datahub/index.d.ts +186 -0
  48. package/dist/src/cvforce-datahub/model.d.ts +438 -0
  49. package/dist/src/cvforce-modelservice/index.d.ts +23 -0
  50. package/dist/src/cvforce-modelservice/model.d.ts +156 -0
  51. package/dist/src/index.d.ts +20 -0
  52. package/dist/src/panorama/index.d.ts +42 -0
  53. package/dist/src/panorama/model.d.ts +263 -0
  54. package/dist/src/pluginmgr/index.d.ts +28 -0
  55. package/dist/src/pluginmgr/model.d.ts +48 -0
  56. package/dist/src/user/index.d.ts +42 -0
  57. package/dist/src/user/model.d.ts +247 -0
  58. package/dist/src/utils/fetchEventSource/fetch.d.ts +44 -0
  59. package/dist/src/utils/fetchEventSource/index.d.ts +1 -0
  60. package/dist/src/utils/fetchEventSource/parse.d.ts +36 -0
  61. package/dist/src/utils/index.d.ts +1 -0
  62. package/package.json +88 -0
@@ -0,0 +1,522 @@
1
+ var P = Object.defineProperty, K = Object.defineProperties;
2
+ var b = Object.getOwnPropertyDescriptors;
3
+ var T = Object.getOwnPropertySymbols;
4
+ var E = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
5
+ var $ = (g, e, t) => e in g ? P(g, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[e] = t, f = (g, e) => {
6
+ for (var t in e || (e = {}))
7
+ E.call(e, t) && $(g, t, e[t]);
8
+ if (T)
9
+ for (var t of T(e))
10
+ F.call(e, t) && $(g, t, e[t]);
11
+ return g;
12
+ }, S = (g, e) => K(g, b(e));
13
+ var r = (g, e, t) => new Promise((o, n) => {
14
+ var s = (i) => {
15
+ try {
16
+ h(t.next(i));
17
+ } catch (c) {
18
+ n(c);
19
+ }
20
+ }, m = (i) => {
21
+ try {
22
+ h(t.throw(i));
23
+ } catch (c) {
24
+ n(c);
25
+ }
26
+ }, h = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(s, m);
27
+ h((t = t.apply(g, e)).next());
28
+ });
29
+ import O from "axios";
30
+ import { BaseApi as v } from "../base/index.mjs";
31
+ import { initMinio as C, putObjectBuffer as H } from "@glodon-aiot/minio";
32
+ import { IHistoryRole as k, AecKnowledgeFileStatus as R } from "./model.mjs";
33
+ import { IFileOrigin as W, ISourceType as X, IThinkingStatus as q, IversionInfo as Z } from "./model.mjs";
34
+ import { v4 as w } from "uuid";
35
+ import Q from "dayjs";
36
+ import { PROMPT_SEARCH_MAX_LENGTH as x } from "./cosntant.mjs";
37
+ import { PROMPT_TITLE_MAX_LENGTH as se } from "./cosntant.mjs";
38
+ import { fetchEventSource as A } from "../utils/fetchEventSource/fetch.mjs";
39
+ class z extends v {
40
+ constructor(e, t, o) {
41
+ super(e != null ? e : O.create(), o), this.axiosInstance = e, this.getToken = t;
42
+ }
43
+ // 会话
44
+ getSessions() {
45
+ return r(this, null, function* () {
46
+ return this.get("/chatSession");
47
+ });
48
+ }
49
+ postSession(e) {
50
+ return r(this, null, function* () {
51
+ return this.post("/chatSession", e);
52
+ });
53
+ }
54
+ getSession(e) {
55
+ return r(this, null, function* () {
56
+ return this.get(`/chatSession/${e}`);
57
+ });
58
+ }
59
+ updateSession(e, t) {
60
+ return r(this, null, function* () {
61
+ return this.patch(`/chatSession/${e}`, t);
62
+ });
63
+ }
64
+ deleteSession(e) {
65
+ return r(this, null, function* () {
66
+ return this.delete(`/chatSession/${e}`);
67
+ });
68
+ }
69
+ // 会话文件
70
+ getSessionKnowledgeFiles(e, t) {
71
+ return r(this, null, function* () {
72
+ return this.get(`chatSession/${e}/file`, t);
73
+ });
74
+ }
75
+ postSessionKnowledgeFile(e, t) {
76
+ return r(this, null, function* () {
77
+ return this.post(`chatSession/${e}/file`, t);
78
+ });
79
+ }
80
+ deleteSessionKnowledgeFiles(e, t) {
81
+ return r(this, null, function* () {
82
+ return this.delete(`chatSession/${e}/file`, t);
83
+ });
84
+ }
85
+ getSessionKnowledgeFile(e, t) {
86
+ return r(this, null, function* () {
87
+ return this.get(`chatSession/${e}/file/${t}`);
88
+ });
89
+ }
90
+ deleteSessionKnowledgeFile(e, t) {
91
+ return r(this, null, function* () {
92
+ return this.delete(`chatSession/${e}/file/${t}`);
93
+ });
94
+ }
95
+ // 会话历史
96
+ getSessionChatHistory(e, t) {
97
+ return r(this, null, function* () {
98
+ return this.get(`/chatSession/${e}/history`, t);
99
+ });
100
+ }
101
+ // 聊天
102
+ postMessage(e, t, o) {
103
+ return r(this, null, function* () {
104
+ return this.post(`/config/tenantApplication?applicationId=${e}&sessionId=${t}`, o);
105
+ });
106
+ }
107
+ // 评价
108
+ postComments(e, t) {
109
+ return r(this, null, function* () {
110
+ return this.post(`/chatSession/${e}/comments`, t);
111
+ });
112
+ }
113
+ // 租户应用
114
+ listApplications() {
115
+ return r(this, null, function* () {
116
+ return this.list("/applications");
117
+ });
118
+ }
119
+ getApplication() {
120
+ return r(this, null, function* () {
121
+ return this.get("/config/tenantApplication");
122
+ });
123
+ }
124
+ postApplication(e) {
125
+ return r(this, null, function* () {
126
+ return this.post("/config/tenantApplication", {
127
+ applicationId: e
128
+ });
129
+ });
130
+ }
131
+ // 推荐问题
132
+ getRecommendQues() {
133
+ return r(this, null, function* () {
134
+ return this.get("/recommendQues");
135
+ });
136
+ }
137
+ postRecommendQues(e) {
138
+ return r(this, null, function* () {
139
+ return this.post("/recommendQues", e);
140
+ });
141
+ }
142
+ patchRecommendQues(e, t) {
143
+ return r(this, null, function* () {
144
+ return this.patch(`/recommendQues/${e}`, t);
145
+ });
146
+ }
147
+ delRecommendQues(e) {
148
+ return r(this, null, function* () {
149
+ return this.delete(`/recommendQues/${e}`);
150
+ });
151
+ }
152
+ // 文件上传
153
+ getUploadTicket(e) {
154
+ return r(this, null, function* () {
155
+ return this.get("/upload/ticket", e);
156
+ });
157
+ }
158
+ uploadMinioFile(e, t) {
159
+ return r(this, null, function* () {
160
+ return new Promise((o, n) => {
161
+ const s = new FileReader();
162
+ s.readAsArrayBuffer(t), s.onload = (m) => {
163
+ C({
164
+ endPoint: e.endpoints[0],
165
+ useSSL: e.useSSL,
166
+ accessKey: e.accessKey,
167
+ secretKey: e.secretKey
168
+ });
169
+ const h = new Uint8Array(m.target.result), i = {
170
+ "Content-Type": "application/octet-stream"
171
+ };
172
+ H(e.bucket, e.fileKeys[0], h, i, (c) => {
173
+ if (c)
174
+ throw console.error(c), Error(c);
175
+ o(e.fileKeys[0]);
176
+ });
177
+ };
178
+ });
179
+ });
180
+ }
181
+ uploadFile(e, t) {
182
+ return r(this, null, function* () {
183
+ const o = {
184
+ files: [t.name],
185
+ isv: "minio",
186
+ knowledgeId: e
187
+ };
188
+ return this.postUploadTicket(o).then((n) => this.uploadMinioFile(n, t)).catch((n) => {
189
+ throw Error(n);
190
+ });
191
+ });
192
+ }
193
+ uploadFiles(e, t) {
194
+ return r(this, null, function* () {
195
+ const o = {
196
+ files: t.map((n) => n.name),
197
+ isv: "minio",
198
+ knowledgeId: e
199
+ };
200
+ return this.postUploadTicket(o).then((n) => Promise.all(t.map((s) => this.uploadMinioFile(n, s)))).catch((n) => {
201
+ throw Error(n);
202
+ });
203
+ });
204
+ }
205
+ getKnowledge(e, t) {
206
+ return r(this, null, function* () {
207
+ return this.get("/knowledge", {
208
+ docId: e,
209
+ name: t
210
+ });
211
+ });
212
+ }
213
+ //
214
+ getKnowledgeIdFileId(e, t) {
215
+ return r(this, null, function* () {
216
+ return this.get(`/knowledge/${e}/file/${t}`);
217
+ });
218
+ }
219
+ updateKnowledgeIdFileId(e, t, o) {
220
+ return r(this, null, function* () {
221
+ return this.patch(`/chatSession/${e}/file/${t}`, o);
222
+ });
223
+ }
224
+ getKnowledgeIdFileIdData(e, t, o) {
225
+ return r(this, null, function* () {
226
+ return this.get(`/knowledge/${e}/file/${t}/data/${o}`);
227
+ });
228
+ }
229
+ // 文件详情
230
+ checkFileReady(e, t, o = () => !0, n = 1e4, s) {
231
+ return r(this, null, function* () {
232
+ return new Promise((m, h) => {
233
+ const i = () => {
234
+ if (!o()) {
235
+ clearInterval(c);
236
+ return;
237
+ }
238
+ t ? this.getSessionKnowledgeFile(e, t).then((a) => {
239
+ if (s == null || s(a), a.status === R.Success && (clearInterval(c), m(a)), a.status === R.Failed) {
240
+ clearInterval(c);
241
+ const l = "该文件无法读取,请上传可编辑pdf,doc,docx文档";
242
+ h(Error(l, {
243
+ cause: {
244
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
245
+ // @ts-ignore
246
+ code: -101,
247
+ message: l,
248
+ data: a
249
+ }
250
+ }));
251
+ }
252
+ }).catch((a) => {
253
+ clearInterval(c), h(a);
254
+ }) : m(null);
255
+ }, c = setInterval(i, n);
256
+ i();
257
+ });
258
+ });
259
+ }
260
+ postChat(e, t) {
261
+ return r(this, null, function* () {
262
+ return this.post("/chat", e, t);
263
+ });
264
+ }
265
+ // IChatParam
266
+ postChatV2EventSource(e, t, o, n) {
267
+ return r(this, null, function* () {
268
+ var i;
269
+ const s = {
270
+ code: 0,
271
+ messageId: w(),
272
+ content: "",
273
+ role: k.Robot,
274
+ sessionId: "",
275
+ reference: [],
276
+ searchReference: [],
277
+ messageTime: "",
278
+ llmModel: "",
279
+ comment: {
280
+ isAgree: 0
281
+ },
282
+ isReplying: !1
283
+ }, m = yield this.getToken(), h = S(f({}, t), {
284
+ stream: !0
285
+ });
286
+ A(`${(i = this.axiosInstance) == null ? void 0 : i.defaults.baseURL}/chat?sessionId=${e}`, {
287
+ method: "POST",
288
+ headers: {
289
+ Authorization: `Bearer ${m}`,
290
+ "Content-Type": "application/json"
291
+ },
292
+ body: JSON.stringify(h),
293
+ openWhenHidden: !0,
294
+ signal: o,
295
+ onopen(c) {
296
+ return c.ok && n != null && n.onopen && n.onopen(), Promise.resolve();
297
+ },
298
+ onmessage(c) {
299
+ if (!c.data && !c.event && !c.id && !c.retry)
300
+ return;
301
+ if (!c.data.includes('{"code": ')) {
302
+ let a = {};
303
+ try {
304
+ a = JSON.parse(c.data);
305
+ } catch (u) {
306
+ }
307
+ (a == null ? void 0 : a.mtype) === "search" ? s.searchReference.push(a) : s.content = s.content + c.data;
308
+ const l = {
309
+ content: s.content,
310
+ role: 1,
311
+ reference: s.reference,
312
+ searchReference: s.searchReference,
313
+ messageId: s.messageId,
314
+ sessionId: e,
315
+ messageTime: Q(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
316
+ comment: {
317
+ isAgree: 0
318
+ },
319
+ isReplying: !0
320
+ };
321
+ return (n == null ? void 0 : n.onmessage) && n.onmessage(l);
322
+ }
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
+ code: s.code,
327
+ content: s.content,
328
+ role: 1,
329
+ reference: s.reference,
330
+ searchReference: s.searchReference,
331
+ messageId: s.messageId,
332
+ sessionId: e,
333
+ messageTime: s.messageTime,
334
+ isReplying: !0
335
+ };
336
+ n != null && n.onmessage && n.onmessage(a);
337
+ }
338
+ },
339
+ onerror() {
340
+ n != null && n.onerror && n.onerror();
341
+ },
342
+ onclose() {
343
+ const c = {
344
+ code: s.code,
345
+ content: s.content,
346
+ role: 1,
347
+ reference: s.reference,
348
+ searchReference: s.searchReference,
349
+ messageId: s.messageId,
350
+ sessionId: e,
351
+ messageTime: s.messageTime,
352
+ comment: {
353
+ isAgree: 0
354
+ },
355
+ isReplying: !1
356
+ };
357
+ n != null && n.onclose && n.onclose(c);
358
+ }
359
+ });
360
+ });
361
+ }
362
+ postChatV3EventSource(e, t, o, n) {
363
+ return r(this, null, function* () {
364
+ var i, c;
365
+ const s = {
366
+ code: 0,
367
+ messageId: w(),
368
+ content: "",
369
+ role: k.Robot,
370
+ sessionId: "",
371
+ reference: [],
372
+ searchReference: [],
373
+ messageTime: "",
374
+ llmModel: "",
375
+ comment: {
376
+ isAgree: 0
377
+ },
378
+ isReplying: !1,
379
+ reasoningContent: "",
380
+ thinkingSecs: "",
381
+ thinkingStatus: "",
382
+ searchingStatus: ""
383
+ }, m = yield this.getToken(), h = S(f({}, t), {
384
+ stream: !0
385
+ });
386
+ A(`${(c = (i = this.axiosInstance) == null ? void 0 : i.defaults.baseURL) == null ? void 0 : c.replace("/v1", "/v3")}/chat?sessionId=${e}`, {
387
+ method: "POST",
388
+ headers: {
389
+ Authorization: `Bearer ${m}`,
390
+ "Content-Type": "application/json"
391
+ },
392
+ body: JSON.stringify(h),
393
+ openWhenHidden: !0,
394
+ signal: o,
395
+ onopen(d) {
396
+ return d.ok && n != null && n.onopen && n.onopen(), Promise.resolve();
397
+ },
398
+ onmessage(d) {
399
+ if (!d.data && !d.event && !d.id && !d.retry)
400
+ return;
401
+ let a = {};
402
+ try {
403
+ a = JSON.parse(d.data);
404
+ } catch (p) {
405
+ console.log("eventData", d.data);
406
+ }
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 y = u.choices[0];
422
+ s.reasoningContent = s.reasoningContent + y.delta.reasoningContent;
423
+ }
424
+ if (l === "thinkingOver") {
425
+ s.code = a.code, s.message = a.message, s.thinkingStatus = "end";
426
+ const p = u.thinkingSecs;
427
+ s.thinkingSecs = p;
428
+ }
429
+ if (l === "text") {
430
+ I(), s.code = a.code, s.message = a.message;
431
+ const y = u.choices[0];
432
+ s.content = s.content + y.delta.content;
433
+ }
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 p = u.messageId, y = u.llmModel, M = u.messageTime;
437
+ s.messageId = p, s.llmModel = y, s.messageTime = M, s.sessionId = e;
438
+ }
439
+ n != null && n.onmessage && n.onmessage(s);
440
+ },
441
+ onerror() {
442
+ n != null && n.onerror && n.onerror();
443
+ },
444
+ onclose() {
445
+ const d = S(f({}, s), {
446
+ isReplying: !1
447
+ });
448
+ n != null && n.onclose && n.onclose(d);
449
+ }
450
+ });
451
+ });
452
+ }
453
+ getResourceToken(e) {
454
+ return r(this, null, function* () {
455
+ return this.get("/resourceToken", e);
456
+ });
457
+ }
458
+ postUploadTicket(e) {
459
+ return r(this, null, function* () {
460
+ return this.post("/upload/ticket", e);
461
+ });
462
+ }
463
+ //常用提示词
464
+ postPrompts(e) {
465
+ return r(this, null, function* () {
466
+ return this.post("/prompts", e);
467
+ });
468
+ }
469
+ listPrompt(e) {
470
+ return r(this, null, function* () {
471
+ return e != null && e.title && e.title.length > x ? [] : this.get("/prompts", e);
472
+ });
473
+ }
474
+ getPrompt(e) {
475
+ return r(this, null, function* () {
476
+ return this.get(`/prompts/${e}`);
477
+ });
478
+ }
479
+ updatePrompt(e, t) {
480
+ return r(this, null, function* () {
481
+ return this.put(`/prompts/${e}`, t);
482
+ });
483
+ }
484
+ deletePrompt(e) {
485
+ return r(this, null, function* () {
486
+ return this.delete(`/prompts/${e}`);
487
+ });
488
+ }
489
+ chatSessionIdContext(e) {
490
+ return r(this, null, function* () {
491
+ return this.patch(`/chatSession/${e}/context`, {});
492
+ });
493
+ }
494
+ getBaseModelInfo(e) {
495
+ return r(this, null, function* () {
496
+ return this.get("/data/v1/baseModelInfo", {
497
+ serviceId: e
498
+ });
499
+ });
500
+ }
501
+ getApplicationId(e) {
502
+ return r(this, null, function* () {
503
+ return this.get(`/applications/${e}`);
504
+ });
505
+ }
506
+ getAppService() {
507
+ return r(this, null, function* () {
508
+ return this.get("/appservice");
509
+ });
510
+ }
511
+ }
512
+ export {
513
+ z as AECPilotApi,
514
+ R as AecKnowledgeFileStatus,
515
+ W as IFileOrigin,
516
+ k as IHistoryRole,
517
+ X as ISourceType,
518
+ q as IThinkingStatus,
519
+ Z as IversionInfo,
520
+ x as PROMPT_SEARCH_MAX_LENGTH,
521
+ se as PROMPT_TITLE_MAX_LENGTH
522
+ };
@@ -0,0 +1,9 @@
1
+ var t = /* @__PURE__ */ ((r) => (r[r.None = 0] = "None", r[r.SourceFile = 1] = "SourceFile", r[r.WebLink = 2] = "WebLink", r))(t || {}), a = /* @__PURE__ */ ((r) => (r.Unprotected = "不受著作权保护", r.ProtectAuthorize = "受著作权保护,已获得授权", r.ProtectUnauthorize = "受著作权保护,未获得授权", r))(a || {}), n = /* @__PURE__ */ ((r) => (r[r.Robot = 1] = "Robot", r[r.User = 2] = "User", r[r.System = 3] = "System", r))(n || {}), P = /* @__PURE__ */ ((r) => (r.Start = "start", r.End = "end", r))(P || {}), b = /* @__PURE__ */ ((r) => (r[r.Processing = 1] = "Processing", r[r.Success = 2] = "Success", r[r.Failed = 3] = "Failed", r))(b || {}), v = /* @__PURE__ */ ((r) => (r.AECPILOT = "aecpilot", r))(v || {});
2
+ export {
3
+ b as AecKnowledgeFileStatus,
4
+ v as IFileOrigin,
5
+ n as IHistoryRole,
6
+ t as ISourceType,
7
+ P as IThinkingStatus,
8
+ a as IversionInfo
9
+ };