dsh-nvidia-models-panel 1.3.22 → 1.3.24
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/LICENSE +21 -21
- package/README.md +104 -104
- package/package.json +51 -51
- package/src/client.js +1261 -1222
- package/src/group.js +652 -652
- package/src/index.js +1253 -1253
- package/src/usage.js +285 -285
package/src/client.js
CHANGED
|
@@ -1,1222 +1,1261 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({
|
|
2
|
-
id: 'dsh-nvidia-models-panel',
|
|
3
|
-
factory(require) {
|
|
4
|
-
const React = require('react');
|
|
5
|
-
const { useState, useCallback, useRef, useEffect } = React;
|
|
6
|
-
const h = React.createElement;
|
|
7
|
-
|
|
8
|
-
const BUILTIN_MODELS = [
|
|
9
|
-
{ id: 'nvidia/llama-3.1-nemotron-70b-instruct', name: 'Llama 3.1 Nemotron 70B', description: 'NVIDIA 旗舰推理模型,擅长复杂推理、编码与数学', contextLength: 128000 },
|
|
10
|
-
{ id: 'nvidia/nemotron-3-ultra-550b-a55b', name: 'Nemotron 3 Ultra 550B', description: '超大参数模型,推理与编码能力极强', contextLength: 1000000 },
|
|
11
|
-
{ id: 'nvidia/nemotron-3-super-120b-a12b', name: 'Nemotron 3 Super 120B', description: '高性能均衡型,适合企业级日常任务', contextLength: 262144 },
|
|
12
|
-
{ id: 'nvidia/nemotron-3.5-lightning-30b-a3b', name: 'Nemotron 3.5 Lightning 30B', description: '轻量高速 MoE 模型,响应快、成本低', contextLength: 262144 },
|
|
13
|
-
{ id: 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning', name: 'Nemotron 3 Nano Omni 30B', description: '全模态模型,支持文本与图像输入', contextLength: 256000 },
|
|
14
|
-
{ id: 'nvidia/llama-3.1-nemotron-ultra-253b-v1', name: 'Llama 3.1 Nemotron Ultra 253B', description: 'Llama 3.1 的 NVIDIA 深度优化版本,253B 参数', contextLength: 128000 },
|
|
15
|
-
{ id: 'nvidia/cosmos-reason2-8b', name: 'Cosmos Reason2 8B', description: '物理世界推理模型,面向机器人与视频理解', contextLength: 131072 },
|
|
16
|
-
{ id: 'deepseek-ai/deepseek-v4.1-flash', name: 'DeepSeek V4.1 Flash', description: 'DeepSeek 高速版,长上下文,支持文本与图像', contextLength: 1000000 },
|
|
17
|
-
{ id: 'moonshotai/kimi-k3', name: 'Kimi K3', description: '月之暗面旗舰模型,百万级上下文窗口', contextLength: 1048576 },
|
|
18
|
-
{ id: 'z-ai/glm-5.3', name: 'GLM-5.3', description: '智谱旗舰大模型,强推理与长上下文', contextLength: 1000000 },
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const VERIFY_CONCURRENCY = 6;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return h('span', {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
style: {
|
|
182
|
-
display: '
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const [
|
|
233
|
-
const [
|
|
234
|
-
const [
|
|
235
|
-
const [
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
)
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}, []);
|
|
632
|
-
|
|
633
|
-
//
|
|
634
|
-
useEffect(function () {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
return
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
)
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
)
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
style: {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
:
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
)
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
},
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
},
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
h('
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
}
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-nvidia-models-panel',
|
|
3
|
+
factory(require) {
|
|
4
|
+
const React = require('react');
|
|
5
|
+
const { useState, useCallback, useRef, useEffect } = React;
|
|
6
|
+
const h = React.createElement;
|
|
7
|
+
|
|
8
|
+
const BUILTIN_MODELS = [
|
|
9
|
+
{ id: 'nvidia/llama-3.1-nemotron-70b-instruct', name: 'Llama 3.1 Nemotron 70B', description: 'NVIDIA 旗舰推理模型,擅长复杂推理、编码与数学', contextLength: 128000 },
|
|
10
|
+
{ id: 'nvidia/nemotron-3-ultra-550b-a55b', name: 'Nemotron 3 Ultra 550B', description: '超大参数模型,推理与编码能力极强', contextLength: 1000000 },
|
|
11
|
+
{ id: 'nvidia/nemotron-3-super-120b-a12b', name: 'Nemotron 3 Super 120B', description: '高性能均衡型,适合企业级日常任务', contextLength: 262144 },
|
|
12
|
+
{ id: 'nvidia/nemotron-3.5-lightning-30b-a3b', name: 'Nemotron 3.5 Lightning 30B', description: '轻量高速 MoE 模型,响应快、成本低', contextLength: 262144 },
|
|
13
|
+
{ id: 'nvidia/nemotron-3-nano-omni-30b-a3b-reasoning', name: 'Nemotron 3 Nano Omni 30B', description: '全模态模型,支持文本与图像输入', contextLength: 256000 },
|
|
14
|
+
{ id: 'nvidia/llama-3.1-nemotron-ultra-253b-v1', name: 'Llama 3.1 Nemotron Ultra 253B', description: 'Llama 3.1 的 NVIDIA 深度优化版本,253B 参数', contextLength: 128000 },
|
|
15
|
+
{ id: 'nvidia/cosmos-reason2-8b', name: 'Cosmos Reason2 8B', description: '物理世界推理模型,面向机器人与视频理解', contextLength: 131072 },
|
|
16
|
+
{ id: 'deepseek-ai/deepseek-v4.1-flash', name: 'DeepSeek V4.1 Flash', description: 'DeepSeek 高速版,长上下文,支持文本与图像', contextLength: 1000000 },
|
|
17
|
+
{ id: 'moonshotai/kimi-k3', name: 'Kimi K3', description: '月之暗面旗舰模型,百万级上下文窗口', contextLength: 1048576 },
|
|
18
|
+
{ id: 'z-ai/glm-5.3', name: 'GLM-5.3', description: '智谱旗舰大模型,强推理与长上下文', contextLength: 1000000 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const VERIFY_CONCURRENCY = 6;
|
|
22
|
+
|
|
23
|
+
// NVIDIA NIM API Key 官方申请地址 + 悬停注册步骤提示。
|
|
24
|
+
const NVIDIA_KEY_URL = 'https://build.nvidia.com/settings/api-keys';
|
|
25
|
+
const NVIDIA_KEY_HINT = [
|
|
26
|
+
'如何获取 NVIDIA API Key:',
|
|
27
|
+
'1. 打开 build.nvidia.com,用 NVIDIA 开发者账号登录(免费,可能需要手机验证)',
|
|
28
|
+
'2. 进入头像菜单 → Settings → API Keys(或 build.nvidia.com/settings/api-keys)',
|
|
29
|
+
'3. 点击 Generate API Key,名称自定义,务必勾选 Public API Endpoints 权限',
|
|
30
|
+
'4. 复制以 nvapi- 开头的 Key(只显示一次),粘贴到下方输入框并保存',
|
|
31
|
+
'(点此徽标可直接打开申请页面)',
|
|
32
|
+
].join('\n');
|
|
33
|
+
|
|
34
|
+
function NvidiaPanelIcon(props) {
|
|
35
|
+
const active = !!(props && props.active);
|
|
36
|
+
return h('button', {
|
|
37
|
+
onClick: props && props.onClick,
|
|
38
|
+
'aria-label': 'NVIDIA 模型',
|
|
39
|
+
title: 'NVIDIA 模型',
|
|
40
|
+
style: {
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
width: '100%',
|
|
45
|
+
height: '100%',
|
|
46
|
+
background: 'transparent',
|
|
47
|
+
border: 'none',
|
|
48
|
+
cursor: 'pointer',
|
|
49
|
+
padding: 0,
|
|
50
|
+
color: active ? '#76B900' : 'inherit',
|
|
51
|
+
},
|
|
52
|
+
}, h('svg', {
|
|
53
|
+
viewBox: '0 0 24 24',
|
|
54
|
+
width: 20,
|
|
55
|
+
height: 20,
|
|
56
|
+
fill: 'currentColor',
|
|
57
|
+
'aria-hidden': 'true',
|
|
58
|
+
}, h('path', { d: 'M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5' })));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Badge for one model's probe result. */
|
|
62
|
+
function statusBadge(result) {
|
|
63
|
+
if (!result) {
|
|
64
|
+
return h('span', { style: { fontSize: '11px', opacity: 0.5, border: '1px solid rgba(128,128,128,0.35)', borderRadius: '4px', padding: '1px 6px' } }, '未试调用');
|
|
65
|
+
}
|
|
66
|
+
if (result.status === 'testing') {
|
|
67
|
+
return h('span', { style: { fontSize: '11px', color: '#b8860b', border: '1px solid #b8860b', borderRadius: '4px', padding: '1px 6px' } }, '试调用中…');
|
|
68
|
+
}
|
|
69
|
+
if (result.status === 'ok') {
|
|
70
|
+
return h('span', { style: { fontSize: '11px', color: '#2e7d32', border: '1px solid #2e7d32', borderRadius: '4px', padding: '1px 6px', background: 'rgba(46,125,50,0.10)' } }, '可用 ✓');
|
|
71
|
+
}
|
|
72
|
+
if (result.status === 'skip') {
|
|
73
|
+
return h('span', { style: { fontSize: '11px', opacity: 0.6, border: '1px dashed rgba(128,128,128,0.5)', borderRadius: '4px', padding: '1px 6px' } }, '跳过');
|
|
74
|
+
}
|
|
75
|
+
return h('span', { style: { fontSize: '11px', color: '#c62828', border: '1px solid #c62828', borderRadius: '4px', padding: '1px 6px', background: 'rgba(198,40,40,0.08)' } }, '不可用');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Badge for one group member's live health status. */
|
|
79
|
+
function groupBadge(status) {
|
|
80
|
+
const map = {
|
|
81
|
+
ok: { c: '#2e7d32', t: '健康 ✓' },
|
|
82
|
+
failed: { c: '#c62828', t: '故障' },
|
|
83
|
+
unknown: { c: '#8a8a8a', t: '未知' },
|
|
84
|
+
};
|
|
85
|
+
const s = map[status] || map.unknown;
|
|
86
|
+
return h('span', {
|
|
87
|
+
style: { fontSize: '11px', color: s.c, border: '1px solid ' + s.c, borderRadius: '4px', padding: '1px 6px' },
|
|
88
|
+
}, s.t);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 输入框 dock 徽标:显示模型组最近真正出正文的模型 + 切换/熔断计数。
|
|
93
|
+
* 独立 React 树,自己轮询 /api/nvidia-models 的 dockStatus(3 秒一次)。
|
|
94
|
+
* 未使用模型组时(active=false)完全不渲染,平时不打扰。
|
|
95
|
+
*/
|
|
96
|
+
function DockBadge(props) {
|
|
97
|
+
const [status, setStatus] = useState(null);
|
|
98
|
+
const btnRef = useRef(null);
|
|
99
|
+
|
|
100
|
+
// 运行时实测对齐:dock 槽位容器的真实宽度/缩进由宿主 CSS 决定,静态猜 CSS 变量不可靠。
|
|
101
|
+
// 直接测量输入框 card 的实际右边缘,动态设置 marginRight 让徽标右边缘与它重合。
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
if (!status || !status.active) return;
|
|
104
|
+
var cancelled = false;
|
|
105
|
+
function findCard(input) {
|
|
106
|
+
var el = input;
|
|
107
|
+
while (el && el !== document.body) {
|
|
108
|
+
var r = el.getBoundingClientRect();
|
|
109
|
+
var cs = window.getComputedStyle(el);
|
|
110
|
+
if (r.width > 400 && r.width <= window.innerWidth - 16 &&
|
|
111
|
+
parseFloat(cs.borderTopLeftRadius) >= 10) return el;
|
|
112
|
+
el = el.parentElement;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
function align() {
|
|
117
|
+
if (cancelled) return;
|
|
118
|
+
var btn = btnRef.current;
|
|
119
|
+
var input = document.querySelector('[data-composer-input]');
|
|
120
|
+
if (!btn || !input) return;
|
|
121
|
+
var card = findCard(input);
|
|
122
|
+
if (!card) return;
|
|
123
|
+
// btn.right = 容器右缘 - marginRight。要让 btn.right 追上 card.right(增量 = card.right - btn.right),
|
|
124
|
+
// 需把 marginRight 减去同样的增量(marginRight 越大按钮越靠左)。
|
|
125
|
+
var delta = card.getBoundingClientRect().right - btn.getBoundingClientRect().right;
|
|
126
|
+
if (Math.abs(delta) >= 1) {
|
|
127
|
+
var cur = parseFloat(window.getComputedStyle(btn).marginRight) || 0;
|
|
128
|
+
btn.style.marginRight = (cur - delta) + 'px';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var n = 0;
|
|
132
|
+
var raf;
|
|
133
|
+
function converge() { align(); if (++n < 10) raf = requestAnimationFrame(converge); }
|
|
134
|
+
converge();
|
|
135
|
+
var timer = setInterval(align, 2000);
|
|
136
|
+
return function () { cancelled = true; cancelAnimationFrame(raf); clearInterval(timer); };
|
|
137
|
+
}, [status && status.active]);
|
|
138
|
+
|
|
139
|
+
const sessionId = props && props.sessionId;
|
|
140
|
+
const refresh = useCallback(async function () {
|
|
141
|
+
try {
|
|
142
|
+
const response = await fetch('/api/nvidia-models', {
|
|
143
|
+
method: 'POST',
|
|
144
|
+
headers: { 'content-type': 'application/json' },
|
|
145
|
+
body: JSON.stringify({ action: 'dockStatus', sessionId: sessionId || undefined }),
|
|
146
|
+
});
|
|
147
|
+
if (!response.ok) return;
|
|
148
|
+
const data = await response.json();
|
|
149
|
+
if (data && data.ok) setStatus(data);
|
|
150
|
+
} catch {
|
|
151
|
+
// best-effort
|
|
152
|
+
}
|
|
153
|
+
}, [sessionId]);
|
|
154
|
+
|
|
155
|
+
useEffect(function () {
|
|
156
|
+
refresh();
|
|
157
|
+
const id = setInterval(refresh, 3000);
|
|
158
|
+
return function () { clearInterval(id); };
|
|
159
|
+
}, [refresh]);
|
|
160
|
+
|
|
161
|
+
if (!status || !status.active) return null;
|
|
162
|
+
|
|
163
|
+
const name = status.memberName || status.memberId || '模型组';
|
|
164
|
+
const justSwitched = Boolean(status.switchFrom);
|
|
165
|
+
const label = justSwitched
|
|
166
|
+
? ('⚡ ' + name + ' ← 从 ' + status.switchFrom + ' 切换 · 切换 ' + status.switchCount + ' 次')
|
|
167
|
+
: ('⚡ ' + name + ' · 切换 ' + status.switchCount + ' 次 · 熔断 ' + status.cooldownCount);
|
|
168
|
+
|
|
169
|
+
const openUsage = function () {
|
|
170
|
+
try {
|
|
171
|
+
window.dispatchEvent(new CustomEvent('nvidia-models-open-usage'));
|
|
172
|
+
} catch { /* 忽略:面板可能未挂载 */ }
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// dock 容器(._7yHdaG_dock)相对输入框两边各缩进了 2×--dsh-composer-dock-inset:
|
|
176
|
+
// max-width = card-max - 2×inset,padding = 0 inset,margin 0 auto
|
|
177
|
+
// 所以 dock 内容区右边缘比输入框右边缘靠左 2×inset(默认 16px)。
|
|
178
|
+
// 用 flex-end 靠右后,再给徽标一个负 margin-right = -2×inset 抵消这段缩进,
|
|
179
|
+
// 右边缘就与输入框右边缘像素级对齐。不用 absolute(外层空 div 高度会塌缩成 0)。
|
|
180
|
+
return h('div', {
|
|
181
|
+
style: {
|
|
182
|
+
display: 'flex',
|
|
183
|
+
justifyContent: 'flex-end',
|
|
184
|
+
width: '100%',
|
|
185
|
+
boxSizing: 'border-box',
|
|
186
|
+
},
|
|
187
|
+
}, h('button', {
|
|
188
|
+
ref: btnRef,
|
|
189
|
+
type: 'button',
|
|
190
|
+
onClick: openUsage,
|
|
191
|
+
title: '查看 NVIDIA 模型组调用日志',
|
|
192
|
+
style: {
|
|
193
|
+
display: 'inline-flex',
|
|
194
|
+
alignItems: 'center',
|
|
195
|
+
gap: '4px',
|
|
196
|
+
fontSize: '11px',
|
|
197
|
+
lineHeight: '1.2',
|
|
198
|
+
color: justSwitched ? '#e65100' : '#8fce00',
|
|
199
|
+
border: '1px solid ' + (justSwitched ? 'rgba(230,81,0,0.55)' : 'rgba(143,206,0,0.5)'),
|
|
200
|
+
background: justSwitched ? 'rgba(230,81,0,0.10)' : 'rgba(143,206,0,0.08)',
|
|
201
|
+
borderRadius: '999px',
|
|
202
|
+
padding: '2px 10px',
|
|
203
|
+
cursor: 'pointer',
|
|
204
|
+
whiteSpace: 'nowrap',
|
|
205
|
+
maxWidth: '420px',
|
|
206
|
+
overflow: 'hidden',
|
|
207
|
+
textOverflow: 'ellipsis',
|
|
208
|
+
height: '32px',
|
|
209
|
+
boxSizing: 'border-box',
|
|
210
|
+
flexShrink: 0,
|
|
211
|
+
marginRight: 'calc(-2 * var(--dsh-composer-dock-inset, 8px))',
|
|
212
|
+
},
|
|
213
|
+
}, label));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** 黄色警示条:未配置 Key 时在关键位置提示用户先去保存 Key。 */
|
|
217
|
+
function noKeyWarning(message) {
|
|
218
|
+
return h('div', {
|
|
219
|
+
style: {
|
|
220
|
+
padding: '8px 10px',
|
|
221
|
+
background: 'rgba(230,150,0,0.12)',
|
|
222
|
+
border: '1px solid rgba(230,150,0,0.55)',
|
|
223
|
+
borderRadius: '6px',
|
|
224
|
+
fontSize: '12px',
|
|
225
|
+
lineHeight: 1.5,
|
|
226
|
+
color: '#b8860b',
|
|
227
|
+
},
|
|
228
|
+
}, message);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function NvidiaModelsPanel(props) {
|
|
232
|
+
const [models, setModels] = useState([]);
|
|
233
|
+
const [detecting, setDetecting] = useState(false);
|
|
234
|
+
const [verifying, setVerifying] = useState(false);
|
|
235
|
+
const [message, setMessage] = useState('');
|
|
236
|
+
const [results, setResults] = useState({});
|
|
237
|
+
const [tab, setTab] = useState('models');
|
|
238
|
+
const cancelRef = useRef(false);
|
|
239
|
+
|
|
240
|
+
const onClose = props && props.onClose;
|
|
241
|
+
|
|
242
|
+
// ---- API key management ----
|
|
243
|
+
const [keyInput, setKeyInput] = useState('');
|
|
244
|
+
const [keyStatus, setKeyStatus] = useState(null);
|
|
245
|
+
const [keyBusy, setKeyBusy] = useState(false);
|
|
246
|
+
const [keyMsg, setKeyMsg] = useState('');
|
|
247
|
+
|
|
248
|
+
const refreshKeyStatus = useCallback(async function () {
|
|
249
|
+
try {
|
|
250
|
+
const response = await fetch('/api/nvidia-models', {
|
|
251
|
+
method: 'POST',
|
|
252
|
+
headers: { 'content-type': 'application/json' },
|
|
253
|
+
body: JSON.stringify({ action: 'keyStatus' }),
|
|
254
|
+
});
|
|
255
|
+
if (!response.ok) return;
|
|
256
|
+
const data = await response.json();
|
|
257
|
+
setKeyStatus(data);
|
|
258
|
+
} catch {
|
|
259
|
+
// Status check is best-effort; the panel still works without it.
|
|
260
|
+
}
|
|
261
|
+
}, []);
|
|
262
|
+
|
|
263
|
+
useEffect(function () { refreshKeyStatus(); }, [refreshKeyStatus]);
|
|
264
|
+
|
|
265
|
+
const saveKey = useCallback(async function () {
|
|
266
|
+
const key = keyInput.trim();
|
|
267
|
+
if (!key) { setKeyMsg('请先输入 API Key'); return; }
|
|
268
|
+
setKeyBusy(true);
|
|
269
|
+
setKeyMsg('保存中…');
|
|
270
|
+
try {
|
|
271
|
+
const response = await fetch('/api/nvidia-models', {
|
|
272
|
+
method: 'POST',
|
|
273
|
+
headers: { 'content-type': 'application/json' },
|
|
274
|
+
body: JSON.stringify({ action: 'setKey', key }),
|
|
275
|
+
});
|
|
276
|
+
const data = await response.json();
|
|
277
|
+
if (data && data.saved) {
|
|
278
|
+
setKeyInput('');
|
|
279
|
+
setKeyMsg('已保存到凭据存储(不进入配置文件)。正式 nvidia 模型路由下一次请求即生效,现在可以点「逐个试调用」。');
|
|
280
|
+
await refreshKeyStatus();
|
|
281
|
+
} else {
|
|
282
|
+
setKeyMsg('保存失败:' + ((data && data.error) || ('HTTP ' + response.status)));
|
|
283
|
+
}
|
|
284
|
+
} catch (error) {
|
|
285
|
+
setKeyMsg('保存请求失败:' + String((error && error.message) || error));
|
|
286
|
+
} finally {
|
|
287
|
+
setKeyBusy(false);
|
|
288
|
+
}
|
|
289
|
+
}, [keyInput, refreshKeyStatus]);
|
|
290
|
+
|
|
291
|
+
const clearKey = useCallback(async function () {
|
|
292
|
+
setKeyBusy(true);
|
|
293
|
+
setKeyMsg('清除中…');
|
|
294
|
+
try {
|
|
295
|
+
const response = await fetch('/api/nvidia-models', {
|
|
296
|
+
method: 'POST',
|
|
297
|
+
headers: { 'content-type': 'application/json' },
|
|
298
|
+
body: JSON.stringify({ action: 'clearKey' }),
|
|
299
|
+
});
|
|
300
|
+
const data = await response.json();
|
|
301
|
+
if (data && data.cleared) {
|
|
302
|
+
setKeyMsg('已清除存储的 Key(环境变量 NVIDIA_API_KEY 若存在将重新生效)。');
|
|
303
|
+
await refreshKeyStatus();
|
|
304
|
+
} else {
|
|
305
|
+
setKeyMsg('清除失败:' + ((data && data.error) || ('HTTP ' + response.status)));
|
|
306
|
+
}
|
|
307
|
+
} catch (error) {
|
|
308
|
+
setKeyMsg('清除请求失败:' + String((error && error.message) || error));
|
|
309
|
+
} finally {
|
|
310
|
+
setKeyBusy(false);
|
|
311
|
+
}
|
|
312
|
+
}, [refreshKeyStatus]);
|
|
313
|
+
|
|
314
|
+
const setOne = useCallback(function (id, patch) {
|
|
315
|
+
setResults(function (prev) {
|
|
316
|
+
const next = { ...prev };
|
|
317
|
+
next[id] = { ...(prev[id] || {}), ...patch };
|
|
318
|
+
return next;
|
|
319
|
+
});
|
|
320
|
+
}, []);
|
|
321
|
+
|
|
322
|
+
const detectModels = useCallback(async function () {
|
|
323
|
+
setDetecting(true);
|
|
324
|
+
setMessage('正在实时查询 NVIDIA API…');
|
|
325
|
+
setResults({});
|
|
326
|
+
try {
|
|
327
|
+
const response = await fetch('/api/nvidia-models', {
|
|
328
|
+
method: 'POST',
|
|
329
|
+
headers: { 'content-type': 'application/json' },
|
|
330
|
+
body: JSON.stringify({ action: 'detect' }),
|
|
331
|
+
});
|
|
332
|
+
if (!response.ok) throw new Error('HTTP ' + response.status);
|
|
333
|
+
const data = await response.json();
|
|
334
|
+
if (data && data.source === 'live' && Array.isArray(data.models)) {
|
|
335
|
+
setModels(data.models);
|
|
336
|
+
setMessage('实时检测到 ' + data.count + ' 个模型(来自 NVIDIA API)。点击「逐个试调用」验证每个模型真实可用性。');
|
|
337
|
+
} else {
|
|
338
|
+
setModels((data && data.models) || BUILTIN_MODELS);
|
|
339
|
+
setMessage((data && data.reason ? data.reason + ',' : '') + '已显示内置目录。');
|
|
340
|
+
}
|
|
341
|
+
} catch (error) {
|
|
342
|
+
setModels(BUILTIN_MODELS);
|
|
343
|
+
setMessage('检测请求失败:' + String((error && error.message) || error) + ',已显示内置目录。');
|
|
344
|
+
} finally {
|
|
345
|
+
setDetecting(false);
|
|
346
|
+
}
|
|
347
|
+
}, []);
|
|
348
|
+
|
|
349
|
+
/** Probe every listed model (shared by the verify button and configure). */
|
|
350
|
+
const runVerification = useCallback(async function (list) {
|
|
351
|
+
setVerifying(true);
|
|
352
|
+
cancelRef.current = false;
|
|
353
|
+
const queue = list.map(function (m) { return m.id; });
|
|
354
|
+
const finalResults = {};
|
|
355
|
+
let done = 0;
|
|
356
|
+
const total = list.length;
|
|
357
|
+
setResults({});
|
|
358
|
+
for (const id of queue) { finalResults[id] = { status: 'testing' }; setOne(id, { status: 'testing' }); }
|
|
359
|
+
setMessage('逐个试调用中(并发 ' + VERIFY_CONCURRENCY + ',流式首包判定)… 0/' + total);
|
|
360
|
+
|
|
361
|
+
async function worker() {
|
|
362
|
+
for (;;) {
|
|
363
|
+
if (cancelRef.current) return;
|
|
364
|
+
const id = queue.shift();
|
|
365
|
+
if (!id) return;
|
|
366
|
+
let outcome;
|
|
367
|
+
try {
|
|
368
|
+
const response = await fetch('/api/nvidia-models', {
|
|
369
|
+
method: 'POST',
|
|
370
|
+
headers: { 'content-type': 'application/json' },
|
|
371
|
+
body: JSON.stringify({ action: 'test', model: id }),
|
|
372
|
+
});
|
|
373
|
+
if (!response.ok) {
|
|
374
|
+
outcome = { status: 'fail', detail: '检测请求失败(HTTP ' + response.status + ')' };
|
|
375
|
+
} else {
|
|
376
|
+
const data = await response.json();
|
|
377
|
+
outcome = { status: data.status, detail: data.detail };
|
|
378
|
+
}
|
|
379
|
+
} catch (error) {
|
|
380
|
+
outcome = { status: 'fail', detail: '检测请求异常:' + String((error && error.message) || error) };
|
|
381
|
+
}
|
|
382
|
+
finalResults[id] = outcome;
|
|
383
|
+
setOne(id, outcome);
|
|
384
|
+
done += 1;
|
|
385
|
+
setMessage('逐个试调用中… ' + done + '/' + total);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const workers = [];
|
|
390
|
+
for (let i = 0; i < VERIFY_CONCURRENCY; i += 1) workers.push(worker());
|
|
391
|
+
await Promise.all(workers);
|
|
392
|
+
setVerifying(false);
|
|
393
|
+
return finalResults;
|
|
394
|
+
}, [setOne]);
|
|
395
|
+
|
|
396
|
+
const verifyAll = useCallback(async function () {
|
|
397
|
+
if (verifying || models.length === 0) return;
|
|
398
|
+
const finalResults = await runVerification(models);
|
|
399
|
+
const done = Object.keys(finalResults).length;
|
|
400
|
+
if (cancelRef.current) {
|
|
401
|
+
setMessage('试调用已手动停止(完成 ' + done + '/' + models.length + ')。');
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
const okCount = Object.values(finalResults).filter(function (r) { return r && r.status === 'ok'; }).length;
|
|
405
|
+
setMessage('试调用完成:' + done + ' 个模型,其中 ' + okCount + ' 个真实可用。点「一键配置到设置」把可用模型写入设置。');
|
|
406
|
+
}, [models, verifying, runVerification]);
|
|
407
|
+
|
|
408
|
+
const [configuring, setConfiguring] = useState(false);
|
|
409
|
+
|
|
410
|
+
/** One click: probe (if not yet done) then write ONLY the available models. */
|
|
411
|
+
const configureModels = useCallback(async function () {
|
|
412
|
+
if (configuring) return;
|
|
413
|
+
if (models.length === 0) {
|
|
414
|
+
setMessage('请先点「检测可用模型」获取列表。');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
setConfiguring(true);
|
|
418
|
+
const tested = Object.keys(results).filter(function (id) {
|
|
419
|
+
return results[id] && results[id].status !== 'testing';
|
|
420
|
+
}).length;
|
|
421
|
+
let finalResults = results;
|
|
422
|
+
if (tested < models.length) {
|
|
423
|
+
setMessage('尚未完成试调用——先自动逐个试调用,再写入可用模型…');
|
|
424
|
+
finalResults = await runVerification(models);
|
|
425
|
+
if (cancelRef.current) {
|
|
426
|
+
setMessage('试调用被手动停止,已中止配置。可再次点击继续。');
|
|
427
|
+
setConfiguring(false);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const probePayload = {};
|
|
432
|
+
for (const id of Object.keys(finalResults)) {
|
|
433
|
+
probePayload[id] = finalResults[id] && finalResults[id].status === 'ok' ? 'ok' : 'unavailable';
|
|
434
|
+
}
|
|
435
|
+
const okCount = Object.values(finalResults).filter(function (r) { return r && r.status === 'ok'; }).length;
|
|
436
|
+
setMessage('正在把 ' + okCount + ' 个可用模型写入设置…');
|
|
437
|
+
try {
|
|
438
|
+
const response = await fetch('/api/nvidia-models', {
|
|
439
|
+
method: 'POST',
|
|
440
|
+
headers: { 'content-type': 'application/json' },
|
|
441
|
+
body: JSON.stringify({ action: 'configure', results: probePayload }),
|
|
442
|
+
});
|
|
443
|
+
if (!response.ok) throw new Error('HTTP ' + response.status);
|
|
444
|
+
const data = await response.json();
|
|
445
|
+
if (data && data.ok) {
|
|
446
|
+
setMessage(data.message || '已写入设置。');
|
|
447
|
+
// 配置会改写 nvidia 供应商的模型列表,也即模型组的成员来源;
|
|
448
|
+
// 立即刷新健康看板并切到「模型组健康」页,让用户马上看到新成员。
|
|
449
|
+
try { await refreshGroup(); } catch { /* best-effort */ }
|
|
450
|
+
setTab('group');
|
|
451
|
+
} else {
|
|
452
|
+
setMessage('配置失败:' + ((data && data.error) || '未知错误'));
|
|
453
|
+
}
|
|
454
|
+
} catch (error) {
|
|
455
|
+
setMessage('配置请求失败:' + String((error && error.message) || error));
|
|
456
|
+
} finally {
|
|
457
|
+
setConfiguring(false);
|
|
458
|
+
}
|
|
459
|
+
}, [configuring, models, results, runVerification]);
|
|
460
|
+
|
|
461
|
+
const stopVerify = useCallback(function () {
|
|
462
|
+
cancelRef.current = true;
|
|
463
|
+
}, []);
|
|
464
|
+
|
|
465
|
+
// ---- model group health dashboard ----
|
|
466
|
+
const [group, setGroup] = useState(null);
|
|
467
|
+
const [groupBusy, setGroupBusy] = useState(false);
|
|
468
|
+
const [groupMsg, setGroupMsg] = useState('');
|
|
469
|
+
|
|
470
|
+
const refreshGroup = useCallback(async function () {
|
|
471
|
+
try {
|
|
472
|
+
const response = await fetch('/api/nvidia-models', {
|
|
473
|
+
method: 'POST',
|
|
474
|
+
headers: { 'content-type': 'application/json' },
|
|
475
|
+
body: JSON.stringify({ action: 'groupStatus' }),
|
|
476
|
+
});
|
|
477
|
+
if (!response.ok) return;
|
|
478
|
+
const data = await response.json();
|
|
479
|
+
if (data && data.ok) setGroup(data);
|
|
480
|
+
} catch {
|
|
481
|
+
// best-effort
|
|
482
|
+
}
|
|
483
|
+
}, []);
|
|
484
|
+
|
|
485
|
+
useEffect(function () { refreshGroup(); }, [refreshGroup]);
|
|
486
|
+
|
|
487
|
+
const probeGroupNow = useCallback(async function () {
|
|
488
|
+
if (groupBusy) return;
|
|
489
|
+
setGroupBusy(true);
|
|
490
|
+
setGroupMsg('正在探测模型组内每个成员(首包判定)…');
|
|
491
|
+
try {
|
|
492
|
+
const response = await fetch('/api/nvidia-models', {
|
|
493
|
+
method: 'POST',
|
|
494
|
+
headers: { 'content-type': 'application/json' },
|
|
495
|
+
body: JSON.stringify({ action: 'probeGroup' }),
|
|
496
|
+
});
|
|
497
|
+
const data = await response.json();
|
|
498
|
+
const okCount = (data && data.results) ? data.results.filter(function (r) { return r && r.status === 'ok'; }).length : 0;
|
|
499
|
+
setGroupMsg('探测完成:' + (data.probed || 0) + ' 个成员,其中 ' + okCount + ' 个可用。');
|
|
500
|
+
await refreshGroup();
|
|
501
|
+
} catch (error) {
|
|
502
|
+
setGroupMsg('探测请求失败:' + String((error && error.message) || error));
|
|
503
|
+
} finally {
|
|
504
|
+
setGroupBusy(false);
|
|
505
|
+
}
|
|
506
|
+
}, [groupBusy, refreshGroup]);
|
|
507
|
+
|
|
508
|
+
const resetGroupHealth = useCallback(async function (model) {
|
|
509
|
+
try {
|
|
510
|
+
const response = await fetch('/api/nvidia-models', {
|
|
511
|
+
method: 'POST',
|
|
512
|
+
headers: { 'content-type': 'application/json' },
|
|
513
|
+
body: JSON.stringify({ action: 'resetGroup', model: model || '' }),
|
|
514
|
+
});
|
|
515
|
+
const data = await response.json();
|
|
516
|
+
if (data && data.ok) setGroup(data);
|
|
517
|
+
setGroupMsg(model ? ('已重置 ' + model + ' 的熔断状态。') : '已重置全部成员的熔断状态。');
|
|
518
|
+
} catch (error) {
|
|
519
|
+
setGroupMsg('重置失败:' + String((error && error.message) || error));
|
|
520
|
+
}
|
|
521
|
+
}, []);
|
|
522
|
+
|
|
523
|
+
const groupCard = h('div', {
|
|
524
|
+
key: 'group',
|
|
525
|
+
style: {
|
|
526
|
+
padding: '12px',
|
|
527
|
+
background: 'rgba(118,185,0,0.06)',
|
|
528
|
+
border: '1px solid rgba(118,185,0,0.35)',
|
|
529
|
+
borderRadius: '6px',
|
|
530
|
+
display: 'flex',
|
|
531
|
+
flexDirection: 'column',
|
|
532
|
+
gap: '8px',
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px', flexWrap: 'wrap' } },
|
|
536
|
+
h('span', { style: { fontSize: '13px', fontWeight: 600 } }, '模型组健康看板(自愈故障转移)'),
|
|
537
|
+
h('div', { style: { display: 'flex', gap: '6px' } },
|
|
538
|
+
h('button', {
|
|
539
|
+
onClick: probeGroupNow,
|
|
540
|
+
disabled: groupBusy,
|
|
541
|
+
style: { padding: '5px 10px', fontSize: '12px', background: '#76B900', color: '#fff', border: 'none', borderRadius: '5px', cursor: groupBusy ? 'wait' : 'pointer', opacity: groupBusy ? 0.6 : 1 },
|
|
542
|
+
}, groupBusy ? '探测中…' : '探测模型组'),
|
|
543
|
+
h('button', {
|
|
544
|
+
onClick: refreshGroup,
|
|
545
|
+
style: { padding: '5px 10px', fontSize: '12px', background: 'transparent', border: '1px solid rgba(128,128,128,0.4)', color: 'inherit', borderRadius: '5px', cursor: 'pointer' },
|
|
546
|
+
}, '刷新')
|
|
547
|
+
)
|
|
548
|
+
),
|
|
549
|
+
h('p', { style: { margin: 0, fontSize: '11px', opacity: 0.7, lineHeight: 1.5 } },
|
|
550
|
+
'选中「NVIDIA 模型组」后,请求按健康度顺序尝试组内模型;首个成员超过 ' +
|
|
551
|
+
((group && group.config && group.config.firstByteTimeoutMs ? Math.round(group.config.firstByteTimeoutMs / 1000) : 15)) +
|
|
552
|
+
' 秒无首包会立即切下一个;连续失败自动熔断冷却。'),
|
|
553
|
+
groupMsg ? h('p', { style: { margin: 0, fontSize: '12px', lineHeight: 1.5 } }, groupMsg) : null,
|
|
554
|
+
(group && Array.isArray(group.members) && group.members.length > 0)
|
|
555
|
+
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px' } },
|
|
556
|
+
group.members.map(function (m) {
|
|
557
|
+
const cooling = m.cooldownRemainingMs > 0;
|
|
558
|
+
return h('div', {
|
|
559
|
+
key: m.id,
|
|
560
|
+
style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', padding: '6px 8px', background: 'rgba(128,128,128,0.06)', border: '1px solid rgba(128,128,128,0.2)', borderRadius: '5px' },
|
|
561
|
+
},
|
|
562
|
+
h('span', { style: { fontWeight: 600, fontSize: '12px' } }, m.name || m.id),
|
|
563
|
+
groupBadge(m.status),
|
|
564
|
+
cooling ? h('span', { style: { fontSize: '11px', color: '#b8860b' } }, '熔断中 · 剩余 ' + Math.ceil(m.cooldownRemainingMs / 1000) + 's') : null,
|
|
565
|
+
m.lastFirstByteMs !== null && m.lastFirstByteMs !== undefined ? h('span', { style: { fontSize: '11px', opacity: 0.65 } }, '首包 ' + m.lastFirstByteMs + 'ms') : null,
|
|
566
|
+
m.failCount > 0 ? h('span', { style: { fontSize: '11px', opacity: 0.65 } }, '失败 ' + m.failCount + ' 次') : null,
|
|
567
|
+
(cooling || m.failCount > 0) ? h('button', {
|
|
568
|
+
onClick: function () { resetGroupHealth(m.id); },
|
|
569
|
+
style: { marginLeft: 'auto', padding: '3px 8px', fontSize: '11px', background: 'transparent', border: '1px solid rgba(128,128,128,0.4)', color: 'inherit', borderRadius: '4px', cursor: 'pointer' },
|
|
570
|
+
}, '重置') : null,
|
|
571
|
+
m.lastError ? h('span', { style: { fontSize: '11px', color: '#c62828', flexBasis: '100%' } }, String(m.lastError).slice(0, 160)) : null
|
|
572
|
+
);
|
|
573
|
+
})
|
|
574
|
+
)
|
|
575
|
+
: h('p', { style: { margin: 0, fontSize: '12px', opacity: 0.6 } },
|
|
576
|
+
'组内暂无模型:先在下方「检测可用模型 → 逐个试调用 → 一键配置到设置」写入至少一个可用模型。'),
|
|
577
|
+
h('div', { style: { display: 'flex', gap: '8px', flexWrap: 'wrap', paddingTop: '2px' } },
|
|
578
|
+
h('span', { style: { fontSize: '11px', opacity: 0.7, alignSelf: 'center' } }, '在对话框模型选择器里选择「NVIDIA 模型组(自动)」即可交由模型组自动选优与故障转移。'),
|
|
579
|
+
h('button', {
|
|
580
|
+
onClick: function () { resetGroupHealth(''); },
|
|
581
|
+
style: { padding: '3px 8px', fontSize: '11px', background: 'transparent', border: '1px solid rgba(128,128,128,0.4)', color: 'inherit', borderRadius: '4px', cursor: 'pointer' },
|
|
582
|
+
}, '重置全部熔断')
|
|
583
|
+
)
|
|
584
|
+
);
|
|
585
|
+
|
|
586
|
+
// ---- daily usage log (调用日志) ----
|
|
587
|
+
const [usage, setUsage] = useState(null);
|
|
588
|
+
const [usageBusy, setUsageBusy] = useState(false);
|
|
589
|
+
const [usageMsg, setUsageMsg] = useState('');
|
|
590
|
+
// 「?」使用说明弹窗开关(方案 A:标题栏入口 + 居中浮层)
|
|
591
|
+
const [helpOpen, setHelpOpen] = useState(false);
|
|
592
|
+
// ---- 新版本检测 ----
|
|
593
|
+
const [updateInfo, setUpdateInfo] = useState(null);
|
|
594
|
+
const [updateBusy, setUpdateBusy] = useState(false);
|
|
595
|
+
|
|
596
|
+
const refreshUsage = useCallback(async function () {
|
|
597
|
+
try {
|
|
598
|
+
const response = await fetch('/api/nvidia-models', {
|
|
599
|
+
method: 'POST',
|
|
600
|
+
headers: { 'content-type': 'application/json' },
|
|
601
|
+
body: JSON.stringify({ action: 'usageStats' }),
|
|
602
|
+
});
|
|
603
|
+
if (!response.ok) return;
|
|
604
|
+
const data = await response.json();
|
|
605
|
+
if (data && data.ok) setUsage(data.stats);
|
|
606
|
+
} catch {
|
|
607
|
+
// best-effort
|
|
608
|
+
}
|
|
609
|
+
}, []);
|
|
610
|
+
|
|
611
|
+
const refreshUpdateCheck = useCallback(async function () {
|
|
612
|
+
if (updateBusy) return;
|
|
613
|
+
setUpdateBusy(true);
|
|
614
|
+
try {
|
|
615
|
+
const response = await fetch('/api/nvidia-models', {
|
|
616
|
+
method: 'POST',
|
|
617
|
+
headers: { 'content-type': 'application/json' },
|
|
618
|
+
body: JSON.stringify({ action: 'checkUpdate' }),
|
|
619
|
+
});
|
|
620
|
+
if (!response.ok) return;
|
|
621
|
+
const data = await response.json();
|
|
622
|
+
if (data && data.ok) setUpdateInfo(data);
|
|
623
|
+
} catch {
|
|
624
|
+
// best-effort
|
|
625
|
+
} finally {
|
|
626
|
+
setUpdateBusy(false);
|
|
627
|
+
}
|
|
628
|
+
}, []);
|
|
629
|
+
|
|
630
|
+
// Check once on mount.
|
|
631
|
+
useEffect(function () { refreshUpdateCheck(); }, [refreshUpdateCheck]);
|
|
632
|
+
|
|
633
|
+
// 输入框 dock 徽标点击后,切到「调用日志」标签页。
|
|
634
|
+
useEffect(function () {
|
|
635
|
+
function onOpenUsage() { setTab('usage'); }
|
|
636
|
+
try {
|
|
637
|
+
window.addEventListener('nvidia-models-open-usage', onOpenUsage);
|
|
638
|
+
return function () { window.removeEventListener('nvidia-models-open-usage', onOpenUsage); };
|
|
639
|
+
} catch {
|
|
640
|
+
return undefined;
|
|
641
|
+
}
|
|
642
|
+
}, []);
|
|
643
|
+
|
|
644
|
+
// Refresh when the user switches to the usage tab.
|
|
645
|
+
useEffect(function () {
|
|
646
|
+
if (tab === 'usage') refreshUsage();
|
|
647
|
+
}, [tab, refreshUsage]);
|
|
648
|
+
|
|
649
|
+
const resetUsageToday = useCallback(async function () {
|
|
650
|
+
if (usageBusy) return;
|
|
651
|
+
setUsageBusy(true);
|
|
652
|
+
try {
|
|
653
|
+
const response = await fetch('/api/nvidia-models', {
|
|
654
|
+
method: 'POST',
|
|
655
|
+
headers: { 'content-type': 'application/json' },
|
|
656
|
+
body: JSON.stringify({ action: 'resetUsage' }),
|
|
657
|
+
});
|
|
658
|
+
const data = await response.json();
|
|
659
|
+
if (data && data.ok) setUsage(data.stats);
|
|
660
|
+
setUsageMsg('已清空当日统计。');
|
|
661
|
+
} catch (error) {
|
|
662
|
+
setUsageMsg('清空失败:' + String((error && error.message) || error));
|
|
663
|
+
} finally {
|
|
664
|
+
setUsageBusy(false);
|
|
665
|
+
}
|
|
666
|
+
}, [usageBusy]);
|
|
667
|
+
|
|
668
|
+
const fmtTokens = function (n) {
|
|
669
|
+
const v = Number(n) || 0;
|
|
670
|
+
if (v >= 1000000) return (v / 1000000).toFixed(2) + 'M';
|
|
671
|
+
if (v >= 1000) return (v / 1000).toFixed(1) + 'k';
|
|
672
|
+
return String(v);
|
|
673
|
+
};
|
|
674
|
+
const fmtTime = function (ts) {
|
|
675
|
+
if (!ts) return '';
|
|
676
|
+
try {
|
|
677
|
+
const d = new Date(ts);
|
|
678
|
+
const p = function (x) { return String(x).padStart(2, '0'); };
|
|
679
|
+
return p(d.getHours()) + ':' + p(d.getMinutes()) + ':' + p(d.getSeconds());
|
|
680
|
+
} catch { return ''; }
|
|
681
|
+
};
|
|
682
|
+
const statBox = function (label, value, color) {
|
|
683
|
+
return h('div', {
|
|
684
|
+
key: 'stat-' + label,
|
|
685
|
+
style: { flex: '1 1 0', minWidth: '74px', padding: '8px', background: 'rgba(128,128,128,0.08)', border: '1px solid rgba(128,128,128,0.2)', borderRadius: '5px', display: 'flex', flexDirection: 'column', gap: '2px', alignItems: 'center' },
|
|
686
|
+
},
|
|
687
|
+
h('span', { style: { fontSize: '10px', opacity: 0.65 } }, label),
|
|
688
|
+
h('span', { style: { fontSize: '15px', fontWeight: 600, color: color || 'inherit' } }, value)
|
|
689
|
+
);
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const usageTotal = (usage && usage.total) || { calls: 0, ok: 0, fail: 0, failovers: 0, inputTokens: 0, outputTokens: 0 };
|
|
693
|
+
const usageMembers = (usage && Array.isArray(usage.members)) ? usage.members : [];
|
|
694
|
+
const usageLog = (usage && Array.isArray(usage.log)) ? usage.log : [];
|
|
695
|
+
|
|
696
|
+
const usageCard = h('div', {
|
|
697
|
+
key: 'usage',
|
|
698
|
+
style: { padding: '12px', background: 'rgba(118,185,0,0.06)', border: '1px solid rgba(118,185,0,0.35)', borderRadius: '6px', display: 'flex', flexDirection: 'column', gap: '10px' },
|
|
699
|
+
},
|
|
700
|
+
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px', flexWrap: 'wrap' } },
|
|
701
|
+
h('span', { style: { fontSize: '13px', fontWeight: 600 } }, '当天模型组调用日志' + (usage && usage.day ? '(' + usage.day + ')' : '')),
|
|
702
|
+
h('div', { style: { display: 'flex', gap: '6px' } },
|
|
703
|
+
h('button', {
|
|
704
|
+
onClick: refreshUsage,
|
|
705
|
+
style: { padding: '5px 10px', fontSize: '12px', background: '#76B900', color: '#fff', border: 'none', borderRadius: '5px', cursor: 'pointer' },
|
|
706
|
+
}, '刷新'),
|
|
707
|
+
h('button', {
|
|
708
|
+
onClick: resetUsageToday,
|
|
709
|
+
disabled: usageBusy,
|
|
710
|
+
style: { padding: '5px 10px', fontSize: '12px', background: 'transparent', border: '1px solid rgba(128,128,128,0.4)', color: 'inherit', borderRadius: '5px', cursor: usageBusy ? 'wait' : 'pointer' },
|
|
711
|
+
}, '清空当日统计')
|
|
712
|
+
)
|
|
713
|
+
),
|
|
714
|
+
usageMsg ? h('p', { style: { margin: 0, fontSize: '12px', lineHeight: 1.5 } }, usageMsg) : null,
|
|
715
|
+
h('div', { style: { display: 'flex', gap: '6px', flexWrap: 'wrap' } },
|
|
716
|
+
statBox('总调用', String(usageTotal.calls)),
|
|
717
|
+
statBox('成功', String(usageTotal.ok), '#2e7d32'),
|
|
718
|
+
statBox('失败', String(usageTotal.fail), usageTotal.fail ? '#c62828' : 'inherit'),
|
|
719
|
+
statBox('自动切换', String(usageTotal.failovers), usageTotal.failovers ? '#b8860b' : 'inherit'),
|
|
720
|
+
statBox('输入 token', fmtTokens(usageTotal.inputTokens)),
|
|
721
|
+
statBox('输出 token', fmtTokens(usageTotal.outputTokens))
|
|
722
|
+
),
|
|
723
|
+
usageMembers.length
|
|
724
|
+
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
|
|
725
|
+
usageMembers.map(function (m) {
|
|
726
|
+
return h('div', {
|
|
727
|
+
key: 'um-' + m.id,
|
|
728
|
+
style: { display: 'flex', flexDirection: 'column', gap: '3px', padding: '6px 8px', background: 'rgba(128,128,128,0.06)', border: '1px solid rgba(128,128,128,0.18)', borderRadius: '4px' },
|
|
729
|
+
},
|
|
730
|
+
h('div', { style: { display: 'flex', gap: '6px', alignItems: 'baseline' } },
|
|
731
|
+
h('span', { style: { flex: '1 1 auto', fontSize: '12px', fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, String(m.id).replace(/^nvidia\//, '')),
|
|
732
|
+
m.failovers ? h('span', { style: { fontSize: '11px', color: '#b8860b', flex: '0 0 auto' } }, '切换 ' + m.failovers + ' 次') : h('span', { style: { fontSize: '11px', opacity: 0.6, flex: '0 0 auto' } }, '共 ' + m.calls + ' 次')
|
|
733
|
+
),
|
|
734
|
+
h('div', { style: { display: 'flex', gap: '10px', fontSize: '11px', flexWrap: 'wrap', opacity: 0.85 } },
|
|
735
|
+
h('span', { style: { color: '#2e7d32' } }, '✓ ' + m.ok),
|
|
736
|
+
m.fail ? h('span', { style: { color: '#c62828' } }, '✗ ' + m.fail) : null,
|
|
737
|
+
h('span', null, '平均首包 ' + (m.avgFirstByteMs ? m.avgFirstByteMs + 'ms' : '—')),
|
|
738
|
+
h('span', null, 'token ' + fmtTokens(m.inputTokens + m.outputTokens))
|
|
739
|
+
)
|
|
740
|
+
);
|
|
741
|
+
})
|
|
742
|
+
)
|
|
743
|
+
: h('p', { style: { margin: 0, fontSize: '12px', opacity: 0.6 } }, '今天还没有调用记录。在对话框模型选择器里选中「NVIDIA 模型组」并发起一轮对话即可产生记录。'),
|
|
744
|
+
usageLog.length
|
|
745
|
+
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '3px', maxHeight: '260px', overflow: 'auto' } },
|
|
746
|
+
h('div', { style: { fontSize: '11px', opacity: 0.6, padding: '0 6px' } }, '最近调用(最新在上,最多 200 条)'),
|
|
747
|
+
usageLog.map(function (e, i) {
|
|
748
|
+
return h('div', {
|
|
749
|
+
key: 'ul-' + i,
|
|
750
|
+
style: { display: 'flex', fontSize: '11px', gap: '8px', padding: '4px 6px', background: 'rgba(128,128,128,0.05)', borderLeft: '3px solid ' + (e.ok ? '#76B900' : '#c62828'), alignItems: 'center', flexWrap: 'wrap' },
|
|
751
|
+
},
|
|
752
|
+
h('span', { style: { flex: '0 0 58px', opacity: 0.6 } }, fmtTime(e.at)),
|
|
753
|
+
h('span', { style: { fontWeight: 600 } }, e.ok ? '✓' : '✗'),
|
|
754
|
+
h('span', { style: { flex: '1 1 120px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, String(e.memberId).replace(/^nvidia\//, '')),
|
|
755
|
+
e.failover ? h('span', { style: { fontSize: '10px', color: '#b8860b' } }, '← 切换自 ' + String(e.failoverFrom || '').replace(/^nvidia\//, '')) : null,
|
|
756
|
+
e.ok ? h('span', { style: { opacity: 0.7 } }, '首包 ' + (e.firstByteMs || 0) + 'ms') : null,
|
|
757
|
+
(e.inputTokens || e.outputTokens) ? h('span', { style: { opacity: 0.7 } }, 'tok ' + fmtTokens(e.inputTokens) + '/' + fmtTokens(e.outputTokens)) : null,
|
|
758
|
+
e.error ? h('span', { style: { flexBasis: '100%', color: '#c62828', fontSize: '10px' } }, String(e.error).slice(0, 140)) : null
|
|
759
|
+
);
|
|
760
|
+
})
|
|
761
|
+
)
|
|
762
|
+
: null
|
|
763
|
+
);
|
|
764
|
+
|
|
765
|
+
// Tab bar — keeps actions + list on the "模型库" tab, the health
|
|
766
|
+
// dashboard on its own tab, and the daily usage log on a third, so the
|
|
767
|
+
// primary buttons are never pushed off the bottom of the panel.
|
|
768
|
+
const tabButton = function (id, label) {
|
|
769
|
+
const active = tab === id;
|
|
770
|
+
return h('button', {
|
|
771
|
+
key: id,
|
|
772
|
+
onClick: function () { setTab(id); },
|
|
773
|
+
style: {
|
|
774
|
+
padding: '7px 14px',
|
|
775
|
+
fontSize: '13px',
|
|
776
|
+
fontWeight: active ? 600 : 500,
|
|
777
|
+
background: 'transparent',
|
|
778
|
+
color: 'inherit',
|
|
779
|
+
border: 'none',
|
|
780
|
+
borderBottom: active ? '2px solid #76B900' : '2px solid transparent',
|
|
781
|
+
cursor: 'pointer',
|
|
782
|
+
opacity: active ? 1 : 0.62,
|
|
783
|
+
marginBottom: '-1px',
|
|
784
|
+
},
|
|
785
|
+
}, label);
|
|
786
|
+
};
|
|
787
|
+
const tabBar = h('div', {
|
|
788
|
+
key: 'tabs',
|
|
789
|
+
style: { display: 'flex', gap: '2px', borderBottom: '1px solid rgba(128,128,128,0.3)' },
|
|
790
|
+
}, [tabButton('models', '模型库'), tabButton('group', '模型组健康'), tabButton('usage', '调用日志')]);
|
|
791
|
+
|
|
792
|
+
// ---- 使用说明(方案 A:标题栏「?」→ 居中浮层)----
|
|
793
|
+
const helpRow = function (label, text) {
|
|
794
|
+
return h('div', { style: { display: 'flex', gap: '8px', fontSize: '12px', lineHeight: 1.55 } },
|
|
795
|
+
h('span', { style: { flex: '0 0 66px', fontWeight: 600, color: '#8fce00' } }, label),
|
|
796
|
+
h('span', { style: { flex: '1 1 auto', opacity: 0.9 } }, text)
|
|
797
|
+
);
|
|
798
|
+
};
|
|
799
|
+
const helpStep = function (n, title, text) {
|
|
800
|
+
return h('div', { key: 'help-step-' + n, style: { display: 'flex', gap: '10px', alignItems: 'flex-start' } },
|
|
801
|
+
h('span', {
|
|
802
|
+
style: { flex: '0 0 20px', height: '20px', borderRadius: '50%', background: '#76B900', color: '#fff', fontSize: '12px', fontWeight: 700, display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: '1px' },
|
|
803
|
+
}, String(n)),
|
|
804
|
+
h('span', { style: { flex: '1 1 auto', fontSize: '12.5px', lineHeight: 1.55 } },
|
|
805
|
+
h('b', { style: { color: 'inherit' } }, title), ':', text)
|
|
806
|
+
);
|
|
807
|
+
};
|
|
808
|
+
const helpModal = !helpOpen ? null : h('div', {
|
|
809
|
+
key: 'help-overlay',
|
|
810
|
+
onClick: function (e) { if (e.target === e.currentTarget) setHelpOpen(false); },
|
|
811
|
+
style: {
|
|
812
|
+
position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 1000,
|
|
813
|
+
background: 'rgba(0,0,0,0.55)',
|
|
814
|
+
display: 'flex', alignItems: 'flex-start', justifyContent: 'center',
|
|
815
|
+
padding: '24px 12px', overflow: 'auto',
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
h('div', {
|
|
819
|
+
role: 'dialog',
|
|
820
|
+
'aria-label': '使用说明',
|
|
821
|
+
style: {
|
|
822
|
+
width: '100%', maxWidth: '348px',
|
|
823
|
+
background: 'var(--dsh-surface, #1b1d20)',
|
|
824
|
+
color: 'inherit',
|
|
825
|
+
border: '1px solid rgba(128,128,128,0.35)',
|
|
826
|
+
borderRadius: '10px',
|
|
827
|
+
boxShadow: '0 12px 40px rgba(0,0,0,0.5)',
|
|
828
|
+
padding: '16px',
|
|
829
|
+
display: 'flex', flexDirection: 'column', gap: '12px',
|
|
830
|
+
flex: '0 0 auto',
|
|
831
|
+
},
|
|
832
|
+
},
|
|
833
|
+
h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' } },
|
|
834
|
+
h('span', { style: { fontSize: '15px', fontWeight: 700 } }, '使用说明'),
|
|
835
|
+
h('button', {
|
|
836
|
+
onClick: function () { setHelpOpen(false); },
|
|
837
|
+
'aria-label': '关闭使用说明',
|
|
838
|
+
style: { background: 'transparent', border: 'none', cursor: 'pointer', color: 'inherit', display: 'flex', alignItems: 'center', padding: '2px' },
|
|
839
|
+
}, h('svg', { viewBox: '0 0 24 24', width: 18, height: 18, fill: 'currentColor', 'aria-hidden': 'true' },
|
|
840
|
+
h('path', { d: 'M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z' })))
|
|
841
|
+
),
|
|
842
|
+
keyStatus && !keyStatus.configured
|
|
843
|
+
? h('div', { style: { fontSize: '12px', color: '#b8860b', border: '1px solid rgba(184,134,11,0.5)', background: 'rgba(184,134,11,0.08)', borderRadius: '6px', padding: '7px 10px', lineHeight: 1.5 } },
|
|
844
|
+
'尚未配置 NVIDIA API Key —— 请先在上方「NVIDIA API Key」卡片粘贴保存后再继续。')
|
|
845
|
+
: null,
|
|
846
|
+
helpStep(1, '配置 Key', '粘贴 nvapi-… Key 并保存,即与正式 nvidia 路由共用凭据,不会写入配置文件或日志。'),
|
|
847
|
+
helpStep(2, '检测 → 验证 → 一键配置', '在「模型库」点「检测可用模型」,再「逐个试调用」,最后「一键配置到设置」;只有试调用通过的模型会写入 llm-pi-ai 路由。'),
|
|
848
|
+
helpStep(3, '启用自动故障转移', '在对话框模型选择器里选「NVIDIA 模型组(自动)」,请求会按实时健康排序并自动切换,无需指定首选模型。'),
|
|
849
|
+
helpStep(4, '看效果', '「模型组健康」页看熔断状态与各成员首包用时;「调用日志」页看当天总用量、各模型使用量与每次自动切换记录。'),
|
|
850
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px', borderTop: '1px solid rgba(128,128,128,0.25)', paddingTop: '10px' } },
|
|
851
|
+
h('span', { style: { fontSize: '12px', fontWeight: 700 } }, '机制要点'),
|
|
852
|
+
helpRow('故障转移', '选中成员首包超过 15 秒无响应即立刻切下一个;已有内容输出后不再切换,避免前后不连贯。'),
|
|
853
|
+
helpRow('熔断冷却', '某成员连续失败进入冷却,20 秒起指数退避、最长 5 分钟,冷却结束后自动恢复。'),
|
|
854
|
+
helpRow('能力路由', '带图片的请求只会分给支持视觉的成员(vision / vl / omni)。'),
|
|
855
|
+
helpRow('自发现', '后台每 5 分钟刷新一次模型列表,新增可用模型自动进组。'),
|
|
856
|
+
helpRow('token 计数', '上游未回传 usage 时 token 显示为 0,不影响调用本身。')
|
|
857
|
+
)
|
|
858
|
+
)
|
|
859
|
+
);
|
|
860
|
+
|
|
861
|
+
// 未配置 Key:主操作按钮禁用、关键位置给出就地提示(凭据服务不可用时不做拦截)。
|
|
862
|
+
const noKey = Boolean(keyStatus && !keyStatus.configured && !keyStatus.unavailable);
|
|
863
|
+
const keyHint = '尚未配置 NVIDIA API Key —— 请先在上方「NVIDIA API Key」卡片粘贴保存后再继续。';
|
|
864
|
+
|
|
865
|
+
return h('div', {
|
|
866
|
+
className: 'nvidia-models-panel',
|
|
867
|
+
style: {
|
|
868
|
+
display: 'flex',
|
|
869
|
+
flexDirection: 'column',
|
|
870
|
+
height: '100%',
|
|
871
|
+
padding: '16px',
|
|
872
|
+
boxSizing: 'border-box',
|
|
873
|
+
background: 'transparent',
|
|
874
|
+
color: 'inherit',
|
|
875
|
+
overflow: 'auto',
|
|
876
|
+
gap: '12px',
|
|
877
|
+
position: 'relative',
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
h('div', {
|
|
881
|
+
key: 'header',
|
|
882
|
+
style: {
|
|
883
|
+
display: 'flex',
|
|
884
|
+
alignItems: 'center',
|
|
885
|
+
justifyContent: 'space-between',
|
|
886
|
+
paddingBottom: '12px',
|
|
887
|
+
borderBottom: '1px solid rgba(128,128,128,0.3)',
|
|
888
|
+
},
|
|
889
|
+
},
|
|
890
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
|
|
891
|
+
h('svg', {
|
|
892
|
+
viewBox: '0 0 24 24',
|
|
893
|
+
width: 22,
|
|
894
|
+
height: 22,
|
|
895
|
+
fill: '#76B900',
|
|
896
|
+
'aria-hidden': 'true',
|
|
897
|
+
}, h('path', { d: 'M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5' })),
|
|
898
|
+
h('h2', { style: { margin: 0, fontSize: '16px', fontWeight: 600 } }, 'NVIDIA 模型'),
|
|
899
|
+
(function () {
|
|
900
|
+
const info = updateInfo;
|
|
901
|
+
const hasUpdate = Boolean(info && info.hasUpdate);
|
|
902
|
+
const failed = Boolean(info && info.reachable === false && !hasUpdate);
|
|
903
|
+
const currentVersion = info && info.currentVersion ? String(info.currentVersion).replace(/^v/, '') : null;
|
|
904
|
+
let label, color;
|
|
905
|
+
if (hasUpdate) {
|
|
906
|
+
label = '新版本 ↑ ' + (info.latestTag || '');
|
|
907
|
+
color = '230,170,0';
|
|
908
|
+
} else if (currentVersion) {
|
|
909
|
+
// 已知当前版本且无新版本:一律显示版本号;网络不可达时加 ⚠ 提示可点击重试
|
|
910
|
+
label = 'v' + currentVersion + (failed ? ' ⚠' : '');
|
|
911
|
+
color = failed ? '200,120,60' : '128,128,128';
|
|
912
|
+
} else if (failed) {
|
|
913
|
+
label = '检查失败 · 重试';
|
|
914
|
+
color = '200,120,60';
|
|
915
|
+
} else {
|
|
916
|
+
label = updateBusy ? '检查中…' : '检查更新';
|
|
917
|
+
color = '128,128,128';
|
|
918
|
+
}
|
|
919
|
+
return h('button', {
|
|
920
|
+
onClick: function () {
|
|
921
|
+
if (hasUpdate) {
|
|
922
|
+
const url = info.latestUrl || 'https://github.com/windxxf/dsh-nvidia-models-panel/releases/latest';
|
|
923
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
924
|
+
} else if (!updateBusy) {
|
|
925
|
+
refreshUpdateCheck();
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
disabled: updateBusy && !hasUpdate,
|
|
929
|
+
title: hasUpdate ? (info.message || '查看更新') : (currentVersion ? ('当前版本 v' + currentVersion + (failed ? '(检查更新失败,点击重试)' : ',点击重新检查')) : '检查更新'),
|
|
930
|
+
style: {
|
|
931
|
+
padding: '3px 9px',
|
|
932
|
+
fontSize: '11px',
|
|
933
|
+
lineHeight: 1.4,
|
|
934
|
+
color: 'rgb(' + color + ')',
|
|
935
|
+
background: 'rgba(' + color + ',0.12)',
|
|
936
|
+
border: '1px solid rgba(' + color + ',0.35)',
|
|
937
|
+
borderRadius: '999px',
|
|
938
|
+
cursor: (hasUpdate || !updateBusy) ? 'pointer' : 'default',
|
|
939
|
+
whiteSpace: 'nowrap',
|
|
940
|
+
opacity: (updateBusy && !hasUpdate) ? 0.6 : 1,
|
|
941
|
+
},
|
|
942
|
+
}, label);
|
|
943
|
+
})()
|
|
944
|
+
),
|
|
945
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: '6px' } },
|
|
946
|
+
h('button', {
|
|
947
|
+
onClick: function () { setHelpOpen(true); },
|
|
948
|
+
'aria-label': '使用说明',
|
|
949
|
+
title: '使用说明',
|
|
950
|
+
style: {
|
|
951
|
+
background: 'transparent',
|
|
952
|
+
border: '1px solid rgba(128,128,128,0.4)',
|
|
953
|
+
borderRadius: '50%',
|
|
954
|
+
width: '20px',
|
|
955
|
+
height: '20px',
|
|
956
|
+
cursor: 'pointer',
|
|
957
|
+
color: 'inherit',
|
|
958
|
+
fontSize: '12px',
|
|
959
|
+
fontWeight: 700,
|
|
960
|
+
display: 'flex',
|
|
961
|
+
alignItems: 'center',
|
|
962
|
+
justifyContent: 'center',
|
|
963
|
+
opacity: 0.8,
|
|
964
|
+
padding: 0,
|
|
965
|
+
},
|
|
966
|
+
}, '?'),
|
|
967
|
+
h('button', {
|
|
968
|
+
onClick: onClose,
|
|
969
|
+
'aria-label': '关闭面板',
|
|
970
|
+
style: {
|
|
971
|
+
background: 'transparent',
|
|
972
|
+
border: 'none',
|
|
973
|
+
cursor: 'pointer',
|
|
974
|
+
padding: '4px',
|
|
975
|
+
color: 'inherit',
|
|
976
|
+
display: 'flex',
|
|
977
|
+
alignItems: 'center',
|
|
978
|
+
},
|
|
979
|
+
}, h('svg', { viewBox: '0 0 24 24', width: 18, height: 18, fill: 'currentColor', 'aria-hidden': 'true' },
|
|
980
|
+
h('path', { d: 'M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z' })))
|
|
981
|
+
)
|
|
982
|
+
),
|
|
983
|
+
h('div', {
|
|
984
|
+
key: 'apikey',
|
|
985
|
+
style: {
|
|
986
|
+
padding: '12px',
|
|
987
|
+
background: 'rgba(128,128,128,0.06)',
|
|
988
|
+
border: '1px solid rgba(128,128,128,0.25)',
|
|
989
|
+
borderRadius: '6px',
|
|
990
|
+
display: 'flex',
|
|
991
|
+
flexDirection: 'column',
|
|
992
|
+
gap: '8px',
|
|
993
|
+
},
|
|
994
|
+
},
|
|
995
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' } },
|
|
996
|
+
h('span', { style: { fontSize: '13px', fontWeight: 600 } }, 'NVIDIA API Key'),
|
|
997
|
+
keyStatus ? (keyStatus.configured
|
|
998
|
+
? h('span', { style: { fontSize: '11px', color: '#2e7d32', border: '1px solid #2e7d32', borderRadius: '4px', padding: '1px 6px', background: 'rgba(46,125,50,0.10)' } },
|
|
999
|
+
'已配置' + (keyStatus.source ? '(' + keyStatus.source + ')' : ''))
|
|
1000
|
+
: h('button', {
|
|
1001
|
+
type: 'button',
|
|
1002
|
+
title: NVIDIA_KEY_HINT,
|
|
1003
|
+
onClick: function () { window.open(NVIDIA_KEY_URL, '_blank', 'noopener,noreferrer'); },
|
|
1004
|
+
style: {
|
|
1005
|
+
display: 'inline-flex',
|
|
1006
|
+
alignItems: 'center',
|
|
1007
|
+
gap: '4px',
|
|
1008
|
+
whiteSpace: 'nowrap',
|
|
1009
|
+
flexShrink: 0,
|
|
1010
|
+
fontSize: '11px',
|
|
1011
|
+
opacity: 0.85,
|
|
1012
|
+
border: '1px dashed rgba(128,128,128,0.6)',
|
|
1013
|
+
borderRadius: '4px',
|
|
1014
|
+
padding: '1px 6px',
|
|
1015
|
+
background: 'transparent',
|
|
1016
|
+
color: 'inherit',
|
|
1017
|
+
cursor: 'pointer',
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
'未配置',
|
|
1021
|
+
h('span', {
|
|
1022
|
+
style: {
|
|
1023
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
|
1024
|
+
width: '13px', height: '13px', borderRadius: '50%',
|
|
1025
|
+
border: '1px solid currentColor', fontSize: '9px', lineHeight: '1', fontWeight: 700,
|
|
1026
|
+
},
|
|
1027
|
+
}, '?')
|
|
1028
|
+
)) : null,
|
|
1029
|
+
keyStatus && keyStatus.unavailable ? h('span', { style: { fontSize: '11px', color: '#b8860b' } }, '(凭据服务不可用)') : null,
|
|
1030
|
+
),
|
|
1031
|
+
h('div', { style: { display: 'flex', gap: '8px', flexWrap: 'wrap' } },
|
|
1032
|
+
h('input', {
|
|
1033
|
+
type: 'password',
|
|
1034
|
+
value: keyInput,
|
|
1035
|
+
onChange: function (e) { setKeyInput(e.target.value); },
|
|
1036
|
+
placeholder: '输入 nvapi-… Key(密文显示,不回显)',
|
|
1037
|
+
autoComplete: 'off',
|
|
1038
|
+
style: {
|
|
1039
|
+
flex: 1,
|
|
1040
|
+
minWidth: '200px',
|
|
1041
|
+
padding: '7px 12px',
|
|
1042
|
+
fontSize: '13px',
|
|
1043
|
+
border: '1px solid rgba(128,128,128,0.4)',
|
|
1044
|
+
borderRadius: '6px',
|
|
1045
|
+
background: 'transparent',
|
|
1046
|
+
color: 'inherit',
|
|
1047
|
+
boxSizing: 'border-box',
|
|
1048
|
+
},
|
|
1049
|
+
}),
|
|
1050
|
+
h('button', {
|
|
1051
|
+
onClick: saveKey,
|
|
1052
|
+
disabled: keyBusy || !keyInput.trim(),
|
|
1053
|
+
style: {
|
|
1054
|
+
padding: '7px 14px',
|
|
1055
|
+
fontSize: '13px',
|
|
1056
|
+
fontWeight: 500,
|
|
1057
|
+
background: '#76B900',
|
|
1058
|
+
color: '#ffffff',
|
|
1059
|
+
border: 'none',
|
|
1060
|
+
borderRadius: '6px',
|
|
1061
|
+
cursor: (keyBusy || !keyInput.trim()) ? 'wait' : 'pointer',
|
|
1062
|
+
opacity: (keyBusy || !keyInput.trim()) ? 0.6 : 1,
|
|
1063
|
+
},
|
|
1064
|
+
}, '保存 Key'),
|
|
1065
|
+
keyStatus && keyStatus.configured && keyStatus.writable ? h('button', {
|
|
1066
|
+
onClick: clearKey,
|
|
1067
|
+
disabled: keyBusy,
|
|
1068
|
+
style: {
|
|
1069
|
+
padding: '7px 14px',
|
|
1070
|
+
fontSize: '13px',
|
|
1071
|
+
background: 'transparent',
|
|
1072
|
+
border: '1px solid rgba(198,40,40,0.7)',
|
|
1073
|
+
color: '#c62828',
|
|
1074
|
+
borderRadius: '6px',
|
|
1075
|
+
cursor: keyBusy ? 'wait' : 'pointer',
|
|
1076
|
+
},
|
|
1077
|
+
}, '清除') : null,
|
|
1078
|
+
),
|
|
1079
|
+
h('p', { style: { margin: 0, fontSize: '11px', opacity: 0.65, lineHeight: 1.5 } },
|
|
1080
|
+
'Key 保存在 Harness 凭据存储(与正式 nvidia 模型路由共用 NVIDIA_API_KEY 引用),不会写入配置文件或日志;保存后下一次请求立即生效。'),
|
|
1081
|
+
noKey ? h('p', { style: { margin: 0, fontSize: '12px', lineHeight: 1.5, color: '#b8860b' } },
|
|
1082
|
+
'⚠ 未配置 Key:检测、试调用与「模型组」都不可用,请先在上方保存 Key。') : null,
|
|
1083
|
+
keyMsg ? h('p', { style: { margin: 0, fontSize: '12px', lineHeight: 1.5 } }, keyMsg) : null,
|
|
1084
|
+
),
|
|
1085
|
+
noKey ? noKeyWarning(keyHint) : null,
|
|
1086
|
+
tabBar,
|
|
1087
|
+
tab === 'models' ? h('div', {
|
|
1088
|
+
key: 'modelsPane',
|
|
1089
|
+
style: { display: 'flex', flexDirection: 'column', gap: '12px' },
|
|
1090
|
+
},
|
|
1091
|
+
[
|
|
1092
|
+
h('div', {
|
|
1093
|
+
key: 'actions',
|
|
1094
|
+
style: { display: 'flex', gap: '8px', flexWrap: 'wrap' },
|
|
1095
|
+
},
|
|
1096
|
+
h('button', {
|
|
1097
|
+
onClick: detectModels,
|
|
1098
|
+
disabled: detecting || verifying || noKey,
|
|
1099
|
+
title: noKey ? keyHint : undefined,
|
|
1100
|
+
style: {
|
|
1101
|
+
padding: '7px 14px',
|
|
1102
|
+
fontSize: '13px',
|
|
1103
|
+
fontWeight: 500,
|
|
1104
|
+
background: '#76B900',
|
|
1105
|
+
color: '#ffffff',
|
|
1106
|
+
border: 'none',
|
|
1107
|
+
borderRadius: '6px',
|
|
1108
|
+
cursor: (detecting || verifying || noKey) ? 'not-allowed' : 'pointer',
|
|
1109
|
+
opacity: (detecting || verifying || noKey) ? 0.6 : 1,
|
|
1110
|
+
},
|
|
1111
|
+
}, detecting ? '检测中…' : '检测可用模型'),
|
|
1112
|
+
h('button', {
|
|
1113
|
+
onClick: verifyAll,
|
|
1114
|
+
disabled: detecting || verifying || models.length === 0 || noKey,
|
|
1115
|
+
title: noKey ? keyHint : undefined,
|
|
1116
|
+
style: {
|
|
1117
|
+
padding: '7px 14px',
|
|
1118
|
+
fontSize: '13px',
|
|
1119
|
+
fontWeight: 500,
|
|
1120
|
+
background: verifying ? 'rgba(118,185,0,0.4)' : '#3d8400',
|
|
1121
|
+
color: '#ffffff',
|
|
1122
|
+
border: 'none',
|
|
1123
|
+
borderRadius: '6px',
|
|
1124
|
+
cursor: (detecting || verifying || models.length === 0 || noKey) ? 'not-allowed' : 'pointer',
|
|
1125
|
+
opacity: noKey ? 0.6 : 1,
|
|
1126
|
+
},
|
|
1127
|
+
}, verifying ? '试调用中…' : '逐个试调用'),
|
|
1128
|
+
verifying ? h('button', {
|
|
1129
|
+
onClick: stopVerify,
|
|
1130
|
+
style: {
|
|
1131
|
+
padding: '7px 14px',
|
|
1132
|
+
fontSize: '13px',
|
|
1133
|
+
background: 'transparent',
|
|
1134
|
+
color: 'inherit',
|
|
1135
|
+
border: '1px solid rgba(198,40,40,0.7)',
|
|
1136
|
+
color: '#c62828',
|
|
1137
|
+
borderRadius: '6px',
|
|
1138
|
+
cursor: 'pointer',
|
|
1139
|
+
},
|
|
1140
|
+
}, '停止') : null,
|
|
1141
|
+
h('button', {
|
|
1142
|
+
onClick: configureModels,
|
|
1143
|
+
disabled: configuring || detecting || verifying || noKey,
|
|
1144
|
+
title: noKey ? keyHint : undefined,
|
|
1145
|
+
style: {
|
|
1146
|
+
padding: '7px 14px',
|
|
1147
|
+
fontSize: '13px',
|
|
1148
|
+
background: 'transparent',
|
|
1149
|
+
color: 'inherit',
|
|
1150
|
+
border: '1px solid rgba(128,128,128,0.4)',
|
|
1151
|
+
borderRadius: '6px',
|
|
1152
|
+
cursor: (configuring || detecting || verifying || noKey) ? 'not-allowed' : 'pointer',
|
|
1153
|
+
opacity: (configuring || detecting || verifying || noKey) ? 0.6 : 1,
|
|
1154
|
+
},
|
|
1155
|
+
}, configuring ? '配置中…' : '一键配置到设置')
|
|
1156
|
+
),
|
|
1157
|
+
message ? h('div', {
|
|
1158
|
+
key: 'message',
|
|
1159
|
+
style: {
|
|
1160
|
+
padding: '10px 12px',
|
|
1161
|
+
background: 'rgba(118,185,0,0.12)',
|
|
1162
|
+
border: '1px solid rgba(118,185,0,0.5)',
|
|
1163
|
+
borderRadius: '6px',
|
|
1164
|
+
fontSize: '13px',
|
|
1165
|
+
lineHeight: 1.5,
|
|
1166
|
+
},
|
|
1167
|
+
}, message) : null,
|
|
1168
|
+
models.length > 0 ? h('div', {
|
|
1169
|
+
key: 'models',
|
|
1170
|
+
style: { display: 'flex', flexDirection: 'column', gap: '8px' },
|
|
1171
|
+
}, models.map(function (model) {
|
|
1172
|
+
const r = results[model.id];
|
|
1173
|
+
return h('div', {
|
|
1174
|
+
key: model.id,
|
|
1175
|
+
style: {
|
|
1176
|
+
display: 'flex',
|
|
1177
|
+
flexDirection: 'column',
|
|
1178
|
+
gap: '4px',
|
|
1179
|
+
padding: '10px 12px',
|
|
1180
|
+
background: 'rgba(128,128,128,0.06)',
|
|
1181
|
+
border: '1px solid rgba(128,128,128,0.25)',
|
|
1182
|
+
borderRadius: '6px',
|
|
1183
|
+
},
|
|
1184
|
+
},
|
|
1185
|
+
h('div', { style: { display: 'flex', alignItems: 'baseline', gap: '8px', flexWrap: 'wrap' } },
|
|
1186
|
+
h('span', { style: { fontWeight: 600, fontSize: '13px' } }, model.name),
|
|
1187
|
+
statusBadge(r),
|
|
1188
|
+
h('span', {
|
|
1189
|
+
style: { fontSize: '11px', opacity: 0.65, fontFamily: 'monospace' },
|
|
1190
|
+
title: model.id,
|
|
1191
|
+
}, model.id)
|
|
1192
|
+
),
|
|
1193
|
+
h('p', { style: { margin: 0, fontSize: '12px', opacity: 0.85, lineHeight: 1.5 } }, model.description),
|
|
1194
|
+
r && r.detail && r.status !== 'ok' && r.status !== 'testing' ? h('p', {
|
|
1195
|
+
style: { margin: 0, fontSize: '11px', color: '#c62828', lineHeight: 1.4 },
|
|
1196
|
+
}, r.detail) : null
|
|
1197
|
+
);
|
|
1198
|
+
})) : h('div', {
|
|
1199
|
+
key: 'empty',
|
|
1200
|
+
style: {
|
|
1201
|
+
flex: 1,
|
|
1202
|
+
display: 'flex',
|
|
1203
|
+
flexDirection: 'column',
|
|
1204
|
+
alignItems: 'center',
|
|
1205
|
+
justifyContent: 'center',
|
|
1206
|
+
textAlign: 'center',
|
|
1207
|
+
opacity: 0.55,
|
|
1208
|
+
gap: '8px',
|
|
1209
|
+
minHeight: '160px',
|
|
1210
|
+
},
|
|
1211
|
+
},
|
|
1212
|
+
h('svg', { viewBox: '0 0 24 24', width: 48, height: 48, fill: 'currentColor', 'aria-hidden': 'true' },
|
|
1213
|
+
h('path', { d: 'M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5' })),
|
|
1214
|
+
h('p', { style: { margin: 0, fontSize: '14px' } }, '尚未检测模型'),
|
|
1215
|
+
h('p', { style: { margin: 0, fontSize: '12px' } }, '点击「检测可用模型」获取列表,再点「逐个试调用」验证真实可用性')
|
|
1216
|
+
)
|
|
1217
|
+
]) : (tab === 'usage' ? h('div', {
|
|
1218
|
+
key: 'usagePane',
|
|
1219
|
+
style: { display: 'flex', flexDirection: 'column', gap: '12px' },
|
|
1220
|
+
}, usageCard) : h('div', {
|
|
1221
|
+
key: 'groupPane',
|
|
1222
|
+
style: { display: 'flex', flexDirection: 'column', gap: '12px' },
|
|
1223
|
+
}, groupCard)),
|
|
1224
|
+
helpModal
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
return {
|
|
1229
|
+
inject: ['slots', 'layout'],
|
|
1230
|
+
apply(ctx) {
|
|
1231
|
+
const panelId = 'nvidia-models';
|
|
1232
|
+
|
|
1233
|
+
ctx.slots.inject('sidebar.panellist', function () {
|
|
1234
|
+
return ctx.slots.register({
|
|
1235
|
+
name: 'sidebar.panellist',
|
|
1236
|
+
id: panelId,
|
|
1237
|
+
order: 100,
|
|
1238
|
+
label: 'NVIDIA 模型',
|
|
1239
|
+
}, NvidiaPanelIcon);
|
|
1240
|
+
});
|
|
1241
|
+
|
|
1242
|
+
ctx.slots.inject('main', function () {
|
|
1243
|
+
return ctx.slots.register({
|
|
1244
|
+
name: 'main',
|
|
1245
|
+
key: panelId,
|
|
1246
|
+
}, NvidiaModelsPanel);
|
|
1247
|
+
});
|
|
1248
|
+
|
|
1249
|
+
// 对话输入框上方的 dock 徽标:order 10 位于待办(0)与队列(20)之间。
|
|
1250
|
+
ctx.slots.inject('conversation.input.dock', function () {
|
|
1251
|
+
return ctx.slots.register({
|
|
1252
|
+
name: 'conversation.input.dock',
|
|
1253
|
+
id: 'nvidia-group-status',
|
|
1254
|
+
order: 10,
|
|
1255
|
+
inject: function (sessionId) { return { sessionId: sessionId }; },
|
|
1256
|
+
}, DockBadge);
|
|
1257
|
+
});
|
|
1258
|
+
},
|
|
1259
|
+
};
|
|
1260
|
+
},
|
|
1261
|
+
});
|