-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathEndpointDetailPage.tsx
More file actions
1612 lines (1592 loc) · 54.3 KB
/
EndpointDetailPage.tsx
File metadata and controls
1612 lines (1592 loc) · 54.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
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
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
182
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
233
234
235
236
237
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
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
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
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
673
674
675
676
677
678
679
680
681
682
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
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
/**
@license
Copyright (c) 2015-2026 Lablup Inc. All rights reserved.
*/
import { AutoScalingRuleEditorModalLegacyFragment$key } from '../__generated__/AutoScalingRuleEditorModalLegacyFragment.graphql';
import {
EndpointDetailPageDeleteAutoScalingRuleMutation,
EndpointDetailPageDeleteAutoScalingRuleMutation$data,
} from '../__generated__/EndpointDetailPageDeleteAutoScalingRuleMutation.graphql';
import {
EndpointDetailPageQuery,
EndpointDetailPageQuery$data,
RouteFilter,
RouteHealthStatus,
RouteStatus,
RouteTrafficStatus,
} from '../__generated__/EndpointDetailPageQuery.graphql';
import { InferenceSessionErrorModalFragment$key } from '../__generated__/InferenceSessionErrorModalFragment.graphql';
import AutoScalingRuleEditorModalLegacy, {
COMPARATOR_LABELS,
} from '../components/AutoScalingRuleEditorModalLegacy';
import AutoScalingRuleList from '../components/AutoScalingRuleList';
import BAIJSONViewerModal from '../components/BAIJSONViewerModal';
import BAIRadioGroup from '../components/BAIRadioGroup';
import { isEndpointInDestroyingCategory } from '../components/EndpointList';
import EndpointOwnerInfo from '../components/EndpointOwnerInfo';
import EndpointStatusTag from '../components/EndpointStatusTag';
import EndpointTokenGenerationModal from '../components/EndpointTokenGenerationModal';
import { useFolderExplorerOpener } from '../components/FolderExplorerOpener';
import ImageNodeSimpleTag from '../components/ImageNodeSimpleTag';
import InferenceSessionErrorModal from '../components/InferenceSessionErrorModal';
import SessionDetailDrawer from '../components/SessionDetailDrawer';
import SourceCodeView from '../components/SourceCodeView';
import SwitchToProjectButton from '../components/SwitchToProjectButton';
import VFolderLazyViewV2 from '../components/VFolderLazyViewV2';
import VFolderNodeIdenticon from '../components/VFolderNodeIdenticon';
import { baiSignedRequestWithPromise, convertToOrderBy } from '../helper';
import { useSuspendedBackendaiClient, useWebUINavigate } from '../hooks';
import { useCurrentUserInfo } from '../hooks/backendai';
import { useBAIPaginationOptionState } from '../hooks/reactPaginationQueryOptions';
import { useTanMutation } from '../hooks/reactQueryAlias';
import { useCurrentProjectValue } from '../hooks/useCurrentProject';
import {
ArrowRightOutlined,
CheckCircleOutlined,
CheckOutlined,
CloseOutlined,
DeleteFilled,
ExclamationCircleOutlined,
LoadingOutlined,
PlusOutlined,
SettingOutlined,
SyncOutlined,
WarningOutlined,
} from '@ant-design/icons';
import {
Alert,
App,
Button,
Card,
Descriptions,
Popconfirm,
Spin,
Table,
Tag,
Tooltip,
Typography,
theme,
} from 'antd';
import { DescriptionsItemType } from 'antd/es/descriptions';
import {
filterOutNullAndUndefined,
BAIFlex,
BAIModal,
BAIGraphQLPropertyFilter,
BAIUnmountAfterClose,
BAIText,
BAIResourceNumberWithIcon,
BAIRouteNodes,
BAITag,
GraphQLFilter,
SemanticColor,
toGlobalId,
toLocalId,
useFetchKey,
useSemanticColorMap,
BAITable,
BAIFetchKeyButton,
} from 'backend.ai-ui';
import { default as dayjs } from 'dayjs';
import * as _ from 'lodash-es';
import {
BotMessageSquareIcon,
CircleArrowDownIcon,
CircleArrowUpIcon,
} from 'lucide-react';
import React, {
Suspense,
useDeferredValue,
useState,
useTransition,
} from 'react';
import { useTranslation } from 'react-i18next';
import { graphql, useLazyLoadQuery, useMutation } from 'react-relay';
import { useParams } from 'react-router-dom';
import { PayloadError } from 'relay-runtime';
interface RoutingInfo {
route_id: string;
session_id: string;
traffic_ratio: number;
}
export interface ModelServiceInfo {
endpoint_id: string;
name: string;
replicas?: number;
active_routes: RoutingInfo[];
service_endpoint: string;
is_public: boolean;
}
// TODO: display all of routings when API/GQL supports
// type RoutingStatus = "HEALTHY" | "PROVISIONING" | "UNHEALTHY";
interface EndpointDetailPageProps {}
type EndPoint = NonNullable<EndpointDetailPageQuery$data['endpoint']>;
type Routing = NonNullable<NonNullable<EndPoint['routings']>[0]>;
const dayDiff = (a: any, b: any) => {
const date1 = dayjs(a.created_at);
const date2 = dayjs(b.created_at);
return date1.diff(date2);
};
const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
'use memo';
const { t } = useTranslation();
const { token } = theme.useToken();
const { message } = App.useApp();
const { baiPaginationOption } = useBAIPaginationOptionState({
current: 1,
pageSize: 100,
});
const [routePagination, setRoutePagination] = useState({
current: 1,
pageSize: 10,
});
const [routeOrder, setRouteOrder] = useState<string | null>(null);
const [routeStatusCategory, setRouteStatusCategory] = useState<
'running' | 'finished'
>('running');
const [routePropertyFilter, setRoutePropertyFilter] =
useState<GraphQLFilter>();
const deferredRoutePagination = useDeferredValue(routePagination);
const deferredRouteOrder = useDeferredValue(routeOrder);
const deferredRouteStatusCategory = useDeferredValue(routeStatusCategory);
const deferredRoutePropertyFilter = useDeferredValue(routePropertyFilter);
const { serviceId } = useParams<{
serviceId: string;
}>();
const [fetchKey, updateFetchKey, INITIAL_FETCH_KEY] = useFetchKey();
const [isPendingRefetch, startRefetchTransition] = useTransition();
const [isPendingClearError, startClearErrorTransition] = useTransition();
const [selectedSessionErrorForModal, setSelectedSessionErrorForModal] =
useState<InferenceSessionErrorModalFragment$key | null>(null);
const [editingAutoScalingRule, setEditingAutoScalingRule] =
useState<AutoScalingRuleEditorModalLegacyFragment$key | null>(null);
const [isOpenAutoScalingRuleModal, setIsOpenAutoScalingRuleModal] =
useState(false);
const [isCurrentRevisionModalOpen, setIsCurrentRevisionModalOpen] =
useState(false);
const [
commitDeleteAutoScalingRuleMutation,
isInFlightDeleteAutoScalingRuleMutation,
] = useMutation<EndpointDetailPageDeleteAutoScalingRuleMutation>(graphql`
mutation EndpointDetailPageDeleteAutoScalingRuleMutation($id: String!) {
delete_endpoint_auto_scaling_rule_node(id: $id) {
ok
msg
}
}
`);
const [isOpenTokenGenerationModal, setIsOpenTokenGenerationModal] =
useState(false);
const [currentUser] = useCurrentUserInfo();
const currentProject = useCurrentProjectValue();
const baiClient = useSuspendedBackendaiClient();
const blockList = baiClient?._config?.blockList ?? null;
const webuiNavigate = useWebUINavigate();
const { open } = useFolderExplorerOpener();
const [selectedSessionId, setSelectedSessionId] = useState<string>();
const isSupportAutoScalingRule = baiClient.supports('auto-scaling-rule');
const isSupportPrometheusAutoScalingRule = baiClient.supports(
'prometheus-auto-scaling-rule',
);
const isSupportRouteHealthStatus = baiClient.supports('route-health-status');
const [errorDataForJSONModal, setErrorDataForJSONModal] = useState<string>();
const {
endpoint,
endpoint_token_list,
endpoint_auto_scaling_rules,
routes,
healthyRoutes,
modelDeployment,
} = useLazyLoadQuery<EndpointDetailPageQuery>(
graphql`
query EndpointDetailPageQuery(
$endpointId: UUID!
$tokenListOffset: Int!
$tokenListLimit: Int!
$autoScalingRules_endpointId: String!
$autoScalingRules_filter: String
$autoScalingRules_offset: Int
$autoScalingRules_order: String
$autoScalingRules_before: String
$autoScalingRules_after: String
$autoScalingRules_first: Int
$autoScalingRules_last: Int
$skipScalingRules: Boolean!
$deploymentId: ID!
$routeFilter: RouteFilter
$healthyRouteFilter: RouteFilter
$routeOrderBy: [RouteOrderBy!]
$routeLimit: Int
$routeOffset: Int
$skipRouteNodes: Boolean!
$skipRoutings: Boolean!
$skipModelDefinition: Boolean!
) {
endpoint(endpoint_id: $endpointId) {
name
status
lifecycle_stage
endpoint_id
project
image_object {
namespace
humanized_name
tag
registry
architecture
is_local
digest
resource_limits {
key
min
}
labels {
key
value
}
size_bytes
supported_accelerators
...ImageNodeSimpleTagFragment
}
replicas
url
open_to_public
errors {
session_id
...InferenceSessionErrorModalFragment
}
retries
runtime_variant {
human_readable_name
}
model
model_mount_destination
model_definition_path
extra_mounts {
row_id
name
...VFolderNodeIdenticonFragment
}
environ
resource_group
resource_slots
resource_opts
routings @skipOnClient(if: $skipRoutings) {
routing_id
session
traffic_ratio
endpoint
status
error_data
}
created_user_email
...EndpointOwnerInfoFragment
...EndpointStatusTagFragment
...ServiceLauncherPageContentFragment
}
endpoint_token_list(
offset: $tokenListOffset
limit: $tokenListLimit
endpoint_id: $endpointId
) {
total_count
items {
id
token
endpoint_id
domain
project
session_owner
created_at
valid_until
}
}
endpoint_auto_scaling_rules: endpoint_auto_scaling_rule_nodes(
endpoint: $autoScalingRules_endpointId
filter: $autoScalingRules_filter
order: $autoScalingRules_order
offset: $autoScalingRules_offset
before: $autoScalingRules_before
after: $autoScalingRules_after
first: $autoScalingRules_first
last: $autoScalingRules_last
) @skipOnClient(if: $skipScalingRules) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
id
endpoint
metric_name
metric_source
threshold
comparator
step_size
cooldown_seconds
min_replicas
max_replicas
created_at
last_triggered_at
...AutoScalingRuleEditorModalLegacyFragment
}
}
}
routes(
deploymentId: $deploymentId
filter: $routeFilter
orderBy: $routeOrderBy
limit: $routeLimit
offset: $routeOffset
) @skipOnClient(if: $skipRouteNodes) {
edges {
node {
...BAIRouteNodesFragment
}
}
count
}
healthyRoutes: routes(
deploymentId: $deploymentId
filter: $healthyRouteFilter
) @skipOnClient(if: $skipRouteNodes) {
count
}
modelDeployment: deployment(id: $deploymentId)
@skipOnClient(if: $skipModelDefinition) {
metadata {
status
}
currentRevision {
id
modelDefinition {
models {
name
modelPath
service {
startCommand
port
healthCheck {
path
initialDelay
maxRetries
}
}
}
}
}
revisionHistory(
limit: 1
orderBy: [{ field: CREATED_AT, direction: DESC }]
) {
edges {
node {
id
modelDefinition {
models {
name
modelPath
service {
startCommand
port
healthCheck {
path
initialDelay
maxRetries
}
}
}
}
}
}
}
}
}
`,
{
tokenListOffset: baiPaginationOption.offset,
tokenListLimit: baiPaginationOption.limit,
endpointId: serviceId || '',
autoScalingRules_endpointId: serviceId as string,
autoScalingRules_filter: undefined,
autoScalingRules_offset: undefined,
autoScalingRules_before: undefined,
autoScalingRules_after: undefined,
autoScalingRules_first: undefined,
autoScalingRules_last: undefined,
skipScalingRules:
!isSupportAutoScalingRule || isSupportPrometheusAutoScalingRule,
deploymentId: toGlobalId('ModelDeployment', serviceId || ''),
routeFilter: {
status: (deferredRouteStatusCategory === 'running'
? isSupportRouteHealthStatus
? ['PROVISIONING', 'RUNNING', 'TERMINATING']
: [
'PROVISIONING',
'HEALTHY',
'UNHEALTHY',
'DEGRADED',
'TERMINATING',
]
: ['TERMINATED', 'FAILED_TO_START']) as RouteStatus[],
...(isSupportRouteHealthStatus &&
deferredRoutePropertyFilter?.healthStatus
? {
healthStatus: [
deferredRoutePropertyFilter.healthStatus as RouteHealthStatus,
],
}
: {}),
...(deferredRoutePropertyFilter?.trafficStatus
? {
trafficStatus: [
deferredRoutePropertyFilter.trafficStatus as RouteTrafficStatus,
],
}
: {}),
},
healthyRouteFilter: (isSupportRouteHealthStatus
? { healthStatus: ['HEALTHY'] }
: { status: ['HEALTHY'] }) as RouteFilter,
routeOrderBy: convertToOrderBy(deferredRouteOrder) ?? undefined,
routeLimit: deferredRoutePagination.pageSize,
routeOffset:
(deferredRoutePagination.current - 1) *
deferredRoutePagination.pageSize,
skipRouteNodes: !baiClient.supports('route-node'),
skipRoutings: baiClient.supports('route-node'),
skipModelDefinition: !baiClient.supports('model-card-v2'),
},
{
fetchPolicy:
fetchKey === INITIAL_FETCH_KEY ? 'store-and-network' : 'network-only',
fetchKey,
},
);
// Check if the endpoint belongs to a different project than the currently selected one
const isProjectMismatch = endpoint
? endpoint.project !== currentProject.id
: false;
const deploymentStatus = modelDeployment?.metadata?.status;
// When model-card-v2 is supported, use deployment.metadata.status as the
// single source of truth — avoids the mixed-state problem of endpoint.status
// and route-count heuristics (which can be stale during rolling updates).
const isDeploymentDeploying = baiClient.supports('model-card-v2')
? deploymentStatus === 'DEPLOYING'
: endpoint?.lifecycle_stage === 'DEPLOYING';
const hasAnyHealthyRoute = baiClient.supports('model-card-v2')
? deploymentStatus === 'READY'
: baiClient.supports('route-node')
? (healthyRoutes?.count ?? 0) > 0
: endpoint?.status === 'HEALTHY';
const mutationToClearError = useTanMutation({
mutationFn: () => {
if (!endpoint) return;
return baiSignedRequestWithPromise({
method: 'POST',
url: `/services/${endpoint.endpoint_id}/errors/clear`,
client: baiClient,
});
},
});
const mutationToSyncRoutes = useTanMutation<
{
success: boolean;
},
unknown,
string
>({
mutationFn: (endpoint_id) => {
return baiSignedRequestWithPromise({
method: 'POST',
url: `/services/${endpoint_id}/sync`,
client: baiClient,
});
},
});
const legacyRouteStatusSemanticMap: Record<string, SemanticColor> = {
HEALTHY: 'success',
PROVISIONING: 'info',
UNHEALTHY: 'warning',
DEGRADED: 'warning',
FAILED_TO_START: 'error',
};
const semanticColorMap = useSemanticColorMap();
const autoScalingRules = filterOutNullAndUndefined(
_.map(endpoint_auto_scaling_rules?.edges, (edge) => edge?.node),
);
const resource_opts = JSON.parse(endpoint?.resource_opts || '{}');
const items: DescriptionsItemType[] = [
{
label: t('modelService.EndpointName'),
children: <Typography.Text copyable>{endpoint?.name}</Typography.Text>,
},
{
label: t('modelService.Status'),
children: <EndpointStatusTag endpointFrgmt={endpoint} />,
},
{
label: t('modelService.RuntimeVariant'),
children: endpoint?.runtime_variant?.human_readable_name || (
<Typography.Text type="secondary">-</Typography.Text>
),
},
{
label: t('modelService.EndpointId'),
children: endpoint?.endpoint_id,
},
{
label: t('modelService.SessionOwner'),
children: <EndpointOwnerInfo endpointFrgmt={endpoint} />,
},
{
label: t('modelService.NumberOfReplicas'),
children: endpoint?.replicas,
},
{
label: t('modelService.ServiceEndpoint'),
children: endpoint?.url ? (
<>
<Typography.Text copyable>{endpoint?.url}</Typography.Text>
{!_.includes(blockList, 'chat') ? (
<Tooltip title={'LLM Chat Test'}>
<Button
type="link"
icon={<BotMessageSquareIcon />}
onClick={() => {
webuiNavigate({
pathname: '/chat',
search: new URLSearchParams({
endpointId: endpoint?.endpoint_id ?? '',
}).toString(),
});
}}
disabled={!hasAnyHealthyRoute}
/>
</Tooltip>
) : null}
</>
) : (
<Typography.Text type="secondary">
{t('modelService.NoServiceEndpoint')}
</Typography.Text>
),
},
{
label: t('modelService.OpenToPublic'),
children: endpoint?.open_to_public ? (
<CheckOutlined />
) : (
<CloseOutlined />
),
},
{
label: t('modelService.Resources'),
children: (
<BAIFlex direction="row" wrap="wrap" gap={'md'}>
<Tooltip title={t('session.ResourceGroup')}>
<Tag>{endpoint?.resource_group}</Tag>
</Tooltip>
{_.map(
JSON.parse(endpoint?.resource_slots || '{}'),
(value: string, type) => {
return (
<BAIResourceNumberWithIcon
key={type}
type={type}
value={value}
opts={resource_opts}
/>
);
},
)}
</BAIFlex>
),
span: {
xl: 2,
},
},
{
label: t('session.launcher.ModelStorage'),
children: endpoint?.model ? (
<Suspense fallback={<Spin indicator={<LoadingOutlined spin />} />}>
<BAIFlex direction="column" align="start">
<VFolderLazyViewV2 uuid={endpoint?.model} clickable={true} />
{endpoint?.model_mount_destination && (
<BAIFlex direction="row" align="center" gap={'xxs'}>
<ArrowRightOutlined type="secondary" />
<Typography.Text type="secondary">
{endpoint?.model_mount_destination}
</Typography.Text>
</BAIFlex>
)}
</BAIFlex>
</Suspense>
) : null,
},
{
label: t('modelService.AdditionalMounts'),
children: (
<BAIFlex direction="column" align="start">
{_.map(
filterOutNullAndUndefined(endpoint?.extra_mounts),
(vfolder) => {
return (
<Typography.Link
onClick={() => {
vfolder?.row_id && open(vfolder?.row_id);
}}
>
<BAIFlex direction="row" gap={'xs'} key={vfolder?.row_id}>
<VFolderNodeIdenticon vfolderNodeIdenticonFrgmt={vfolder} />{' '}
{vfolder?.name}
</BAIFlex>
</Typography.Link>
);
},
)}
</BAIFlex>
),
},
{
label: t('session.launcher.EnvironmentVariable'),
children: (() => {
let envObj: Record<string, string> = {};
try {
envObj = JSON.parse(endpoint?.environ || '{}');
} catch {
return '-';
}
if (_.isEmpty(envObj)) return '-';
const envText = _.map(envObj, (value, key) => `${key}="${value}"`).join(
'\n',
);
return <SourceCodeView language="shell">{envText}</SourceCodeView>;
})(),
span: {
sm: 1,
},
},
{
label: t('modelService.Image'),
children: endpoint?.image_object ? (
<ImageNodeSimpleTag imageFrgmt={endpoint.image_object} />
) : null,
span: {
xl: 3,
},
},
];
// TODO: show current Autoscaling Rule in human-friendly way
// items.push({
// label: 'Autoscaling Rule',
// children: (
// <>
// <Tag>vllm_avg_prompt_throughput_toks_per_s</Tag>
// <Tag>LESS_THAN</Tag>
// <Tag>Cool down sec: 300</Tag>
// <Tag>Min Replica #: 1</Tag>
// <Tag>Max Replica #: 3</Tag>
// </>
// ),
// });
const buildModelDefinitionItems = (
rawModels:
| ReadonlyArray<{
readonly name: string | null | undefined;
readonly modelPath: string | null | undefined;
readonly service?: {
readonly startCommand: unknown;
readonly port: number | null | undefined;
readonly healthCheck?: {
readonly path: string | null | undefined;
readonly initialDelay: number | null | undefined;
readonly maxRetries: number | null | undefined;
} | null;
} | null;
} | null>
| null
| undefined,
): DescriptionsItemType[] => {
const models = filterOutNullAndUndefined(rawModels);
if (!models || models.length === 0) return [];
return models.flatMap((model, idx) => {
const prefix = models.length > 1 ? `[${idx}] ` : '';
const modelItems: DescriptionsItemType[] = [
{
key: `model-name-${idx}`,
label: `${prefix}${t('modelStore.ModelName')}`,
children: model.name || (
<Typography.Text type="secondary">-</Typography.Text>
),
},
{
key: `model-path-${idx}`,
label: `${prefix}${t('modelStore.ModelPath')}`,
children: model.modelPath || (
<Typography.Text type="secondary">-</Typography.Text>
),
},
...(model.service
? ([
{
key: `model-start-command-${idx}`,
label: `${prefix}${t('modelService.StartCommand')}`,
children: model.service.startCommand ? (
<SourceCodeView language="shell">
{typeof model.service.startCommand === 'string'
? model.service.startCommand
: JSON.stringify(model.service.startCommand, null, 2)}
</SourceCodeView>
) : (
<Typography.Text type="secondary">-</Typography.Text>
),
span: { xl: 2 },
},
{
key: `model-port-${idx}`,
label: `${prefix}${t('modelService.Port')}`,
children: model.service.port ?? (
<Typography.Text type="secondary">-</Typography.Text>
),
},
...(model.service.healthCheck
? ([
{
key: `model-healthcheck-path-${idx}`,
label: `${prefix}${t('modelService.HealthCheck')}`,
children: model.service.healthCheck.path || (
<Typography.Text type="secondary">-</Typography.Text>
),
},
{
key: `model-initial-delay-${idx}`,
label: `${prefix}${t('modelService.InitialDelay')}`,
children: model.service.healthCheck.initialDelay ?? (
<Typography.Text type="secondary">-</Typography.Text>
),
},
{
key: `model-max-retries-${idx}`,
label: `${prefix}${t('modelService.MaxRetries')}`,
children: model.service.healthCheck.maxRetries ?? (
<Typography.Text type="secondary">-</Typography.Text>
),
},
] as DescriptionsItemType[])
: []),
] as DescriptionsItemType[])
: []),
];
return modelItems;
});
};
const currentRevisionItems = buildModelDefinitionItems(
modelDeployment?.currentRevision?.modelDefinition?.models,
);
const latestRevisionItems = buildModelDefinitionItems(
modelDeployment?.revisionHistory?.edges?.[0]?.node?.modelDefinition?.models,
);
const currentRevisionName = modelDeployment?.currentRevision?.id
? toLocalId(modelDeployment.currentRevision.id)
: undefined;
const latestRevisionName = modelDeployment?.revisionHistory?.edges?.[0]?.node
?.id
? toLocalId(modelDeployment.revisionHistory.edges[0].node.id)
: undefined;
const isRevisionMismatch =
modelDeployment?.currentRevision?.id != null &&
modelDeployment?.revisionHistory?.edges?.[0]?.node?.id != null &&
modelDeployment?.currentRevision?.id !==
modelDeployment?.revisionHistory?.edges?.[0]?.node?.id;
const displayRevisionItems =
latestRevisionItems.length > 0 ? latestRevisionItems : currentRevisionItems;
const displayRevisionName =
latestRevisionItems.length > 0 ? latestRevisionName : currentRevisionName;
return (
<BAIFlex direction="column" align="stretch" gap="sm">
<BAIFlex direction="row" justify="between">
<Typography.Title level={3} style={{ margin: 0 }}>
{endpoint?.name || ''}
</Typography.Title>
<BAIFlex gap={'xxs'}>
{(endpoint?.retries || 0) > 0 ? (
<Tooltip title={t('modelService.ClearErrors')}>
<Button
loading={isPendingClearError}
icon={<WarningOutlined />}
onClick={() => {
startClearErrorTransition(() => {
mutationToClearError.mutate(undefined, {
onSuccess: () =>
startRefetchTransition(() => {
updateFetchKey();
}),
});
});
}}
/>
</Tooltip>
) : (
<></>
)}
<BAIFetchKeyButton
loading={isPendingRefetch}
value={fetchKey}
autoUpdateDelay={10_000}
disabled={isEndpointInDestroyingCategory(endpoint)}
onChange={() => {
startRefetchTransition(() => {
updateFetchKey();
});
}}
>
{t('button.Refresh')}
</BAIFetchKeyButton>
</BAIFlex>
</BAIFlex>
{isDeploymentDeploying &&
!isEndpointInDestroyingCategory(endpoint) &&
endpoint?.replicas !== 0 && (
<Alert
type="info"
showIcon
icon={<LoadingOutlined />}
title={t('modelService.PreparingService')}
description={t('modelService.PreparingServiceDescription')}
style={{ marginBottom: token.marginSM }}
/>
)}
{hasAnyHealthyRoute &&
!isEndpointInDestroyingCategory(endpoint) &&
!_.includes(blockList, 'chat') && (
<Alert
type="success"
showIcon
title={t('modelService.ServiceReady')}
description={t('modelService.ServiceReadyDescription')}
style={{ marginBottom: token.marginSM }}
action={
<Button
type="primary"
size="small"
icon={<BotMessageSquareIcon size={14} />}
onClick={() => {
webuiNavigate({
pathname: '/chat',
search: new URLSearchParams({
endpointId: endpoint?.endpoint_id ?? '',
}).toString(),
});
}}
>
{t('modelService.StartChat')}
</Button>
}
/>
)}
{isProjectMismatch && endpoint?.project && (
<Alert
title={t('modelService.NotInProject')}
type="warning"
showIcon
style={{ marginBottom: token.marginSM }}
action={<SwitchToProjectButton projectId={endpoint.project} />}
/>
)}
<Card
title={t('modelService.ServiceInfo')}
extra={
<Tooltip
title={
endpoint?.lifecycle_stage === 'DEPLOYING'
? t('modelService.EditNotAvailableWhileDeploying')
: undefined
}
>
<Button
type="primary"
icon={<SettingOutlined />}
disabled={
endpoint?.lifecycle_stage === 'DEPLOYING' ||
isEndpointInDestroyingCategory(endpoint) ||
isProjectMismatch ||
(!!endpoint?.created_user_email &&
endpoint?.created_user_email !== currentUser.email)
}
onClick={() => {
webuiNavigate('/service/update/' + serviceId);
}}
>
{t('button.Edit')}
</Button>
</Tooltip>
}
>
<Descriptions
bordered
column={{ xxl: 3, xl: 2, lg: 2, md: 1, sm: 1, xs: 1 }}
style={{
backgroundColor: token.colorBgBase,
}}
items={items}
></Descriptions>
</Card>
{(latestRevisionItems.length > 0 || currentRevisionItems.length > 0) && (
<Card title={t('modelService.RevisionInfo')}>
{isRevisionMismatch && (
<Alert
type="info"
icon={<LoadingOutlined spin />}
showIcon
title={t('modelService.NextRevisionApplying')}
action={
<Button onClick={() => setIsCurrentRevisionModalOpen(true)}>
{t('modelService.ViewCurrentRevision')}
</Button>
}
style={{ marginBottom: token.marginMD }}
/>
)}
<Descriptions
bordered
column={{ xxl: 3, xl: 2, lg: 2, md: 1, sm: 1, xs: 1 }}
style={{
backgroundColor: token.colorBgBase,
}}
items={[
{
key: 'revision-id',
label: t('modelService.RevisionID'),
children: displayRevisionName || (
<Typography.Text type="secondary">-</Typography.Text>
),
},
...displayRevisionItems,
]}
></Descriptions>
</Card>
)}
<BAIModal
open={isCurrentRevisionModalOpen}
onCancel={() => setIsCurrentRevisionModalOpen(false)}
title={t('modelService.CurrentRevisionTitle')}
footer={null}
width={800}
>
<Alert
type="info"
icon={<CheckCircleOutlined />}
showIcon