china-mobile-international-custom-components 0.0.58 → 0.0.59

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,1010 +0,0 @@
1
- import { w as ge } from "./index.bCzIhWFw.js";
2
- import { createElementBlock as E, openBlock as c, Fragment as P, createCommentVNode as h, unref as e, renderSlot as _e, createVNode as a, withCtx as d, renderList as Y, createBlock as w, createElementVNode as M, resolveDynamicComponent as ue, toDisplayString as R, createTextVNode as S, normalizeClass as ve, computed as me, ref as g, onMounted as Re, reactive as Ae } from "vue";
3
- import { u as ce } from "./i18n.Bd7hh14j.js";
4
- import { g as F } from "./request.24c3shPx.js";
5
- import { ElRow as De, ElCol as Ce, ElIcon as N, ElButton as V, ElMessage as G, ElForm as Ie, ElFormItem as x, ElInput as k, ElSelect as we, ElOption as Te } from "element-plus";
6
- import { IconDelete as pe, IconHide as ye, IconWarn as Ne, IconGoto3 as Oe, Workflow as he } from "color-message-aibox-vue";
7
- import { UploadTypesEnum as re, FileUploader as be } from "../FileUploader.mjs";
8
- import "viewerjs/dist/viewer.css";
9
- import { api as ie } from "v-viewer";
10
- import { downloadBlobFile as Ee } from "@/utils/downloadBlobFile";
11
- import { _ as Z } from "./_plugin-vue_export-helper.CHgC5LLL.js";
12
- import { useDialog as fe, DialogContainer as Le } from "../DialogContainer.mjs";
13
- import { useRouter as xe } from "vue-router";
14
- import '../assets/index3.css';const Me = () => {
15
- const { $request: l, $env: r } = F();
16
- return {
17
- deleteKey: (_) => l({
18
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/model/key/${_}`,
19
- method: "delete"
20
- }),
21
- deleteOwnerModel: (_) => l({
22
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/model/${_}`,
23
- method: "delete"
24
- }),
25
- addModel: (_) => l({
26
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/model`,
27
- method: "post",
28
- data: _
29
- }),
30
- updateModel: (_, L) => l({
31
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/model/${_}`,
32
- method: "put",
33
- data: L
34
- })
35
- };
36
- }, Pe = (l) => /(txt|yaml)/i.test(l), Ue = (l) => /ppt|pptx/i.test(l), Be = (l) => /pdf/i.test(l);
37
- function ke(l) {
38
- return /(docx|doc|msword)/i.test(l);
39
- }
40
- function Se(l) {
41
- return /(xlsx|xls|sheet|csv)/i.test(l);
42
- }
43
- function $e(l) {
44
- return /(zip|rar|7z)$/i.test(l);
45
- }
46
- const q = (l) => /(jpe?g|png|bmp|gif|webp|svg|ico)(\?.*)?$/i.test(l), Ve = (l) => /(mp4|avi|rmvb|rm|wmv|flv|3gp|mkv|mov)(\?.*)?$/i.test(l), Ye = (l) => /(mp3|wav|wma|aac|flac)(\?.*)?$/i.test(l), Fe = (l) => /(md|markdown)/i.test(l), Ke = (l) => /(html|htm|xhtml|xml)/i.test(l), He = (l) => /(json)/i.test(l), Xe = (l) => {
47
- if (Be(l.suffix))
48
- return "Pdf1";
49
- if (ke(l.suffix))
50
- return "Doc";
51
- if (Se(l.suffix))
52
- return "Excel1";
53
- if (Ve(l.suffix))
54
- return "Video";
55
- if (Ye(l.suffix))
56
- return "Music";
57
- if (Ue(l.suffix))
58
- return "Ppt1";
59
- if (Fe(l.suffix))
60
- return "Md";
61
- if (Ke(l.suffix))
62
- return "Html";
63
- if (Pe(l.suffix))
64
- return "Txt1";
65
- if (He(l.suffix))
66
- return "Other";
67
- if ($e(l.suffix))
68
- return "Other";
69
- }, de = () => {
70
- const { $request: l, $env: r } = F();
71
- return {
72
- commonDownloadInterior: (O) => l({
73
- method: "get",
74
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/common/file/download/streams`,
75
- params: O,
76
- responseType: "arraybuffer"
77
- }),
78
- commonDownloadForeign: (O) => l({
79
- method: "get",
80
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/common/file/download/urls`,
81
- params: O
82
- }),
83
- commonFileDelete: (O) => l({
84
- method: "delete",
85
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/common/file`,
86
- params: O
87
- })
88
- };
89
- }, Ge = () => ({
90
- downloadPrew: async (u) => {
91
- const { commonDownloadForeign: O } = de(), { data: _ } = await O({ "file-ids": [u.bnid] });
92
- _ && (q(u.suffix) || q(_[0].suffix) ? (_ && _.length, ie({
93
- images: [_[0].url],
94
- options: {
95
- zIndex: 3e3
96
- }
97
- })) : window.open(_[0].url, "_blank"));
98
- },
99
- downloadStreamPrew: async (u) => {
100
- const { commonDownloadInterior: O } = de(), _ = await O({ "file-ids": [u.bnid] });
101
- if (_)
102
- if (q(u.suffix)) {
103
- const L = Ee(_, u.name, "image");
104
- _ && ie({
105
- images: [L],
106
- options: {
107
- zIndex: 3e3
108
- }
109
- });
110
- } else
111
- Ee(_, u.name);
112
- },
113
- previewImage: (u) => {
114
- ie({
115
- images: [u],
116
- options: {
117
- zIndex: 3e3
118
- }
119
- });
120
- },
121
- deleteFile: async (u) => {
122
- const { commonFileDelete: O } = de();
123
- await O({ "file-ids": [u.bnid] });
124
- }
125
- }), qe = {
126
- key: 0,
127
- class: "panel-preview"
128
- }, ze = { class: "panel-preview__item" }, je = ["onClick"], We = ["src", "alt"], Qe = { class: "panel-preview__name ellipsis" }, Je = { key: 0 }, Ze = { key: 1 }, el = {
129
- key: 1,
130
- class: "upload-preview"
131
- }, ll = ["src", "alt"], tl = { class: "preview-item__mask" }, ol = {
132
- __name: "FilePreview",
133
- props: {
134
- fileList: {
135
- type: Array,
136
- default: () => []
137
- },
138
- canEdit: {
139
- type: Boolean,
140
- default: !0
141
- },
142
- previewType: {
143
- type: String,
144
- default: re.面板
145
- },
146
- isStream: {
147
- type: Boolean,
148
- default: !1
149
- },
150
- isCustom: {
151
- type: Boolean,
152
- default: !1
153
- }
154
- },
155
- emits: ["on-remove", "on-preview"],
156
- setup(l, { emit: r }) {
157
- const { downloadPrew: f, downloadStreamPrew: t } = Ge(), { t: u } = ce(), O = l, _ = r, L = (p) => Xe(p);
158
- function $(p) {
159
- O.isCustom ? _("on-preview", p) : O.isStream ? t(p) : f(p);
160
- }
161
- function A(p, D) {
162
- _("on-remove", p, D);
163
- }
164
- return (p, D) => (c(), E(P, null, [
165
- l.previewType === e(re).面板 ? (c(), E("div", qe, [
166
- _e(p.$slots, "PanelUploader", {}, void 0, !0),
167
- a(e(De), {
168
- gutter: 20,
169
- class: "panel-preview__row"
170
- }, {
171
- default: d(() => [
172
- (c(!0), E(P, null, Y(l.fileList, (m, C) => (c(), w(e(Ce), {
173
- span: 8,
174
- key: m.bnid
175
- }, {
176
- default: d(() => [
177
- M("div", ze, [
178
- M("div", {
179
- class: "panel-preview__box",
180
- onClick: (b) => $(m)
181
- }, [
182
- e(q)(m.suffix) ? (c(), E("img", {
183
- key: 0,
184
- src: m.url,
185
- alt: m.name,
186
- class: "panel-preview__img"
187
- }, null, 8, We)) : (c(), w(e(N), {
188
- key: 1,
189
- size: "32px",
190
- class: "panel-preview__img"
191
- }, {
192
- default: d(() => [
193
- (c(), w(ue(L(m))))
194
- ]),
195
- _: 2
196
- }, 1024)),
197
- M("span", Qe, R(m.name), 1)
198
- ], 8, je),
199
- m.isUploading ? (c(), E("div", Je, [
200
- a(e(V), {
201
- text: "",
202
- size: "small",
203
- loading: ""
204
- }, {
205
- default: d(() => [
206
- S(R(e(u)("COMPONENTS.UPLOADING")) + "...", 1)
207
- ]),
208
- _: 1
209
- })
210
- ])) : (c(), E("div", Ze, [
211
- l.canEdit ? (c(), w(e(N), {
212
- key: 0,
213
- size: "18",
214
- style: { cursor: "pointer" },
215
- onClick: (b) => A(C, m)
216
- }, {
217
- default: d(() => [
218
- a(e(pe))
219
- ]),
220
- _: 1
221
- }, 8, ["onClick"])) : h("", !0)
222
- ]))
223
- ])
224
- ]),
225
- _: 2
226
- }, 1024))), 128))
227
- ]),
228
- _: 1
229
- })
230
- ])) : h("", !0),
231
- l.previewType === e(re).卡片 ? (c(), E("ul", el, [
232
- (c(!0), E(P, null, Y(l.fileList, (m, C) => (c(), E("li", {
233
- class: "preview-item",
234
- key: m.bnid
235
- }, [
236
- e(q)(m.suffix) ? (c(), E("img", {
237
- key: 0,
238
- src: m.url,
239
- alt: m.name,
240
- class: "preview-item__img"
241
- }, null, 8, ll)) : (c(), w(e(N), {
242
- key: 1,
243
- size: "32px",
244
- class: "preview-item__img"
245
- }, {
246
- default: d(() => [
247
- (c(), w(ue(L(m))))
248
- ]),
249
- _: 2
250
- }, 1024)),
251
- M("div", tl, [
252
- a(e(N), {
253
- class: "preview-item__mask--view",
254
- onClick: (b) => $(m)
255
- }, {
256
- default: d(() => [
257
- a(e(ye))
258
- ]),
259
- _: 1
260
- }, 8, ["onClick"]),
261
- l.canEdit ? (c(), w(e(N), {
262
- key: 0,
263
- class: "preview-item__mask--delete",
264
- onClick: (b) => A(C, m)
265
- }, {
266
- default: d(() => [
267
- a(e(pe))
268
- ]),
269
- _: 1
270
- }, 8, ["onClick"])) : h("", !0)
271
- ])
272
- ]))), 128)),
273
- _e(p.$slots, "CardUploader", {}, void 0, !0)
274
- ])) : h("", !0)
275
- ], 64));
276
- }
277
- }, sl = /* @__PURE__ */ Z(ol, [["__scopeId", "data-v-256f8de6"]]), nl = () => {
278
- const { $request: l, $env: r } = F();
279
- return {
280
- getSystemReference: (t) => l({
281
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/system/reference`,
282
- method: "get",
283
- params: t
284
- })
285
- };
286
- }, al = () => {
287
- const { $request: l, $env: r } = F();
288
- return {
289
- deleteKnowledgeBase: (t) => l({
290
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/library/${t}`,
291
- method: "delete"
292
- })
293
- };
294
- }, rl = () => {
295
- const { $request: l, $env: r } = F();
296
- return {
297
- del: (t) => l({
298
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/workflow/${t}`,
299
- method: "delete"
300
- })
301
- };
302
- }, il = () => {
303
- const { $request: l, $env: r } = F();
304
- return {
305
- deleteId: (u) => l({
306
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/plugin/${u}`,
307
- method: "delete"
308
- }),
309
- deleteTools: (u) => l({
310
- url: `${r.VITE_APP_AIBOX_BASE_URL}/api/v1/plugin/tools/${u}`,
311
- method: "delete"
312
- })
313
- };
314
- }, dl = { class: "ai-box-tabs overflow-hidden" }, ul = ["onClick"], cl = {
315
- __name: "AiboxTabs",
316
- props: {
317
- modelValue: {
318
- type: [String, Number],
319
- default: () => ""
320
- },
321
- tabList: {
322
- type: Array,
323
- default: () => []
324
- }
325
- },
326
- emits: ["update:modelValue", "change"],
327
- setup(l, { emit: r }) {
328
- const f = r, t = (u) => {
329
- f("update:modelValue", u.value), f("change", u.value);
330
- };
331
- return (u, O) => (c(), E("div", dl, [
332
- M("ul", null, [
333
- (c(!0), E(P, null, Y(l.tabList, (_) => (c(), E("li", {
334
- key: _.value,
335
- onClick: (L) => t(_),
336
- class: ve(l.modelValue === _.value ? "current" : "")
337
- }, R(_.label), 11, ul))), 128))
338
- ])
339
- ]));
340
- }
341
- }, _l = /* @__PURE__ */ Z(cl, [["__scopeId", "data-v-f526f5ca"]]), pl = { class: "delete-title" }, Ol = { class: "custom-message-box" }, El = {
342
- class: "custom-message-box__title",
343
- style: { "line-height": "24px" }
344
- }, ml = { style: { color: "red" } }, fl = {
345
- key: 0,
346
- class: "custom-message-box__tip"
347
- }, Ll = {
348
- key: 0,
349
- class: "delete-tabs"
350
- }, Ml = {
351
- key: 0,
352
- class: "resource-list"
353
- }, gl = ["onClick"], vl = { class: "item-title" }, Rl = {
354
- key: 1,
355
- class: "resource-list"
356
- }, Al = ["onClick"], Dl = { class: "item-title" }, Cl = { class: "dialog-footer" }, Il = {
357
- __name: "DeleteResourceDialog",
358
- props: {
359
- title: {
360
- type: String,
361
- default: ""
362
- },
363
- deleteType: {
364
- type: String,
365
- default: ""
366
- }
367
- },
368
- emits: ["success"],
369
- setup(l, { expose: r, emit: f }) {
370
- const { getSystemReference: t } = nl(), { deleteKnowledgeBase: u } = al(), { del: O } = rl(), { deleteId: _, deleteTools: L } = il(), { deleteKey: $, deleteOwnerModel: A } = Me(), { t: p } = ce(), D = xe(), { dialogRef: m, showDialog: C, hideDialog: b } = fe(), z = l, K = f, i = me(() => {
371
- const o = [];
372
- return T.value.length && o.push({
373
- // label: `${t('PLUGINLIST.APPLICATION_REFERENCED') || '已发布应用引用'}(${applyList.value.length})`,
374
- label: p("COMPONENTS_OUTER_SPHERE.APPLICATION_REFERENCE", {
375
- num: T.value.length
376
- }),
377
- value: "1"
378
- }), y.value.length && o.push({
379
- // label: `${t('PLUGINLIST.APPLICATION_REFERENCED_INFO') || '已发布工作流引用'}(${workflowList.value.length})`,
380
- label: p("COMPONENTS_OUTER_SPHERE.WORKFLOW_REFERENCE", {
381
- num: y.value.length
382
- }),
383
- value: "2"
384
- }), o;
385
- }), U = g("1"), v = g(""), T = g([]), y = g([]), ee = (o) => {
386
- const n = {
387
- model: {
388
- code: 1,
389
- desc: p("COMMON_TAG.APPLICATION"),
390
- deleteFn: async () => await A(v.value)
391
- },
392
- knowledge: {
393
- code: 2,
394
- desc: p("COMMON_TAG.KNOWLEDGE_BASE"),
395
- deleteFn: async () => await u(v.value)
396
- },
397
- workflow: {
398
- code: 4,
399
- desc: p("COMMON_TAG.WORKFLOW"),
400
- deleteFn: async () => await O(v.value)
401
- },
402
- plugin: {
403
- code: 6,
404
- desc: p("COMMON_TAG.PLUGIN"),
405
- deleteFn: async () => await _(v.value)
406
- },
407
- pluglit: {
408
- code: 6,
409
- desc: p("COMMON_TAG.TOOL"),
410
- deleteFn: async () => await L(v.value)
411
- },
412
- modelKey: {
413
- code: 7,
414
- desc: p("COMMON_TAG.MODEL_KEY"),
415
- deleteFn: async () => await $(v.value)
416
- }
417
- };
418
- return console.log(o, "value"), n[o];
419
- }, le = async () => {
420
- let o = v.value;
421
- z.deleteType == "plugin" && (o = W.value);
422
- const n = {
423
- bnid: o,
424
- size: 999,
425
- page: 1,
426
- "business-type": j
427
- }, { code: s, data: I } = await t(n);
428
- s === 0 && ((I.data || []).forEach((J) => {
429
- J.name == "workflow" && (y.value = J.data), J.name == "agent" && (T.value = J.data);
430
- }), T.value.length || (U.value = "2"));
431
- }, B = g("");
432
- let j = "", H = null;
433
- Re(() => {
434
- const o = ee(z.deleteType);
435
- B.value = o.desc || "", j = o.code || "", H = o.deleteFn || null;
436
- });
437
- const W = g(""), te = (o, n = "") => {
438
- v.value = o, W.value = n, C(), le();
439
- }, oe = async () => {
440
- if (!H) return;
441
- const o = await H();
442
- o && o.code == 0 ? (G({
443
- // message: `${t('COMMON_BUTTON.DELETE_TEXT') || '删除'}${deleteTypeStr.value}${t('MESSAGE_REMIND.SUCCESS_TEXT') || '成功'}`,
444
- message: p("COMPONENTS_OUTER_SPHERE.DELETE_DATA_SUCCESS", {
445
- name: B.value
446
- }),
447
- type: "success"
448
- }), K("success"), X()) : G({
449
- // message: `${t('COMMON_BUTTON.DELETE_TEXT' || '删除')}${deleteTypeStr.value}${t('MESSAGE_REMIND.FAIL_TEXT') || '失败'}`,
450
- message: p("COMPONENTS_OUTER_SPHERE.DELETE_DATA_FAILED", {
451
- name: B.value
452
- }),
453
- type: "error"
454
- });
455
- }, se = (o) => {
456
- D.push({ name: "AgentDetail", params: { bnid: o.skillet } });
457
- }, Q = (o) => {
458
- D.push({ name: "Workflow", params: { workflowBnid: o.skillet } });
459
- }, ne = () => {
460
- }, X = () => {
461
- b(), v.value = "", T.value = [], y.value = [];
462
- };
463
- return r({ showDeleteDialog: te, hideDeleteDialog: X }), (o, n) => (c(), w(e(Le), {
464
- title: l.title || e(p)("COMPONENTS_OUTER_SPHERE.CONFIRM_DELETE", { deleteTypeStr: B.value }),
465
- width: "520px",
466
- ref_key: "dialogRef",
467
- ref: m
468
- }, {
469
- footer: d(() => [
470
- M("div", Cl, [
471
- a(e(V), { onClick: X }, {
472
- default: d(() => [
473
- S(R(e(p)("COMMON_BUTTON.CANCEL_TEXT")), 1)
474
- ]),
475
- _: 1
476
- }),
477
- a(e(V), {
478
- type: "danger",
479
- onClick: oe
480
- }, {
481
- default: d(() => [
482
- S(R(e(p)("COMMON_BUTTON.CONFIRM_AFFIRM")), 1)
483
- ]),
484
- _: 1
485
- })
486
- ])
487
- ]),
488
- default: d(() => [
489
- M("div", pl, [
490
- a(e(N), { class: "warning-icon" }, {
491
- default: d(() => [
492
- a(e(Ne))
493
- ]),
494
- _: 1
495
- }),
496
- M("div", Ol, [
497
- M("div", El, [
498
- S(R(e(p)("COMPONENTS_OUTER_SPHERE.HISTORY_REFERENCE", { deleteTypeStr: B.value })) + " ", 1),
499
- M("span", ml, R(e(p)("PLUGINLIST.CAUTION")), 1)
500
- ]),
501
- T.value.length || y.value.length ? (c(), E("div", fl, R(e(p)("PLUGINLIST.CAUTION_INFO")), 1)) : h("", !0),
502
- n[1] || (n[1] = M("div", null, null, -1))
503
- ])
504
- ]),
505
- T.value.length || y.value.length ? (c(), E("div", Ll, [
506
- a(_l, {
507
- modelValue: U.value,
508
- "onUpdate:modelValue": n[0] || (n[0] = (s) => U.value = s),
509
- tabList: i.value,
510
- onChange: ne
511
- }, null, 8, ["modelValue", "tabList"]),
512
- U.value == "1" ? (c(), E("div", Ml, [
513
- (c(!0), E(P, null, Y(T.value, (s) => (c(), E("div", {
514
- class: "resource-item",
515
- key: s.resource,
516
- onClick: (I) => se(s)
517
- }, [
518
- n[2] || (n[2] = M("div", { class: "flow-name__icon-placeholder" }, null, -1)),
519
- M("div", vl, R(s.name), 1),
520
- a(e(N), null, {
521
- default: d(() => [
522
- a(e(Oe))
523
- ]),
524
- _: 1
525
- })
526
- ], 8, gl))), 128))
527
- ])) : h("", !0),
528
- U.value == "2" ? (c(), E("div", Rl, [
529
- (c(!0), E(P, null, Y(y.value, (s) => (c(), E("div", {
530
- class: "resource-item",
531
- key: s.resource,
532
- onClick: (I) => Q(s)
533
- }, [
534
- a(e(N), { size: "32px" }, {
535
- default: d(() => [
536
- a(e(he))
537
- ]),
538
- _: 1
539
- }),
540
- M("div", Dl, R(s.name), 1),
541
- a(e(N), null, {
542
- default: d(() => [
543
- a(e(Oe))
544
- ]),
545
- _: 1
546
- })
547
- ], 8, Al))), 128))
548
- ])) : h("", !0)
549
- ])) : h("", !0)
550
- ]),
551
- _: 1
552
- }, 8, ["title"]));
553
- }
554
- }, wl = /* @__PURE__ */ Z(Il, [["__scopeId", "data-v-71205bec"]]), Tl = { class: "dialog-footer" }, yl = {
555
- __name: "AddOrEditSupplierDialog",
556
- emits: ["submit", "success"],
557
- setup(l, { expose: r, emit: f }) {
558
- const { t } = ce(), { addModel: u, updateModel: O } = Me(), _ = g(null), L = g([]), $ = g(!1), A = g(!1), { dialogRef: p, hideDialog: D, resetDialog: m } = fe(A), C = g(!1), b = g(""), z = me(() => C.value ? t("COMMON_MODEL_LIBRARY.EDIT_MODEL") : t("COMMON_MODEL_LIBRARY.ADD_MODEL")), K = g(""), i = Ae({
559
- name: "",
560
- code: "",
561
- type: "",
562
- description: "",
563
- // supplier: '',
564
- apiKey: "",
565
- apiUrl: "",
566
- bnid: null,
567
- maxTokens: 2e6,
568
- contextLength: 2e6,
569
- icon: "0",
570
- avatarUrl: ""
571
- }), U = [
572
- {
573
- label: t("COMMON_MODEL_LIBRARY.MODEL_TYPE_LARGE_LANGUAGE_MODEL"),
574
- value: "llm"
575
- },
576
- {
577
- label: t("COMMON_MODEL_LIBRARY.MODEL_TYPE_MULTIMODAL_MODEL"),
578
- value: "multimodal"
579
- },
580
- {
581
- label: t("COMMON_MODEL_LIBRARY.MODEL_TYPE_EMBEDDING_MODEL"),
582
- value: "embedding"
583
- },
584
- { label: t("COMMON_MODEL_LIBRARY.MODEL_TYPE_RERANK_MODEL"), value: "rerank" }
585
- ], v = g(!i.bnid), T = {
586
- name: [
587
- {
588
- required: !0,
589
- message: t("COMMON_MODEL_LIBRARY.MODEL_NAME_REQUIRED"),
590
- trigger: "blur"
591
- },
592
- {
593
- max: 64,
594
- message: t("COMMON_MODEL_LIBRARY.MODEL_NAME_MAX_LENGTH"),
595
- trigger: "blur"
596
- },
597
- {
598
- validator: (o, n, s) => {
599
- n && /\s/.test(n) ? s(new Error(t("COMMON_MODEL_LIBRARY.MODEL_NAME_NO_SPACE"))) : s();
600
- },
601
- trigger: "blur"
602
- }
603
- ],
604
- code: [
605
- {
606
- required: !0,
607
- message: t("COMMON_MODEL_LIBRARY.MODEL_CODE_REQUIRED"),
608
- trigger: "blur"
609
- },
610
- {
611
- max: 64,
612
- message: t("COMMON_MODEL_LIBRARY.MODEL_CODE_MAX_LENGTH"),
613
- trigger: "blur"
614
- },
615
- {
616
- validator: (o, n, s) => {
617
- n && /\s/.test(n) ? s(new Error(t("COMMON_MODEL_LIBRARY.MODEL_CODE_NO_SPACE"))) : s();
618
- },
619
- trigger: "blur"
620
- }
621
- ],
622
- type: [
623
- {
624
- required: !0,
625
- message: t("COMMON_MODEL_LIBRARY.MODEL_TYPE_PLACEHOLDER"),
626
- trigger: "change"
627
- }
628
- ],
629
- // description: [{ required: true, message: '请输入供应商描述', trigger: 'blur' }],
630
- maxTokens: [
631
- {
632
- required: !0,
633
- message: t("COMMON_MODEL_LIBRARY.MAX_TOKENS_PLACEHOLDER"),
634
- trigger: "blur"
635
- }
636
- ],
637
- contextLength: [
638
- {
639
- required: !0,
640
- message: t("COMMON_MODEL_LIBRARY.CONTEXT_LENGTH_PLACEHOLDER"),
641
- trigger: "blur"
642
- }
643
- ],
644
- apiKey: [
645
- {
646
- required: !0,
647
- message: t("COMMON_MODEL_LIBRARY.API_KEY_REQUIRED"),
648
- trigger: "blur"
649
- }
650
- ],
651
- apiUrl: [
652
- {
653
- required: !0,
654
- message: t("COMMON_MODEL_LIBRARY.API_URL_REQUIRED"),
655
- trigger: "blur"
656
- },
657
- {
658
- validator: (o, n, s) => {
659
- if (!n) {
660
- s();
661
- return;
662
- }
663
- try {
664
- const I = new URL(n);
665
- if (I.protocol !== "http:" && I.protocol !== "https:") {
666
- s(new Error(t("COMMON_MODEL_LIBRARY.API_URL_INVALID")));
667
- return;
668
- }
669
- s();
670
- } catch {
671
- s(new Error(t("COMMON_MODEL_LIBRARY.API_URL_INVALID_DESC")));
672
- }
673
- },
674
- trigger: "blur"
675
- }
676
- ]
677
- }, y = f, ee = (o = null) => {
678
- console.log("data:", o), Object.assign(i, {
679
- name: "",
680
- code: "",
681
- type: "",
682
- description: "",
683
- maxTokens: 2e6,
684
- contextLength: 2e6,
685
- supplier: "",
686
- apiKey: "",
687
- apiUrl: "",
688
- bnid: null,
689
- avatarUrl: "",
690
- icon: "0"
691
- }), b.value = o?.rowData?.bnid || "", o?.rowData ? (console.log("rowData:", o.rowData), o.rowData.apiKey || ($.value = !0), Object.assign(i, o.rowData), K.value = o.rowData.apiUrl || "") : K.value = "", L.value = [], o ? (i.supplier = o.supplier || "", C.value = o.isEditDialog ?? !1, o.rowData?.icon && o.rowData.icon !== "0" && o.rowData?.avatarUrl && (L.value = [
692
- {
693
- bnid: o.rowData.icon,
694
- url: o.rowData.avatarUrl
695
- }
696
- ])) : C.value = !1, p.value?.showDialog();
697
- }, le = (o) => {
698
- o > 2e9 ? i.maxTokens = 2e9 : i.maxTokens = o;
699
- }, B = (o) => {
700
- o > 2e9 ? i.contextLength = 2e9 : i.contextLength = o;
701
- }, j = async () => {
702
- _.value && await _.value.validate(async (o) => {
703
- if (o) {
704
- A.value = !0;
705
- const n = 2e9;
706
- let s = Number(i.maxTokens), I = Number(i.contextLength);
707
- s = Math.min(s, n), I = Math.min(I, n);
708
- const ae = {
709
- name: i.name,
710
- code: i.code,
711
- icon: i.icon,
712
- type: i.type,
713
- description: i.description,
714
- maxTokens: s,
715
- contextLength: I,
716
- apiKey: i.apiKey,
717
- apiUrl: i.apiUrl
718
- };
719
- C.value ? await W(ae) : H(ae);
720
- } else
721
- G.error(t("COMMON_MODEL_LIBRARY.REQUIRED"));
722
- });
723
- }, H = async (o) => {
724
- try {
725
- console.log(o), (await u(o)).code === 0 && (G.success(t("COMMON_MODEL_LIBRARY.CREATE_MODEL_SUCCESS")), D(), y("submit"));
726
- } finally {
727
- A.value = !1;
728
- }
729
- }, W = async (o) => {
730
- console.log("更新模型formData:", o);
731
- try {
732
- (await O(b.value, o)).code === 0 && (G.success(t("COMMON_MODEL_LIBRARY.UPDATE_MODEL_SUCCESS")), D());
733
- } finally {
734
- A.value = !1;
735
- }
736
- }, te = () => {
737
- v.value = !v.value;
738
- }, oe = (o) => {
739
- i.avatarUrl = o.url, i.icon = o.bnid, L.value = [o];
740
- }, se = () => {
741
- i.icon = "0", L.value = [];
742
- }, Q = g(null), ne = () => {
743
- Q.value.showDeleteDialog(b.value);
744
- }, X = () => {
745
- D(), y("success");
746
- };
747
- return r({
748
- showDialog: ee,
749
- hideDialog: D
750
- }), (o, n) => (c(), E(P, null, [
751
- a(e(Le), {
752
- class: "custom-model-dialog",
753
- ref_key: "dialogRef",
754
- ref: p,
755
- title: z.value,
756
- width: "520px",
757
- onClosed: e(m)
758
- }, {
759
- footer: d(() => [
760
- M("div", Tl, [
761
- C.value ? (c(), w(e(V), {
762
- key: 0,
763
- style: { float: "left" },
764
- type: "danger",
765
- onClick: ne
766
- }, {
767
- default: d(() => [
768
- S(R(e(t)("COMMON_BUTTON.DELETE_TEXT")), 1)
769
- ]),
770
- _: 1
771
- })) : h("", !0),
772
- a(e(V), { onClick: e(D) }, {
773
- default: d(() => [
774
- S(R(e(t)("COMMON_BUTTON.CANCEL_TEXT")), 1)
775
- ]),
776
- _: 1
777
- }, 8, ["onClick"]),
778
- a(e(V), {
779
- type: "primary",
780
- loading: A.value,
781
- onClick: j,
782
- disabled: A.value
783
- }, {
784
- default: d(() => [
785
- S(R(A.value ? e(t)("COMMON_MODEL_LIBRARY.VALIDATION_LOADING") : e(t)("COMMON_BUTTON.CONFIRM_TEXT")), 1)
786
- ]),
787
- _: 1
788
- }, 8, ["loading", "disabled"])
789
- ])
790
- ]),
791
- default: d(() => [
792
- a(e(Ie), {
793
- ref_key: "formRef",
794
- ref: _,
795
- model: i,
796
- rules: T,
797
- "label-width": "auto",
798
- class: "vertical-form"
799
- }, {
800
- default: d(() => [
801
- a(e(x), {
802
- label: e(t)("COMMON_MODEL_LIBRARY.MODEL_NAME"),
803
- prop: "name"
804
- }, {
805
- default: d(() => [
806
- a(e(k), {
807
- modelValue: i.name,
808
- "onUpdate:modelValue": n[0] || (n[0] = (s) => i.name = s),
809
- placeholder: e(t)("COMMON_MODEL_LIBRARY.MODEL_NAME_PLACEHOLDER"),
810
- maxlength: 64
811
- }, null, 8, ["modelValue", "placeholder"])
812
- ]),
813
- _: 1
814
- }, 8, ["label"]),
815
- a(e(x), {
816
- label: e(t)("COMMON_MODEL_LIBRARY.MODEL_CODE"),
817
- prop: "code"
818
- }, {
819
- default: d(() => [
820
- a(e(k), {
821
- modelValue: i.code,
822
- "onUpdate:modelValue": n[1] || (n[1] = (s) => i.code = s),
823
- placeholder: e(t)("COMMON_MODEL_LIBRARY.MODEL_CODE_PLACEHOLDER"),
824
- maxlength: 64
825
- }, null, 8, ["modelValue", "placeholder"])
826
- ]),
827
- _: 1
828
- }, 8, ["label"]),
829
- a(e(x), {
830
- label: e(t)("COMMON_MODEL_LIBRARY.MODEL_AVATAR_URL"),
831
- prop: "avatarUrl"
832
- }, {
833
- default: d(() => [
834
- a(sl, {
835
- fileList: L.value,
836
- previewType: "Card",
837
- onOnRemove: se
838
- }, {
839
- CardUploader: d(() => [
840
- L.value.length === 0 ? (c(), w(e(be), {
841
- key: 0,
842
- limitSize: 5,
843
- acceptType: ".jpg,.png",
844
- defaultUploadIcon: "model",
845
- onOnSuccess: oe,
846
- businessType: "model"
847
- })) : h("", !0)
848
- ]),
849
- _: 1
850
- }, 8, ["fileList"])
851
- ]),
852
- _: 1
853
- }, 8, ["label"]),
854
- a(e(x), {
855
- label: e(t)("COMMON_MODEL_LIBRARY.MODEL_TYPE"),
856
- prop: "type"
857
- }, {
858
- default: d(() => [
859
- a(e(we), {
860
- modelValue: i.type,
861
- "onUpdate:modelValue": n[2] || (n[2] = (s) => i.type = s),
862
- placeholder: e(t)("COMMON_MODEL_LIBRARY.MODEL_TYPE_PLACEHOLDER"),
863
- style: { width: "100%" }
864
- }, {
865
- default: d(() => [
866
- (c(), E(P, null, Y(U, (s) => a(e(Te), {
867
- key: s.value,
868
- label: s.label,
869
- value: s.value
870
- }, null, 8, ["label", "value"])), 64))
871
- ]),
872
- _: 1
873
- }, 8, ["modelValue", "placeholder"])
874
- ]),
875
- _: 1
876
- }, 8, ["label"]),
877
- a(e(x), {
878
- label: e(t)("COMMON_MODEL_LIBRARY.MODEL_DESCRIPTION"),
879
- prop: "description"
880
- }, {
881
- default: d(() => [
882
- a(e(k), {
883
- modelValue: i.description,
884
- "onUpdate:modelValue": n[3] || (n[3] = (s) => i.description = s),
885
- type: "textarea",
886
- placeholder: e(t)("COMMON_MODEL_LIBRARY.MODEL_DESCRIPTION_PLACEHOLDER"),
887
- maxlength: 200,
888
- "show-word-limit": ""
889
- }, null, 8, ["modelValue", "placeholder"])
890
- ]),
891
- _: 1
892
- }, 8, ["label"]),
893
- a(e(x), {
894
- label: e(t)("COMMON_MODEL_LIBRARY.MAX_TOKENS"),
895
- prop: "maxTokens"
896
- }, {
897
- default: d(() => [
898
- a(e(k), {
899
- modelValue: i.maxTokens,
900
- "onUpdate:modelValue": n[4] || (n[4] = (s) => i.maxTokens = s),
901
- placeholder: e(t)("COMMON_MODEL_LIBRARY.MAX_TOKENS_PLACEHOLDER"),
902
- onInput: le
903
- }, null, 8, ["modelValue", "placeholder"])
904
- ]),
905
- _: 1
906
- }, 8, ["label"]),
907
- a(e(x), {
908
- label: e(t)("COMMON_MODEL_LIBRARY.CONTEXT_LENGTH"),
909
- prop: "contextLength"
910
- }, {
911
- default: d(() => [
912
- a(e(k), {
913
- modelValue: i.contextLength,
914
- "onUpdate:modelValue": n[5] || (n[5] = (s) => i.contextLength = s),
915
- placeholder: e(t)("COMMON_MODEL_LIBRARY.CONTEXT_LENGTH_PLACEHOLDER"),
916
- onInput: B
917
- }, null, 8, ["modelValue", "placeholder"])
918
- ]),
919
- _: 1
920
- }, 8, ["label"]),
921
- a(e(x), {
922
- label: e(t)("COMMON_MODEL_LIBRARY.API_KEY"),
923
- prop: "apiKey"
924
- }, {
925
- default: d(() => [
926
- a(e(k), {
927
- modelValue: i.apiKey,
928
- "onUpdate:modelValue": n[6] || (n[6] = (s) => i.apiKey = s),
929
- placeholder: e(t)("COMMON_MODEL_LIBRARY.API_KEY_PLACEHOLDER"),
930
- type: v.value ? "text" : "password"
931
- }, {
932
- suffix: d(() => [
933
- a(e(N), {
934
- class: "cursor-pointer",
935
- onClick: te
936
- }, {
937
- default: d(() => [
938
- (c(), w(ue(v.value ? "IconLook" : "IconHide")))
939
- ]),
940
- _: 1
941
- })
942
- ]),
943
- _: 1
944
- }, 8, ["modelValue", "placeholder", "type"])
945
- ]),
946
- _: 1
947
- }, 8, ["label"]),
948
- a(e(x), {
949
- label: e(t)("COMMON_MODEL_LIBRARY.API_URL"),
950
- prop: "apiUrl"
951
- }, {
952
- default: d(() => [
953
- a(e(k), {
954
- modelValue: i.apiUrl,
955
- "onUpdate:modelValue": n[7] || (n[7] = (s) => i.apiUrl = s),
956
- placeholder: e(t)("COMMON_MODEL_LIBRARY.API_URL_PLACEHOLDER"),
957
- disabled: !!K.value
958
- }, null, 8, ["modelValue", "placeholder", "disabled"])
959
- ]),
960
- _: 1
961
- }, 8, ["label"])
962
- ]),
963
- _: 1
964
- }, 8, ["model"])
965
- ]),
966
- _: 1
967
- }, 8, ["title", "onClosed"]),
968
- a(wl, {
969
- ref_key: "deleteResourceDialog",
970
- ref: Q,
971
- deleteType: "model",
972
- onSuccess: X
973
- }, null, 512)
974
- ], 64));
975
- }
976
- }, Nl = /* @__PURE__ */ Z(yl, [["__scopeId", "data-v-36a3918c"]]), Hl = (l, r = "", f = "file") => {
977
- const t = new Blob([l]);
978
- if (f == "image")
979
- return URL.createObjectURL(t);
980
- {
981
- const u = document.createElement("a");
982
- u.style.display = "none";
983
- const O = window.URL.createObjectURL(t);
984
- u.href = O, u.setAttribute("download", r), document.body.appendChild(u), u.click(), document.body.removeChild(u), setTimeout(() => {
985
- window.URL.revokeObjectURL(O);
986
- }, 5e3);
987
- }
988
- }, Xl = ge(Nl);
989
- export {
990
- Xl as A,
991
- wl as D,
992
- sl as F,
993
- _l as a,
994
- Se as b,
995
- Ke as c,
996
- Hl as d,
997
- q as e,
998
- He as f,
999
- de as g,
1000
- Fe as h,
1001
- Ye as i,
1002
- Be as j,
1003
- Ue as k,
1004
- Pe as l,
1005
- Ve as m,
1006
- ke as n,
1007
- $e as o,
1008
- Ge as p,
1009
- Xe as u
1010
- };