From db45c861e45c37feaf60c7ecbb34acf06cf47732 Mon Sep 17 00:00:00 2001 From: jialin Date: Sun, 21 Dec 2025 21:35:53 +0800 Subject: [PATCH] feat: models filter by state --- src/locales/en-US/models.ts | 4 +- src/locales/ja-JP/models.ts | 8 +- src/locales/ru-RU/models.ts | 4 +- src/pages/llmodels/components/model-item.tsx | 17 +--- src/pages/llmodels/components/table-list.tsx | 19 +++++ src/pages/llmodels/config/index.ts | 6 +- .../llmodels/hooks/use-filter-status.tsx | 79 +++++++++++++++++++ src/pages/llmodels/index.tsx | 16 ++++ src/pages/llmodels/user-models.tsx | 12 +-- 9 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 src/pages/llmodels/hooks/use-filter-status.tsx diff --git a/src/locales/en-US/models.ts b/src/locales/en-US/models.ts index e10c9bba..1b69f1b5 100644 --- a/src/locales/en-US/models.ts +++ b/src/locales/en-US/models.ts @@ -216,8 +216,8 @@ export default { 'models.form.gpusAllocationType.custom.tips': 'You can specify the exact number of GPUs per replica.', 'models.mymodels.status.inactive': 'Stopped', - 'models.mymodels.status.degrade': 'Abnormal', - 'models.mymodels.status.active': 'Active', + 'models.mymodels.status.degrade': 'Not Ready', + 'models.mymodels.status.active': 'Ready', 'models.form.kvCache.tips': 'Extended KV cache and speculative decoding are only available with built-in backends (vLLM / SGLang), Please switch the backend in the Advanced settings to enable them.', 'models.form.kvCache.tips2': diff --git a/src/locales/ja-JP/models.ts b/src/locales/ja-JP/models.ts index a8fb286e..10c51f8e 100644 --- a/src/locales/ja-JP/models.ts +++ b/src/locales/ja-JP/models.ts @@ -216,8 +216,8 @@ export default { 'models.form.gpusAllocationType.custom.tips': 'You can specify the exact number of GPUs per replica.', 'models.mymodels.status.inactive': 'Stopped', - 'models.mymodels.status.degrade': 'Abnormal', - 'models.mymodels.status.active': 'Active', + 'models.mymodels.status.degrade': 'Not Ready', + 'models.mymodels.status.active': 'Ready', 'models.form.kvCache.tips': 'Extended KV cache and speculative decoding are only available with built-in backends (vLLM / SGLang), Please switch the backend in the Advanced settings to enable them.', 'models.form.kvCache.tips2': @@ -313,8 +313,8 @@ export default { // 37. 'models.form.gpusAllocationType.auto.tips': 'The system automatically calculates the GPU count per replica, using powers of two by default and capped by the selected GPUs.', // 38. 'models.form.gpusAllocationType.custom.tips': 'You can specify the exact number of GPUs per replica.', // 39. 'models.mymodels.status.inactive': 'Stopped', -// 41. 'models.mymodels.status.degrade': 'Abnormal', -// 42. 'models.mymodels.status.active': 'Active' +// 41. 'models.mymodels.status.degrade': 'Not Ready', +// 42. 'models.mymodels.status.active': 'Ready', // 43. 'models.form.remoteURL.tips': 'Refer to the configuration documentation for details.', // 44. 'models.form.kvCache.tips': 'Extended KV cache and speculative decoding are only available with built-in backends (vLLM / SGLang), Please switch the backend in the Advanced settings to enable them.', // 45. 'models.form.kvCache.tips2': 'Only supported when using built-in inference backends (vLLM or SGLang).', diff --git a/src/locales/ru-RU/models.ts b/src/locales/ru-RU/models.ts index 09a72a77..ee7b2509 100644 --- a/src/locales/ru-RU/models.ts +++ b/src/locales/ru-RU/models.ts @@ -220,8 +220,8 @@ export default { 'models.form.gpusAllocationType.custom.tips': 'Вы можете указать точное количество GPU на реплику.', 'models.mymodels.status.inactive': 'Остановлен', - 'models.mymodels.status.degrade': 'Аномальный', - 'models.mymodels.status.active': 'Активен', + 'models.mymodels.status.degrade': 'Не готов', + 'models.mymodels.status.active': 'Готов', 'models.form.kvCache.tips': 'Расширенный KV-кэш и спекулятивное декодирование доступны только со встроенными бэкендами (vLLM / SGLang). Переключите бэкенд в Расширенных настройках, чтобы включить их.', 'models.form.kvCache.tips2': diff --git a/src/pages/llmodels/components/model-item.tsx b/src/pages/llmodels/components/model-item.tsx index 08dd3b4f..fd7e8183 100644 --- a/src/pages/llmodels/components/model-item.tsx +++ b/src/pages/llmodels/components/model-item.tsx @@ -161,21 +161,6 @@ const ModelItem: React.FC<{ return _.round(max_tokens / 1024); }, [model]); - const status = useMemo(() => { - if (!model.replicas && !model.ready_replicas) { - return MyModelsStatusValueMap.Inactive; - } - - if (model.replicas > 0 && !model.ready_replicas) { - return MyModelsStatusValueMap.Degrade; - } - - if (model.replicas === model.ready_replicas && model.replicas > 0) { - return MyModelsStatusValueMap.Active; - } - return MyModelsStatusValueMap.Degrade; - }, [model]); - return ( void; onStart?: () => void; onTableSort?: (order: TableOrder | Array) => void; + onStatusChange: (value?: any) => void; sortOrder: string[]; queryParams: { page: number; @@ -119,6 +121,7 @@ const Models: React.FC = ({ onStop, onStart, onTableSort, + onStatusChange, sortOrder, deleteIds, dataSource, @@ -154,6 +157,10 @@ const Models: React.FC = ({ removeExpandedRowKey, expandedRowKeys } = useExpandedRowKeys(expandAtom); + const { labelRender, optionRender, handleStatusChange, statusOptions } = + useFilterStatus({ + onStatusChange: onStatusChange + }); const [apiAccessInfo, setAPIAccessInfo] = useState({ show: false, @@ -663,6 +670,18 @@ const Models: React.FC = ({ onChange={handleClusterChange} options={clusterList} > +