chatluna-plugin-kb 0.1.4 → 0.1.7
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/package.json +1 -1
- package/web/client.css +136 -128
- package/web/client.js +404 -223
package/package.json
CHANGED
package/web/client.css
CHANGED
|
@@ -829,12 +829,6 @@
|
|
|
829
829
|
font-size: 0.75rem;
|
|
830
830
|
}
|
|
831
831
|
|
|
832
|
-
.kb-engine-segmented {
|
|
833
|
-
display: flex;
|
|
834
|
-
align-items: center;
|
|
835
|
-
gap: 0.5rem;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
832
|
.kb-engine-panel {
|
|
839
833
|
display: flex;
|
|
840
834
|
min-width: 0;
|
|
@@ -846,19 +840,11 @@
|
|
|
846
840
|
background: var(--card);
|
|
847
841
|
}
|
|
848
842
|
|
|
849
|
-
.kb-engine-log-panel
|
|
850
|
-
.kb-engine-model-panel {
|
|
843
|
+
.kb-engine-log-panel {
|
|
851
844
|
height: clamp(28rem, calc(100dvh - 17rem), 48rem);
|
|
852
845
|
min-height: 24rem;
|
|
853
846
|
}
|
|
854
847
|
|
|
855
|
-
.kb-engine-model-panel {
|
|
856
|
-
display: flex;
|
|
857
|
-
min-width: 0;
|
|
858
|
-
flex-direction: column;
|
|
859
|
-
overflow: hidden;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
848
|
.kb-engine-panel-head {
|
|
863
849
|
display: flex;
|
|
864
850
|
flex-wrap: wrap;
|
|
@@ -891,9 +877,11 @@
|
|
|
891
877
|
}
|
|
892
878
|
|
|
893
879
|
.kb-log-console {
|
|
880
|
+
min-width: 0;
|
|
894
881
|
min-height: 0;
|
|
895
882
|
flex: 1;
|
|
896
|
-
overflow: auto;
|
|
883
|
+
overflow-y: auto;
|
|
884
|
+
overflow-x: hidden;
|
|
897
885
|
overscroll-behavior: contain;
|
|
898
886
|
background: color-mix(in srgb, var(--muted) 45%, var(--card));
|
|
899
887
|
padding: 0.5rem 0.75rem;
|
|
@@ -944,156 +932,184 @@
|
|
|
944
932
|
color: var(--muted-foreground);
|
|
945
933
|
}
|
|
946
934
|
|
|
947
|
-
/*
|
|
948
|
-
.kb-
|
|
935
|
+
/* ---- 模型复制 Dialog --------------------------------------------------- */
|
|
936
|
+
div.kb-model-copy-dialog {
|
|
949
937
|
display: flex;
|
|
950
|
-
min-
|
|
951
|
-
|
|
938
|
+
width: min(56rem, calc(100vw - 2rem));
|
|
939
|
+
max-width: 56rem;
|
|
940
|
+
height: min(82dvh, 46rem);
|
|
941
|
+
max-height: calc(100dvh - 2rem);
|
|
952
942
|
flex-direction: column;
|
|
953
|
-
gap: 0
|
|
954
|
-
padding: 0
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
.kb-model-workbench-card {
|
|
958
|
-
min-height: 0;
|
|
959
|
-
flex: 1;
|
|
943
|
+
gap: 0;
|
|
944
|
+
padding: 0;
|
|
945
|
+
overflow: hidden;
|
|
960
946
|
}
|
|
961
947
|
|
|
962
|
-
.kb-model-
|
|
948
|
+
div.kb-model-copy-dialog > .kb-model-workbench {
|
|
963
949
|
display: flex;
|
|
964
950
|
min-height: 0;
|
|
965
951
|
flex: 1;
|
|
966
952
|
flex-direction: column;
|
|
967
953
|
}
|
|
968
954
|
|
|
969
|
-
.kb-model-workbench-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
955
|
+
.kb-model-workbench-header {
|
|
956
|
+
flex-shrink: 0;
|
|
957
|
+
border-bottom: 1px solid var(--border);
|
|
958
|
+
padding: 1.25rem 3rem 0.875rem 1.25rem;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
.kb-model-workbench-title {
|
|
962
|
+
margin: 0;
|
|
963
|
+
font-size: 1rem;
|
|
964
|
+
font-weight: 600;
|
|
965
|
+
line-height: 1.4;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
.kb-model-workbench-subtitle {
|
|
969
|
+
margin: 0.25rem 0 0;
|
|
970
|
+
color: var(--muted-foreground);
|
|
971
|
+
font-size: 0.8125rem;
|
|
974
972
|
}
|
|
975
973
|
|
|
976
974
|
.kb-model-workbench .kb-model-toolbar {
|
|
977
975
|
flex-shrink: 0;
|
|
976
|
+
border-bottom: 1px solid var(--border);
|
|
977
|
+
padding: 0.75rem 1.25rem;
|
|
978
978
|
}
|
|
979
979
|
|
|
980
980
|
.kb-model-workbench .kb-model-scroll {
|
|
981
981
|
min-height: 0;
|
|
982
982
|
max-height: none;
|
|
983
983
|
flex: 1;
|
|
984
|
+
overflow-x: hidden;
|
|
985
|
+
overflow-y: auto;
|
|
986
|
+
padding: 0.875rem 1.25rem 1rem;
|
|
984
987
|
}
|
|
985
988
|
|
|
986
|
-
.kb-model-workbench .kb-model-
|
|
987
|
-
margin-top: auto;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
.kb-model-actionbar-sticky {
|
|
989
|
+
.kb-model-workbench .kb-model-group-head {
|
|
991
990
|
position: sticky;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
padding-top: 0.5rem;
|
|
991
|
+
top: 0;
|
|
992
|
+
z-index: 1;
|
|
993
|
+
background: var(--popover);
|
|
994
|
+
padding-block: 0.25rem;
|
|
997
995
|
}
|
|
998
996
|
|
|
999
|
-
.kb-model-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
997
|
+
.kb-model-workbench .kb-model-list {
|
|
998
|
+
display: grid;
|
|
999
|
+
grid-template-columns: minmax(0, 1fr);
|
|
1000
|
+
gap: 0.5rem;
|
|
1003
1001
|
}
|
|
1004
1002
|
|
|
1005
|
-
@media (
|
|
1006
|
-
.kb-
|
|
1007
|
-
|
|
1003
|
+
@media (min-width: 42rem) {
|
|
1004
|
+
.kb-model-workbench .kb-model-list {
|
|
1005
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
1008
1006
|
}
|
|
1007
|
+
}
|
|
1009
1008
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1009
|
+
.kb-model-workbench .kb-model-item {
|
|
1010
|
+
min-width: 0;
|
|
1013
1011
|
}
|
|
1014
1012
|
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
'rail stack';
|
|
1023
|
-
align-items: start;
|
|
1024
|
-
}
|
|
1013
|
+
.kb-model-model-id {
|
|
1014
|
+
overflow: hidden;
|
|
1015
|
+
min-width: 0;
|
|
1016
|
+
font-weight: 500;
|
|
1017
|
+
text-overflow: ellipsis;
|
|
1018
|
+
white-space: nowrap;
|
|
1019
|
+
}
|
|
1025
1020
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1021
|
+
.kb-model-result {
|
|
1022
|
+
flex-shrink: 0;
|
|
1023
|
+
padding: 0 1.25rem 0.5rem;
|
|
1024
|
+
}
|
|
1029
1025
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1026
|
+
.kb-model-dialog-footer {
|
|
1027
|
+
display: flex;
|
|
1028
|
+
flex-shrink: 0;
|
|
1029
|
+
flex-wrap: wrap;
|
|
1030
|
+
align-items: center;
|
|
1031
|
+
justify-content: space-between;
|
|
1032
|
+
gap: 0.75rem;
|
|
1033
|
+
border-top: 1px solid var(--border);
|
|
1034
|
+
padding: 0.75rem 1.25rem;
|
|
1035
|
+
}
|
|
1038
1036
|
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1037
|
+
.kb-model-selection {
|
|
1038
|
+
display: flex;
|
|
1039
|
+
min-width: 0;
|
|
1040
|
+
flex: 1 1 18rem;
|
|
1041
|
+
flex-wrap: wrap;
|
|
1042
|
+
align-items: center;
|
|
1043
|
+
gap: 0.5rem;
|
|
1044
|
+
}
|
|
1042
1045
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
}
|
|
1046
|
+
.kb-model-selection-empty {
|
|
1047
|
+
color: var(--muted-foreground);
|
|
1048
|
+
font-size: 0.75rem;
|
|
1047
1049
|
}
|
|
1048
1050
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
}
|
|
1051
|
+
.kb-model-selection-text {
|
|
1052
|
+
overflow: hidden;
|
|
1053
|
+
min-width: 0;
|
|
1054
|
+
color: var(--muted-foreground);
|
|
1055
|
+
font-size: 0.75rem;
|
|
1056
|
+
text-overflow: ellipsis;
|
|
1057
|
+
white-space: nowrap;
|
|
1058
|
+
}
|
|
1058
1059
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1060
|
+
.kb-model-selection > .kb-model-selection-text {
|
|
1061
|
+
max-width: 100%;
|
|
1062
|
+
flex: 0 1 auto;
|
|
1063
|
+
}
|
|
1062
1064
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
grid-template-columns: minmax(0, 1fr);
|
|
1070
|
-
}
|
|
1065
|
+
.kb-model-role {
|
|
1066
|
+
width: auto;
|
|
1067
|
+
max-width: 14rem;
|
|
1068
|
+
min-width: 0;
|
|
1069
|
+
flex: 0 0 auto;
|
|
1070
|
+
}
|
|
1071
1071
|
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1072
|
+
.kb-model-role [data-slot='select'],
|
|
1073
|
+
.kb-model-role [data-slot='select-trigger'] {
|
|
1074
|
+
width: 100%;
|
|
1075
|
+
max-width: 14rem;
|
|
1076
|
+
}
|
|
1075
1077
|
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1078
|
+
.kb-model-role [data-slot='select-trigger'] {
|
|
1079
|
+
min-width: 0;
|
|
1080
|
+
}
|
|
1079
1081
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1082
|
+
.kb-model-selection-name {
|
|
1083
|
+
color: var(--foreground);
|
|
1084
|
+
font-weight: 600;
|
|
1083
1085
|
}
|
|
1084
1086
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
grid-template-columns: minmax(0, 1fr);
|
|
1088
|
-
}
|
|
1087
|
+
.kb-model-selection-provider {
|
|
1088
|
+
color: var(--muted-foreground);
|
|
1089
1089
|
}
|
|
1090
1090
|
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1091
|
+
.kb-model-footer-actions {
|
|
1092
|
+
display: flex;
|
|
1093
|
+
flex-shrink: 0;
|
|
1094
|
+
gap: 0.5rem;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
.kb-model-top-actions {
|
|
1098
|
+
display: flex;
|
|
1099
|
+
min-width: 0;
|
|
1100
|
+
flex-wrap: wrap;
|
|
1101
|
+
align-items: center;
|
|
1102
|
+
justify-content: flex-end;
|
|
1103
|
+
gap: 0.375rem;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
.kb-model-selected {
|
|
1107
|
+
overflow: hidden;
|
|
1108
|
+
max-width: 18rem;
|
|
1109
|
+
color: var(--muted-foreground);
|
|
1110
|
+
font-size: 0.75rem;
|
|
1111
|
+
text-overflow: ellipsis;
|
|
1112
|
+
white-space: nowrap;
|
|
1097
1113
|
}
|
|
1098
1114
|
|
|
1099
1115
|
/* ---- 模型复制 --------------------------------------------------------- */
|
|
@@ -1214,14 +1230,6 @@
|
|
|
1214
1230
|
color: var(--primary);
|
|
1215
1231
|
}
|
|
1216
1232
|
|
|
1217
|
-
.kb-model-footer {
|
|
1218
|
-
display: flex;
|
|
1219
|
-
flex-wrap: wrap;
|
|
1220
|
-
align-items: center;
|
|
1221
|
-
justify-content: flex-end;
|
|
1222
|
-
gap: 0.5rem;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
1233
|
/* ---- 安装向导 --------------------------------------------------------- */
|
|
1226
1234
|
.kb-wizard {
|
|
1227
1235
|
display: flex;
|
package/web/client.js
CHANGED
|
@@ -1240,6 +1240,14 @@ const providerGroupOf = (item) => {
|
|
|
1240
1240
|
return id === '' ? '—' : id
|
|
1241
1241
|
}
|
|
1242
1242
|
|
|
1243
|
+
/** 分组展示名:去掉 chatluna 内部前缀与 8+ 位实例后缀;原值仍用于 key/title。 */
|
|
1244
|
+
export function modelProviderLabel(value) {
|
|
1245
|
+
const raw = typeof value === 'string' ? value.trim() : ''
|
|
1246
|
+
if (raw === '') return '—'
|
|
1247
|
+
const stripped = raw.replace(/^chatluna-provider-/i, '').replace(/-[a-z0-9]{8,}$/i, '')
|
|
1248
|
+
return stripped === '' ? raw : stripped
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1243
1251
|
/**
|
|
1244
1252
|
* 模型复制列表的搜索/类型筛选/厂商分组(纯函数,SSR 与单测共用)。
|
|
1245
1253
|
* - 类型计数与 chips 基于完整目录,只展示有模型的类型;
|
|
@@ -1292,7 +1300,7 @@ export function modelCopyReport(models, options = {}) {
|
|
|
1292
1300
|
const visible = items.slice(0, limit)
|
|
1293
1301
|
groups.push({
|
|
1294
1302
|
key,
|
|
1295
|
-
label: key,
|
|
1303
|
+
label: modelProviderLabel(key),
|
|
1296
1304
|
items: visible,
|
|
1297
1305
|
total: items.length,
|
|
1298
1306
|
hidden: items.length - visible.length,
|
|
@@ -1342,13 +1350,312 @@ export function modelCopyView(m = {}) {
|
|
|
1342
1350
|
const activeImportRole = selectedRoles.includes(m.importRole) ? m.importRole : selected?.type
|
|
1343
1351
|
const result = m.result !== null && typeof m.result === 'object' ? m.result : null
|
|
1344
1352
|
const workbench = m.layout === 'workbench'
|
|
1345
|
-
// 工作台形态常驻展开,不再有折叠交互。
|
|
1346
1353
|
const open = workbench ? true : m.open === true
|
|
1347
1354
|
const state = typeof m.state === 'string' ? m.state : 'idle'
|
|
1348
|
-
const loadLabel = state === 'loading' ? '
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1351
|
-
|
|
1355
|
+
const loadLabel = state === 'loading' ? '刷新中…' : '刷新'
|
|
1356
|
+
const fullLabel = (item) =>
|
|
1357
|
+
`${item.providerLabel || item.providerId || '—'} · ${item.modelId || '—'}`
|
|
1358
|
+
const roleLabel = (role) => (role === 'vlm' ? '仅作为视觉模型' : '对话模型(含视觉)')
|
|
1359
|
+
|
|
1360
|
+
const roleSelect = (withId) =>
|
|
1361
|
+
h(
|
|
1362
|
+
Select,
|
|
1363
|
+
{
|
|
1364
|
+
value: activeImportRole,
|
|
1365
|
+
disabled: m.importing === true,
|
|
1366
|
+
onValueChange: (next) =>
|
|
1367
|
+
typeof m.onImportRole === 'function' ? m.onImportRole(String(next)) : undefined
|
|
1368
|
+
},
|
|
1369
|
+
h(
|
|
1370
|
+
SelectTrigger,
|
|
1371
|
+
{ id: withId ? 'kb-model-import-role' : undefined, className: 'kb-rule-select', 'aria-label': '导入为' },
|
|
1372
|
+
h(SelectValue, null, roleLabel(activeImportRole))
|
|
1373
|
+
),
|
|
1374
|
+
h(
|
|
1375
|
+
SelectContent,
|
|
1376
|
+
null,
|
|
1377
|
+
selectedRoles.map((role) =>
|
|
1378
|
+
h(SelectItem, { key: role, value: role }, roleLabel(role))
|
|
1379
|
+
)
|
|
1380
|
+
)
|
|
1381
|
+
)
|
|
1382
|
+
|
|
1383
|
+
const importButton = () =>
|
|
1384
|
+
h(
|
|
1385
|
+
Button,
|
|
1386
|
+
{
|
|
1387
|
+
size: 'sm',
|
|
1388
|
+
disabled: selected === null || m.importing === true || typeof m.onCopy !== 'function',
|
|
1389
|
+
onClick: selected !== null && typeof m.onCopy === 'function' ? m.onCopy : undefined
|
|
1390
|
+
},
|
|
1391
|
+
m.importing === true ? '复制中…' : '复制到知识库'
|
|
1392
|
+
)
|
|
1393
|
+
|
|
1394
|
+
const resultAlert = () => {
|
|
1395
|
+
if (!m.copyError && result === null) return null
|
|
1396
|
+
return h(
|
|
1397
|
+
'div',
|
|
1398
|
+
{ className: 'kb-model-result' },
|
|
1399
|
+
m.copyError ? errorAlert(m.copyError, '复制失败') : null,
|
|
1400
|
+
result !== null
|
|
1401
|
+
? h(
|
|
1402
|
+
Alert,
|
|
1403
|
+
{ className: 'kb-alert-success' },
|
|
1404
|
+
h(UiIcon, { name: 'check' }),
|
|
1405
|
+
h(AlertTitle, null, '已复制到知识库'),
|
|
1406
|
+
h(
|
|
1407
|
+
AlertDescription,
|
|
1408
|
+
null,
|
|
1409
|
+
`模型 id ${result.modelId ?? '—'}${result.dimension ? ` · 维度 ${result.dimension}` : ''}`
|
|
1410
|
+
)
|
|
1411
|
+
)
|
|
1412
|
+
: null
|
|
1413
|
+
)
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
if (workbench) {
|
|
1417
|
+
const workbenchItem = (item) => {
|
|
1418
|
+
const key = modelSelectionKey(item)
|
|
1419
|
+
const active = key === selectedKey
|
|
1420
|
+
return h(
|
|
1421
|
+
'button',
|
|
1422
|
+
{
|
|
1423
|
+
type: 'button',
|
|
1424
|
+
key,
|
|
1425
|
+
className: 'kb-model-item',
|
|
1426
|
+
title: fullLabel(item),
|
|
1427
|
+
'aria-pressed': active,
|
|
1428
|
+
onClick: typeof m.onSelect === 'function' ? () => m.onSelect(key) : undefined
|
|
1429
|
+
},
|
|
1430
|
+
h(
|
|
1431
|
+
'span',
|
|
1432
|
+
{ className: 'kb-model-main' },
|
|
1433
|
+
h(
|
|
1434
|
+
'span',
|
|
1435
|
+
{ className: 'kb-model-title' },
|
|
1436
|
+
h('span', { className: 'kb-model-model-id' }, item.modelId || '—'),
|
|
1437
|
+
h(Badge, { variant: item.type === 'embedding' ? 'secondary' : 'outline' }, modelRoleLabel(item.type)),
|
|
1438
|
+
item.supportsVision === true ? h(Badge, { variant: 'secondary' }, '支持视觉') : null,
|
|
1439
|
+
item.protocolHint ? h(Badge, { variant: 'outline' }, '原生协议') : null
|
|
1440
|
+
),
|
|
1441
|
+
h(
|
|
1442
|
+
'span',
|
|
1443
|
+
{ className: 'kb-model-url', title: item.baseUrl || '' },
|
|
1444
|
+
shortenUrl(item.baseUrl)
|
|
1445
|
+
),
|
|
1446
|
+
item.protocolHint
|
|
1447
|
+
? h(
|
|
1448
|
+
'span',
|
|
1449
|
+
{ className: 'kb-muted-text' },
|
|
1450
|
+
'该路由使用非 OpenAI 原生协议,复制后可能需要在知识库设置中调整接口类型。'
|
|
1451
|
+
)
|
|
1452
|
+
: null
|
|
1453
|
+
),
|
|
1454
|
+
active
|
|
1455
|
+
? h('span', { className: 'kb-model-check', 'aria-hidden': true }, h(UiIcon, { name: 'check' }))
|
|
1456
|
+
: null
|
|
1457
|
+
)
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
let body
|
|
1461
|
+
if (state === 'loading') {
|
|
1462
|
+
body = h(
|
|
1463
|
+
'div',
|
|
1464
|
+
{ className: 'kb-model-scroll' },
|
|
1465
|
+
h(Skeleton, { className: 'kb-skeleton-row' }),
|
|
1466
|
+
h(Skeleton, { className: 'kb-skeleton-row' })
|
|
1467
|
+
)
|
|
1468
|
+
} else if (state === 'error' && typeof m.error === 'string' && m.error !== '') {
|
|
1469
|
+
body = h('div', { className: 'kb-model-scroll' }, errorAlert(m.error, '读取模型列表失败'))
|
|
1470
|
+
} else if (state === 'idle') {
|
|
1471
|
+
body = h('div', { className: 'kb-model-scroll' }, h('p', { className: 'kb-muted-text' }, '点击刷新加载模型列表。'))
|
|
1472
|
+
} else if (models.length === 0) {
|
|
1473
|
+
body = h(
|
|
1474
|
+
'div',
|
|
1475
|
+
{ className: 'kb-model-scroll' },
|
|
1476
|
+
h('p', { className: 'kb-muted-text' }, 'ChatLuna 暂无可用于复制的知识库模型。')
|
|
1477
|
+
)
|
|
1478
|
+
} else if (report.groups.length === 0) {
|
|
1479
|
+
body = h(
|
|
1480
|
+
'div',
|
|
1481
|
+
{ className: 'kb-model-scroll' },
|
|
1482
|
+
h('p', { className: 'kb-muted-text' }, '没有匹配的模型;调整搜索关键词或类型筛选。')
|
|
1483
|
+
)
|
|
1484
|
+
} else {
|
|
1485
|
+
body = h(
|
|
1486
|
+
'div',
|
|
1487
|
+
{ className: 'kb-model-scroll' },
|
|
1488
|
+
report.groups.map((group) =>
|
|
1489
|
+
h(
|
|
1490
|
+
'div',
|
|
1491
|
+
{ key: group.key, className: 'kb-model-group' },
|
|
1492
|
+
h(
|
|
1493
|
+
'div',
|
|
1494
|
+
{ className: 'kb-model-group-head' },
|
|
1495
|
+
h('p', { className: 'kb-model-group-title' }, group.label),
|
|
1496
|
+
h(Badge, { variant: 'outline' }, String(group.total))
|
|
1497
|
+
),
|
|
1498
|
+
h('div', { className: 'kb-model-list' }, group.items.map(workbenchItem)),
|
|
1499
|
+
group.hidden > 0
|
|
1500
|
+
? h(
|
|
1501
|
+
Button,
|
|
1502
|
+
{
|
|
1503
|
+
variant: 'ghost',
|
|
1504
|
+
size: 'sm',
|
|
1505
|
+
className: 'kb-model-more',
|
|
1506
|
+
onClick: () =>
|
|
1507
|
+
typeof m.onToggleGroup === 'function' ? m.onToggleGroup(group.key) : undefined
|
|
1508
|
+
},
|
|
1509
|
+
`显示更多 ${group.hidden}`
|
|
1510
|
+
)
|
|
1511
|
+
: null,
|
|
1512
|
+
group.expanded && group.total > MODEL_GROUP_LIMIT
|
|
1513
|
+
? h(
|
|
1514
|
+
Button,
|
|
1515
|
+
{
|
|
1516
|
+
variant: 'ghost',
|
|
1517
|
+
size: 'sm',
|
|
1518
|
+
className: 'kb-model-more',
|
|
1519
|
+
onClick: () =>
|
|
1520
|
+
typeof m.onToggleGroup === 'function' ? m.onToggleGroup(group.key) : undefined
|
|
1521
|
+
},
|
|
1522
|
+
'收起'
|
|
1523
|
+
)
|
|
1524
|
+
: null
|
|
1525
|
+
)
|
|
1526
|
+
)
|
|
1527
|
+
)
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
return h(
|
|
1531
|
+
'div',
|
|
1532
|
+
{ className: 'kb-model-workbench' },
|
|
1533
|
+
h(
|
|
1534
|
+
'div',
|
|
1535
|
+
{ className: 'kb-model-workbench-header' },
|
|
1536
|
+
h(DialogTitle, { className: 'kb-model-workbench-title' }, '从 ChatLuna 复制模型'),
|
|
1537
|
+
h(
|
|
1538
|
+
DialogDescription,
|
|
1539
|
+
{ className: 'kb-model-workbench-subtitle' },
|
|
1540
|
+
'选择已配置的模型复制到知识库;仅同步元数据,不会暴露 API Key。'
|
|
1541
|
+
)
|
|
1542
|
+
),
|
|
1543
|
+
h(
|
|
1544
|
+
'div',
|
|
1545
|
+
{ className: 'kb-model-toolbar' },
|
|
1546
|
+
h(SearchBox, {
|
|
1547
|
+
value: query,
|
|
1548
|
+
onChange: (value) => (typeof m.onQueryChange === 'function' ? m.onQueryChange(value) : undefined),
|
|
1549
|
+
placeholder: '搜索厂商、模型或地址…',
|
|
1550
|
+
clearLabel: '清除搜索'
|
|
1551
|
+
}),
|
|
1552
|
+
h(FilterChips, {
|
|
1553
|
+
options: report.typeOptions,
|
|
1554
|
+
value: report.activeType,
|
|
1555
|
+
onChange: (value) => (typeof m.onTypeChange === 'function' ? m.onTypeChange(value) : undefined),
|
|
1556
|
+
label: '按模型类型筛选'
|
|
1557
|
+
}),
|
|
1558
|
+
h(
|
|
1559
|
+
Button,
|
|
1560
|
+
{
|
|
1561
|
+
variant: 'outline',
|
|
1562
|
+
size: 'sm',
|
|
1563
|
+
disabled: state === 'loading' || typeof m.onLoad !== 'function',
|
|
1564
|
+
onClick: typeof m.onLoad === 'function' ? m.onLoad : undefined
|
|
1565
|
+
},
|
|
1566
|
+
loadLabel
|
|
1567
|
+
)
|
|
1568
|
+
),
|
|
1569
|
+
body,
|
|
1570
|
+
resultAlert(),
|
|
1571
|
+
h(
|
|
1572
|
+
DialogFooter,
|
|
1573
|
+
{ className: 'kb-model-dialog-footer' },
|
|
1574
|
+
h(
|
|
1575
|
+
'div',
|
|
1576
|
+
{ className: 'kb-model-selection' },
|
|
1577
|
+
selected === null
|
|
1578
|
+
? h('span', { className: 'kb-model-selection-empty' }, '请选择一个要复制的模型')
|
|
1579
|
+
: h(
|
|
1580
|
+
'span',
|
|
1581
|
+
{ className: 'kb-model-selection-text' },
|
|
1582
|
+
'已选:',
|
|
1583
|
+
h('strong', { className: 'kb-model-selection-name' }, selected.modelId || '—'),
|
|
1584
|
+
h(
|
|
1585
|
+
'span',
|
|
1586
|
+
{ className: 'kb-model-selection-provider' },
|
|
1587
|
+
` · ${selected.providerLabel || selected.providerId || '—'}`
|
|
1588
|
+
)
|
|
1589
|
+
),
|
|
1590
|
+
selected !== null && selectedRoles.length > 1
|
|
1591
|
+
? h('div', { className: 'kb-model-role' }, roleSelect(true))
|
|
1592
|
+
: null
|
|
1593
|
+
),
|
|
1594
|
+
h(
|
|
1595
|
+
'div',
|
|
1596
|
+
{ className: 'kb-model-footer-actions' },
|
|
1597
|
+
h(
|
|
1598
|
+
Button,
|
|
1599
|
+
{
|
|
1600
|
+
variant: 'outline',
|
|
1601
|
+
size: 'sm',
|
|
1602
|
+
onClick: typeof m.onClose === 'function' ? m.onClose : undefined
|
|
1603
|
+
},
|
|
1604
|
+
'取消'
|
|
1605
|
+
),
|
|
1606
|
+
importButton()
|
|
1607
|
+
)
|
|
1608
|
+
)
|
|
1609
|
+
)
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
const cardItem = (item) => {
|
|
1613
|
+
const key = modelSelectionKey(item)
|
|
1614
|
+
const active = key === selectedKey
|
|
1615
|
+
return h(
|
|
1616
|
+
'li',
|
|
1617
|
+
{ key },
|
|
1618
|
+
h(
|
|
1619
|
+
'button',
|
|
1620
|
+
{
|
|
1621
|
+
type: 'button',
|
|
1622
|
+
className: 'kb-model-item',
|
|
1623
|
+
'aria-pressed': active,
|
|
1624
|
+
onClick: typeof m.onSelect === 'function' ? () => m.onSelect(key) : undefined
|
|
1625
|
+
},
|
|
1626
|
+
h(
|
|
1627
|
+
'span',
|
|
1628
|
+
{ className: 'kb-model-main' },
|
|
1629
|
+
h(
|
|
1630
|
+
'span',
|
|
1631
|
+
{ className: 'kb-model-title' },
|
|
1632
|
+
fullLabel(item),
|
|
1633
|
+
h(Badge, { variant: item.type === 'embedding' ? 'secondary' : 'outline' }, modelRoleLabel(item.type)),
|
|
1634
|
+
item.supportsVision === true ? h(Badge, { variant: 'secondary' }, '支持视觉') : null,
|
|
1635
|
+
item.protocolHint ? h(Badge, { variant: 'outline' }, '原生协议') : null
|
|
1636
|
+
),
|
|
1637
|
+
h('span', { className: 'kb-model-url', title: item.baseUrl || '' }, shortenUrl(item.baseUrl)),
|
|
1638
|
+
item.protocolHint
|
|
1639
|
+
? h(
|
|
1640
|
+
'span',
|
|
1641
|
+
{ className: 'kb-muted-text' },
|
|
1642
|
+
'该路由使用非 OpenAI 原生协议,复制后可能需要在知识库设置中调整接口类型。'
|
|
1643
|
+
)
|
|
1644
|
+
: null
|
|
1645
|
+
),
|
|
1646
|
+
active
|
|
1647
|
+
? h('span', { className: 'kb-model-check', 'aria-hidden': true }, h(UiIcon, { name: 'check' }))
|
|
1648
|
+
: null
|
|
1649
|
+
)
|
|
1650
|
+
)
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
return h(
|
|
1654
|
+
Section,
|
|
1655
|
+
{ title: '模型配置' },
|
|
1656
|
+
h(
|
|
1657
|
+
Card,
|
|
1658
|
+
{ size: 'sm' },
|
|
1352
1659
|
h(
|
|
1353
1660
|
CardHeader,
|
|
1354
1661
|
null,
|
|
@@ -1359,7 +1666,19 @@ export function modelCopyView(m = {}) {
|
|
|
1359
1666
|
null,
|
|
1360
1667
|
h(
|
|
1361
1668
|
'div',
|
|
1362
|
-
{ className: 'kb-
|
|
1669
|
+
{ className: 'kb-model-top-actions' },
|
|
1670
|
+
open && selected !== null
|
|
1671
|
+
? h(
|
|
1672
|
+
'span',
|
|
1673
|
+
{
|
|
1674
|
+
className: 'kb-model-selected',
|
|
1675
|
+
title: fullLabel(selected)
|
|
1676
|
+
},
|
|
1677
|
+
`已选:${selected.modelId || '—'} · ${selected.providerLabel || selected.providerId || '—'}`
|
|
1678
|
+
)
|
|
1679
|
+
: null,
|
|
1680
|
+
open && selectedRoles.length > 1 ? roleSelect(true) : null,
|
|
1681
|
+
open ? importButton() : null,
|
|
1363
1682
|
open
|
|
1364
1683
|
? h(
|
|
1365
1684
|
Button,
|
|
@@ -1372,27 +1691,27 @@ export function modelCopyView(m = {}) {
|
|
|
1372
1691
|
loadLabel
|
|
1373
1692
|
)
|
|
1374
1693
|
: null,
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
)
|
|
1694
|
+
h(
|
|
1695
|
+
Button,
|
|
1696
|
+
{
|
|
1697
|
+
variant: 'ghost',
|
|
1698
|
+
size: 'sm',
|
|
1699
|
+
'aria-expanded': open,
|
|
1700
|
+
onClick: typeof m.onToggle === 'function' ? m.onToggle : undefined
|
|
1701
|
+
},
|
|
1702
|
+
open ? '收起' : '展开'
|
|
1703
|
+
)
|
|
1386
1704
|
)
|
|
1387
1705
|
)
|
|
1388
1706
|
),
|
|
1389
1707
|
open
|
|
1390
1708
|
? h(
|
|
1391
1709
|
CardContent,
|
|
1392
|
-
|
|
1710
|
+
null,
|
|
1393
1711
|
h(
|
|
1394
1712
|
'div',
|
|
1395
1713
|
{ className: 'kb-card-stack' },
|
|
1714
|
+
resultAlert(),
|
|
1396
1715
|
state === 'loading' ? h(Skeleton, { className: 'kb-skeleton-row' }) : null,
|
|
1397
1716
|
state === 'loading' ? h(Skeleton, { className: 'kb-skeleton-row' }) : null,
|
|
1398
1717
|
state === 'error' && typeof m.error === 'string' && m.error !== ''
|
|
@@ -1412,7 +1731,7 @@ export function modelCopyView(m = {}) {
|
|
|
1412
1731
|
value: query,
|
|
1413
1732
|
onChange: (value) =>
|
|
1414
1733
|
typeof m.onQueryChange === 'function' ? m.onQueryChange(value) : undefined,
|
|
1415
|
-
placeholder: '
|
|
1734
|
+
placeholder: '搜索厂商、模型或地址…',
|
|
1416
1735
|
clearLabel: '清除搜索'
|
|
1417
1736
|
}),
|
|
1418
1737
|
h(FilterChips, {
|
|
@@ -1441,61 +1760,7 @@ export function modelCopyView(m = {}) {
|
|
|
1441
1760
|
h('p', { className: 'kb-model-group-title' }, group.label),
|
|
1442
1761
|
h(Badge, { variant: 'outline' }, String(group.total))
|
|
1443
1762
|
),
|
|
1444
|
-
h(
|
|
1445
|
-
'ul',
|
|
1446
|
-
{ className: 'kb-model-list' },
|
|
1447
|
-
group.items.map((item) => {
|
|
1448
|
-
const key = modelSelectionKey(item)
|
|
1449
|
-
const active = key === selectedKey
|
|
1450
|
-
const role = modelRoleLabel(item.type)
|
|
1451
|
-
return h(
|
|
1452
|
-
'li',
|
|
1453
|
-
{ key },
|
|
1454
|
-
h(
|
|
1455
|
-
'button',
|
|
1456
|
-
{
|
|
1457
|
-
type: 'button',
|
|
1458
|
-
className: 'kb-model-item',
|
|
1459
|
-
'aria-pressed': active,
|
|
1460
|
-
onClick: typeof m.onSelect === 'function' ? () => m.onSelect(key) : undefined
|
|
1461
|
-
},
|
|
1462
|
-
h(
|
|
1463
|
-
'span',
|
|
1464
|
-
{ className: 'kb-model-main' },
|
|
1465
|
-
h(
|
|
1466
|
-
'span',
|
|
1467
|
-
{ className: 'kb-model-title' },
|
|
1468
|
-
`${item.providerLabel || item.providerId || '—'} · ${item.modelId || '—'}`,
|
|
1469
|
-
h(Badge, { variant: item.type === 'embedding' ? 'secondary' : 'outline' }, role),
|
|
1470
|
-
item.supportsVision === true
|
|
1471
|
-
? h(Badge, { variant: 'secondary' }, '支持视觉')
|
|
1472
|
-
: null,
|
|
1473
|
-
item.protocolHint ? h(Badge, { variant: 'outline' }, '原生协议') : null
|
|
1474
|
-
),
|
|
1475
|
-
h(
|
|
1476
|
-
'span',
|
|
1477
|
-
{ className: 'kb-model-url', title: item.baseUrl || '' },
|
|
1478
|
-
shortenUrl(item.baseUrl)
|
|
1479
|
-
),
|
|
1480
|
-
item.protocolHint
|
|
1481
|
-
? h(
|
|
1482
|
-
'span',
|
|
1483
|
-
{ className: 'kb-muted-text' },
|
|
1484
|
-
'该路由使用非 OpenAI 原生协议,复制后可能需要在 WeKnora 中调整接口类型。'
|
|
1485
|
-
)
|
|
1486
|
-
: null
|
|
1487
|
-
),
|
|
1488
|
-
active
|
|
1489
|
-
? h(
|
|
1490
|
-
'span',
|
|
1491
|
-
{ className: 'kb-model-check', 'aria-hidden': true },
|
|
1492
|
-
h(UiIcon, { name: 'check' })
|
|
1493
|
-
)
|
|
1494
|
-
: null
|
|
1495
|
-
)
|
|
1496
|
-
)
|
|
1497
|
-
})
|
|
1498
|
-
),
|
|
1763
|
+
h('ul', { className: 'kb-model-list' }, group.items.map(cardItem)),
|
|
1499
1764
|
group.hidden > 0
|
|
1500
1765
|
? h(
|
|
1501
1766
|
Button,
|
|
@@ -1504,9 +1769,7 @@ export function modelCopyView(m = {}) {
|
|
|
1504
1769
|
size: 'sm',
|
|
1505
1770
|
className: 'kb-model-more',
|
|
1506
1771
|
onClick: () =>
|
|
1507
|
-
typeof m.onToggleGroup === 'function'
|
|
1508
|
-
? m.onToggleGroup(group.key)
|
|
1509
|
-
: undefined
|
|
1772
|
+
typeof m.onToggleGroup === 'function' ? m.onToggleGroup(group.key) : undefined
|
|
1510
1773
|
},
|
|
1511
1774
|
`显示更多 ${group.hidden}`
|
|
1512
1775
|
)
|
|
@@ -1519,9 +1782,7 @@ export function modelCopyView(m = {}) {
|
|
|
1519
1782
|
size: 'sm',
|
|
1520
1783
|
className: 'kb-model-more',
|
|
1521
1784
|
onClick: () =>
|
|
1522
|
-
typeof m.onToggleGroup === 'function'
|
|
1523
|
-
? m.onToggleGroup(group.key)
|
|
1524
|
-
: undefined
|
|
1785
|
+
typeof m.onToggleGroup === 'function' ? m.onToggleGroup(group.key) : undefined
|
|
1525
1786
|
},
|
|
1526
1787
|
'收起'
|
|
1527
1788
|
)
|
|
@@ -1529,91 +1790,15 @@ export function modelCopyView(m = {}) {
|
|
|
1529
1790
|
)
|
|
1530
1791
|
)
|
|
1531
1792
|
)
|
|
1532
|
-
: null
|
|
1533
|
-
h(
|
|
1534
|
-
'div',
|
|
1535
|
-
{
|
|
1536
|
-
className: workbench
|
|
1537
|
-
? 'kb-model-actionbar kb-model-actionbar-sticky'
|
|
1538
|
-
: 'kb-model-actionbar'
|
|
1539
|
-
},
|
|
1540
|
-
m.copyError ? errorAlert(m.copyError, '复制失败') : null,
|
|
1541
|
-
result !== null
|
|
1542
|
-
? h(
|
|
1543
|
-
Alert,
|
|
1544
|
-
{ className: 'kb-alert-success' },
|
|
1545
|
-
h(UiIcon, { name: 'check' }),
|
|
1546
|
-
h(AlertTitle, null, '已复制到 WeKnora'),
|
|
1547
|
-
h(
|
|
1548
|
-
AlertDescription,
|
|
1549
|
-
null,
|
|
1550
|
-
`模型 id ${result.modelId ?? '—'}${result.dimension ? ` · 维度 ${result.dimension}` : ''}`
|
|
1551
|
-
)
|
|
1552
|
-
)
|
|
1553
|
-
: null,
|
|
1554
|
-
selected !== null
|
|
1555
|
-
? h(
|
|
1556
|
-
'div',
|
|
1557
|
-
{ className: 'kb-model-footer' },
|
|
1558
|
-
selectedRoles.length > 1
|
|
1559
|
-
? h(
|
|
1560
|
-
Select,
|
|
1561
|
-
{
|
|
1562
|
-
value: activeImportRole,
|
|
1563
|
-
disabled: m.importing === true,
|
|
1564
|
-
onValueChange: (next) =>
|
|
1565
|
-
typeof m.onImportRole === 'function' ? m.onImportRole(String(next)) : undefined
|
|
1566
|
-
},
|
|
1567
|
-
h(
|
|
1568
|
-
SelectTrigger,
|
|
1569
|
-
{ id: 'kb-model-import-role', className: 'kb-rule-select', 'aria-label': '导入为' },
|
|
1570
|
-
h(
|
|
1571
|
-
SelectValue,
|
|
1572
|
-
null,
|
|
1573
|
-
activeImportRole === 'vlm' ? '仅作为视觉模型 (VLLM)' : '对话模型(含视觉)'
|
|
1574
|
-
)
|
|
1575
|
-
),
|
|
1576
|
-
h(
|
|
1577
|
-
SelectContent,
|
|
1578
|
-
null,
|
|
1579
|
-
selectedRoles.map((role) =>
|
|
1580
|
-
h(
|
|
1581
|
-
SelectItem,
|
|
1582
|
-
{ key: role, value: role },
|
|
1583
|
-
role === 'vlm' ? '仅作为视觉模型 (VLLM)' : '对话模型(含视觉)'
|
|
1584
|
-
)
|
|
1585
|
-
)
|
|
1586
|
-
)
|
|
1587
|
-
)
|
|
1588
|
-
: null,
|
|
1589
|
-
h(
|
|
1590
|
-
Button,
|
|
1591
|
-
{
|
|
1592
|
-
size: 'sm',
|
|
1593
|
-
disabled: m.importing === true || typeof m.onCopy !== 'function',
|
|
1594
|
-
onClick: typeof m.onCopy === 'function' ? m.onCopy : undefined
|
|
1595
|
-
},
|
|
1596
|
-
m.importing === true ? '复制中…' : '复制到 WeKnora'
|
|
1597
|
-
)
|
|
1598
|
-
)
|
|
1599
|
-
: workbench
|
|
1600
|
-
? h(
|
|
1601
|
-
'p',
|
|
1602
|
-
{ className: 'kb-model-empty-hint' },
|
|
1603
|
-
'点击上方任意模型即可一键复制到知识库(不暴露 API Key)。'
|
|
1604
|
-
)
|
|
1605
|
-
: null
|
|
1606
|
-
)
|
|
1793
|
+
: null
|
|
1607
1794
|
)
|
|
1608
1795
|
)
|
|
1609
1796
|
: null
|
|
1797
|
+
)
|
|
1610
1798
|
)
|
|
1611
|
-
return workbench
|
|
1612
|
-
? h('section', { className: 'kb-model-workbench' }, card)
|
|
1613
|
-
: h(Section, { title: '模型配置' }, card)
|
|
1614
1799
|
}
|
|
1615
1800
|
|
|
1616
|
-
function ModelCopyPanel({ layout = 'card', autoLoad = false } = {}) {
|
|
1801
|
+
function ModelCopyPanel({ layout = 'card', autoLoad = false, onClose } = {}) {
|
|
1617
1802
|
const [open, setOpen] = useState(true)
|
|
1618
1803
|
const [state, setState] = useState('idle')
|
|
1619
1804
|
const [models, setModels] = useState([])
|
|
@@ -1648,10 +1833,10 @@ function ModelCopyPanel({ layout = 'card', autoLoad = false } = {}) {
|
|
|
1648
1833
|
|
|
1649
1834
|
// 工作台在宽屏首次出现或用户切到模型分段时懒加载一次;不阻塞日志首屏。
|
|
1650
1835
|
useEffect(() => {
|
|
1651
|
-
if (!autoLoad || autoLoadRef.current || state !== 'idle') return
|
|
1836
|
+
if (!autoLoad || !open || autoLoadRef.current || state !== 'idle') return
|
|
1652
1837
|
autoLoadRef.current = true
|
|
1653
1838
|
load()
|
|
1654
|
-
}, [autoLoad, state, load])
|
|
1839
|
+
}, [autoLoad, open, state, load])
|
|
1655
1840
|
|
|
1656
1841
|
const copy = useCallback(async () => {
|
|
1657
1842
|
const selected = models.find((item) => modelSelectionKey(item) === selectedKey)
|
|
@@ -1676,7 +1861,7 @@ function ModelCopyPanel({ layout = 'card', autoLoad = false } = {}) {
|
|
|
1676
1861
|
}, [models, selectedKey, importRole])
|
|
1677
1862
|
|
|
1678
1863
|
return modelCopyView({
|
|
1679
|
-
open
|
|
1864
|
+
open,
|
|
1680
1865
|
layout,
|
|
1681
1866
|
state,
|
|
1682
1867
|
models,
|
|
@@ -1689,6 +1874,7 @@ function ModelCopyPanel({ layout = 'card', autoLoad = false } = {}) {
|
|
|
1689
1874
|
importing,
|
|
1690
1875
|
copyError,
|
|
1691
1876
|
result,
|
|
1877
|
+
onClose,
|
|
1692
1878
|
onToggle: () => setOpen((value) => !value),
|
|
1693
1879
|
onLoad: load,
|
|
1694
1880
|
onSelect: (key) => {
|
|
@@ -3695,18 +3881,39 @@ function LogConsole({
|
|
|
3695
3881
|
)
|
|
3696
3882
|
}
|
|
3697
3883
|
|
|
3698
|
-
|
|
3884
|
+
/** 左栏档案卡暂不进入 UI;组件保留,便于以后恢复。 */
|
|
3885
|
+
const SHOW_ENGINE_RAIL = false
|
|
3699
3886
|
|
|
3700
|
-
|
|
3701
|
-
|
|
3887
|
+
/** 低频模型复制:Dialog 覆盖层,关闭后日志 DOM/滚动位置完全不变。 */
|
|
3888
|
+
export function ModelCopyDialog({ open = false, onOpenChange, children }) {
|
|
3889
|
+
const close = () => {
|
|
3890
|
+
if (typeof onOpenChange === 'function') onOpenChange(false)
|
|
3891
|
+
}
|
|
3892
|
+
return h(
|
|
3893
|
+
Dialog,
|
|
3894
|
+
{
|
|
3895
|
+
open: open === true,
|
|
3896
|
+
onOpenChange: (next) => {
|
|
3897
|
+
if (next !== true) close()
|
|
3898
|
+
}
|
|
3899
|
+
},
|
|
3900
|
+
h(
|
|
3901
|
+
DialogContent,
|
|
3902
|
+
{ className: 'flex flex-col kb-model-copy-dialog' },
|
|
3903
|
+
children !== undefined
|
|
3904
|
+
? children
|
|
3905
|
+
: open === true
|
|
3906
|
+
? h(ModelCopyPanel, { layout: 'workbench', autoLoad: true, onClose: close })
|
|
3907
|
+
: null
|
|
3908
|
+
)
|
|
3909
|
+
)
|
|
3702
3910
|
}
|
|
3703
3911
|
|
|
3704
3912
|
export function EngineTab({ status, actions, retrying, onRetry }) {
|
|
3705
3913
|
const [wrap, setWrap] = useState(true)
|
|
3706
3914
|
const [logQuery, setLogQuery] = useState('')
|
|
3707
3915
|
const [warningsOnly, setWarningsOnly] = useState(false)
|
|
3708
|
-
const [
|
|
3709
|
-
const [wideWorkbench, setWideWorkbench] = useState(() => matchesWideWorkbench())
|
|
3916
|
+
const [modelOpen, setModelOpen] = useState(false)
|
|
3710
3917
|
const logRef = useRef(null)
|
|
3711
3918
|
const busy = actions.pending !== ''
|
|
3712
3919
|
const loading = status.live === 'loading'
|
|
@@ -3801,15 +4008,6 @@ export function EngineTab({ status, actions, retrying, onRetry }) {
|
|
|
3801
4008
|
? `共 ${status.logLines} 行(status.logs 未提供,无法展示尾部)`
|
|
3802
4009
|
: '暂无引擎输出日志'
|
|
3803
4010
|
|
|
3804
|
-
useEffect(() => {
|
|
3805
|
-
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return undefined
|
|
3806
|
-
const query = window.matchMedia(WIDE_WORKBENCH_QUERY)
|
|
3807
|
-
const apply = () => setWideWorkbench(query.matches === true)
|
|
3808
|
-
apply()
|
|
3809
|
-
query.addEventListener?.('change', apply)
|
|
3810
|
-
return () => query.removeEventListener?.('change', apply)
|
|
3811
|
-
}, [])
|
|
3812
|
-
|
|
3813
4011
|
const jumpToBottom = () => {
|
|
3814
4012
|
const node = logRef.current
|
|
3815
4013
|
if (!node) return
|
|
@@ -3819,7 +4017,7 @@ export function EngineTab({ status, actions, retrying, onRetry }) {
|
|
|
3819
4017
|
|
|
3820
4018
|
return h(
|
|
3821
4019
|
'div',
|
|
3822
|
-
{ className: 'kb-engine-workbench'
|
|
4020
|
+
{ className: 'kb-engine-workbench' },
|
|
3823
4021
|
h(
|
|
3824
4022
|
'section',
|
|
3825
4023
|
{ className: 'kb-engine-hero' },
|
|
@@ -3840,7 +4038,17 @@ export function EngineTab({ status, actions, retrying, onRetry }) {
|
|
|
3840
4038
|
? h(Badge, { variant: 'outline' }, status.version)
|
|
3841
4039
|
: null
|
|
3842
4040
|
),
|
|
3843
|
-
h(
|
|
4041
|
+
h(
|
|
4042
|
+
'div',
|
|
4043
|
+
{ className: 'kb-hero-actions' },
|
|
4044
|
+
buttons,
|
|
4045
|
+
h(
|
|
4046
|
+
Button,
|
|
4047
|
+
{ variant: 'ghost', size: 'sm', onClick: () => setModelOpen(true) },
|
|
4048
|
+
h(UiIcon, { name: 'copy' }),
|
|
4049
|
+
'复制模型'
|
|
4050
|
+
)
|
|
4051
|
+
)
|
|
3844
4052
|
),
|
|
3845
4053
|
h(
|
|
3846
4054
|
'div',
|
|
@@ -3865,43 +4073,20 @@ export function EngineTab({ status, actions, retrying, onRetry }) {
|
|
|
3865
4073
|
)
|
|
3866
4074
|
: null
|
|
3867
4075
|
),
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
4076
|
+
SHOW_ENGINE_RAIL
|
|
4077
|
+
? h(
|
|
4078
|
+
'aside',
|
|
4079
|
+
{ className: 'kb-engine-rail' },
|
|
4080
|
+
h(
|
|
4081
|
+
EngineSideCard,
|
|
4082
|
+
{ title: '运行详情' },
|
|
4083
|
+
detailRows.map((row) =>
|
|
4084
|
+
h(EngineSideRow, { key: row.label, label: row.label }, row.value)
|
|
4085
|
+
)
|
|
4086
|
+
),
|
|
4087
|
+
h(OcrHealthCard, { status })
|
|
3876
4088
|
)
|
|
3877
|
-
|
|
3878
|
-
h(OcrHealthCard, { status })
|
|
3879
|
-
),
|
|
3880
|
-
h(
|
|
3881
|
-
'div',
|
|
3882
|
-
{ className: 'kb-engine-segmented' },
|
|
3883
|
-
h(
|
|
3884
|
-
ToggleGroup,
|
|
3885
|
-
{
|
|
3886
|
-
value: [pane],
|
|
3887
|
-
variant: 'outline',
|
|
3888
|
-
size: 'sm',
|
|
3889
|
-
spacing: 0,
|
|
3890
|
-
'aria-label': '引擎工作台面板',
|
|
3891
|
-
onValueChange: (next) => {
|
|
3892
|
-
const picked = next.find((value) => value !== pane)
|
|
3893
|
-
if (picked === 'logs' || picked === 'models') setPane(picked)
|
|
3894
|
-
}
|
|
3895
|
-
},
|
|
3896
|
-
h(
|
|
3897
|
-
ToggleGroupItem,
|
|
3898
|
-
{ value: 'logs' },
|
|
3899
|
-
'运行日志',
|
|
3900
|
-
h(Badge, { variant: 'secondary', className: 'kb-count' }, String(logs.length))
|
|
3901
|
-
),
|
|
3902
|
-
h(ToggleGroupItem, { value: 'models' }, '从 ChatLuna 复制模型')
|
|
3903
|
-
)
|
|
3904
|
-
),
|
|
4089
|
+
: null,
|
|
3905
4090
|
h(LogConsole, {
|
|
3906
4091
|
logs,
|
|
3907
4092
|
fallback: logFallback,
|
|
@@ -3914,14 +4099,10 @@ export function EngineTab({ status, actions, retrying, onRetry }) {
|
|
|
3914
4099
|
onWrap: () => setWrap((value) => !value),
|
|
3915
4100
|
onJump: jumpToBottom
|
|
3916
4101
|
}),
|
|
3917
|
-
h(
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
layout: 'workbench',
|
|
3922
|
-
autoLoad: pane === 'models' || wideWorkbench
|
|
3923
|
-
})
|
|
3924
|
-
)
|
|
4102
|
+
h(ModelCopyDialog, {
|
|
4103
|
+
open: modelOpen,
|
|
4104
|
+
onOpenChange: (next) => setModelOpen(next === true)
|
|
4105
|
+
})
|
|
3925
4106
|
)
|
|
3926
4107
|
}
|
|
3927
4108
|
|