From a42df69a7fe48bdf68e4574ab1ccdddfd0baeb85 Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 25 Nov 2024 11:47:52 +0800 Subject: [PATCH] feat: add backend version field --- src/locales/en-US/models.ts | 5 ++++- src/locales/zh-CN/models.ts | 5 ++++- src/pages/llmodels/components/advance-config.tsx | 10 ++++++++++ src/pages/llmodels/components/instance-item.tsx | 2 ++ src/pages/llmodels/components/table-list.tsx | 4 ++-- src/pages/llmodels/components/view-logs-modal.tsx | 4 ++-- src/pages/llmodels/config/index.ts | 5 +++++ src/pages/llmodels/config/types.ts | 2 ++ 8 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/locales/en-US/models.ts b/src/locales/en-US/models.ts index d9b97daf..2137b0f3 100644 --- a/src/locales/en-US/models.ts +++ b/src/locales/en-US/models.ts @@ -70,5 +70,8 @@ export default { 'models.logs.pagination.prev': 'Previous {lines} Lines', 'models.logs.pagination.next': 'Next {lines} Lines', 'models.form.localPath': 'Local Path', - 'models.form.filePath': 'Model Path' + 'models.form.filePath': 'Model Path', + 'model.form.backendVersion': 'Backend Version', + 'models.form.backendVersion.tips': + 'Pin a specific version to keep the backend stable across GPUStack upgrades.' }; diff --git a/src/locales/zh-CN/models.ts b/src/locales/zh-CN/models.ts index ffeb3ff6..b4bceed5 100644 --- a/src/locales/zh-CN/models.ts +++ b/src/locales/zh-CN/models.ts @@ -68,5 +68,8 @@ export default { 'models.logs.pagination.prev': '上一 {lines} 行', 'models.logs.pagination.next': '下一 {lines} 行', 'models.form.localPath': '本地路径', - 'models.form.filePath': '模型路径' + 'models.form.filePath': '模型路径', + 'model.form.backendVersion': '后端版本', + 'model.form.backendVersion.tips': + '固定指定版本以保持后端在 GPUStack 升级过程中的稳定性' }; diff --git a/src/pages/llmodels/components/advance-config.tsx b/src/pages/llmodels/components/advance-config.tsx index 3f9afdc8..8a1954d2 100644 --- a/src/pages/llmodels/components/advance-config.tsx +++ b/src/pages/llmodels/components/advance-config.tsx @@ -1,5 +1,6 @@ import LabelSelector from '@/components/label-selector'; import ListInput from '@/components/list-input'; +import SealInput from '@/components/seal-form/seal-input'; import SealSelect from '@/components/seal-form/seal-select'; import { PageAction } from '@/config'; import { PageActionType } from '@/config/types'; @@ -138,6 +139,7 @@ const AdvanceConfig: React.FC = (props) => { cpu_offloading: true }); } + form.setFieldValue('backend_version', ''); }, []); const collapseItems = useMemo(() => { @@ -270,6 +272,14 @@ const AdvanceConfig: React.FC = (props) => { } > + + + name="backend_parameters"> = ({ label: 'common.button.viewlog', key: 'viewlog', status: [ + InstanceStatusMap.Initializing, InstanceStatusMap.Running, InstanceStatusMap.Error, InstanceStatusMap.Downloading @@ -104,6 +105,7 @@ const InstanceItem: React.FC = ({
{intl.formatMessage({ id: 'models.form.backend' })}:{' '} {modelData?.backend || ''} + {modelData.backend_version ? `(${modelData.backend_version})` : ''}
); diff --git a/src/pages/llmodels/components/table-list.tsx b/src/pages/llmodels/components/table-list.tsx index d6d0e24a..b3cfb3a3 100644 --- a/src/pages/llmodels/components/table-list.tsx +++ b/src/pages/llmodels/components/table-list.tsx @@ -40,7 +40,7 @@ import { updateModel } from '../apis'; import { - InstanceStatusMap, + InstanceRealLogStatus, getSourceRepoConfigValue, modelSourceMap } from '../config'; @@ -357,7 +357,7 @@ const Models: React.FC = ({ status: row.state, id: row.id, modelId: row.model_id, - tail: row.state === InstanceStatusMap.Downloading ? undefined : PageSize + tail: InstanceRealLogStatus.includes(row.state) ? undefined : PageSize }); setOpenLogModal(true); } catch (error) { diff --git a/src/pages/llmodels/components/view-logs-modal.tsx b/src/pages/llmodels/components/view-logs-modal.tsx index 6cd20bd6..5aa21221 100644 --- a/src/pages/llmodels/components/view-logs-modal.tsx +++ b/src/pages/llmodels/components/view-logs-modal.tsx @@ -4,7 +4,7 @@ import { useIntl } from '@umijs/max'; import { Modal } from 'antd'; import React, { useCallback, useEffect, useState } from 'react'; import { MODELS_API } from '../apis'; -import { InstanceStatusMap } from '../config'; +import { InstanceRealLogStatus } from '../config'; type ViewModalProps = { open: boolean; @@ -36,7 +36,7 @@ const ViewCodeModal: React.FC = (props) => { const updateHandler = (list: any) => { const data = list?.find((item: any) => item.data.id === props.id); if (data) { - setEnableScorllLoad(InstanceStatusMap.Downloading !== data?.data?.state); + setEnableScorllLoad(!InstanceRealLogStatus.includes(data?.data?.state)); } }; diff --git a/src/pages/llmodels/config/index.ts b/src/pages/llmodels/config/index.ts index 0b1b824e..03f82bf6 100644 --- a/src/pages/llmodels/config/index.ts +++ b/src/pages/llmodels/config/index.ts @@ -104,6 +104,11 @@ export const InstanceStatusMap = { Analyzing: 'analyzing' }; +export const InstanceRealLogStatus = [ + InstanceStatusMap.Downloading, + InstanceStatusMap.Initializing +]; + export const InstanceStatusMapValue = { [InstanceStatusMap.Initializing]: 'Initializing', [InstanceStatusMap.Pending]: 'Pending', diff --git a/src/pages/llmodels/config/types.ts b/src/pages/llmodels/config/types.ts index e2ae31ea..17f0468e 100644 --- a/src/pages/llmodels/config/types.ts +++ b/src/pages/llmodels/config/types.ts @@ -4,6 +4,7 @@ export interface ListItem { reranker: boolean; huggingface_repo_id: string; huggingface_file_name: string; + backend_version?: string; huggingface_filename: string; ollama_library_model_name: string; model_scope_file_path: string; @@ -29,6 +30,7 @@ export interface ListItem { export interface FormData { backend?: string; backend_parameters?: string[]; + backend_version?: string; source: string; repo_id: string; file_name: string;