chore: pluggable locale config

This commit is contained in:
jialin
2025-10-13 14:40:26 +08:00
parent caabeb065a
commit b5fa40047a
30 changed files with 731 additions and 575 deletions
+3 -2
View File
@@ -399,7 +399,7 @@ export async function evaluationsModelSpec(
};
}
export async function queryBackendList() {
export async function queryBackendList(params?: { cluster_id: number }) {
return request<{
items: {
backend_name: string;
@@ -410,6 +410,7 @@ export async function queryBackendList() {
versions: string[];
}[];
}>(BACKEND_LIST_API, {
method: 'GET'
method: 'GET',
params
});
}
@@ -245,6 +245,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
return result;
};
// TODO need check the backend is available
const handleSetBackendOptions = () => {
const backendGroup = _.groupBy(specListRef.current, 'backend');
@@ -495,6 +496,9 @@ const AddModal: React.FC<AddModalProps> = (props) => {
form.current?.getGPUOptionList?.({
clusterId: initClusterId()
});
form.current?.getBackendOptions?.({
cluster_id: initClusterId()
});
}, 100);
}
return () => {
@@ -596,7 +600,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
isGGUF={isGGUF}
formKey={deployFormKeyMap.catalog}
sourceDisable={false}
backendOptions={backendList}
sourceList={sourceList}
clusterList={clusterList}
onBackendChange={handleBackendChange}
+13 -10
View File
@@ -10,7 +10,7 @@ import styled from 'styled-components';
import ColumnWrapper from '../../_components/column-wrapper';
import { defaultFormValues, deployFormKeyMap, modelSourceMap } from '../config';
import { backendOptionsMap } from '../config/backend-parameters';
import { BackendOption, FormData, SourceType } from '../config/types';
import { FormData, SourceType } from '../config/types';
import DataForm from '../forms';
import {
MessageStatus,
@@ -63,7 +63,6 @@ type AddModalProps = {
width?: string | number;
initialValues?: any;
deploymentType?: 'modelList' | 'modelFiles';
backendOptions: BackendOption[];
clusterList: Global.BaseOption<
number,
{ provider: string; state: string | number }
@@ -326,15 +325,17 @@ const AddModal: FC<AddModalProps> = (props) => {
return;
}
if (data.local_path || props.source !== modelSourceMap.local_path_value) {
// TODO confirm wheather it is gguf by model file not by backend
handleOnValuesChange?.({
changedValues: {},
allValues:
backend === backendOptionsMap.llamaBox
? data
: _.omit(data, [
'cpu_offloading',
'distributed_inference_across_workers'
]),
// allValues:
// backend === backendOptionsMap.llamaBox
// ? data
// : _.omit(data, [
// 'cpu_offloading',
// 'distributed_inference_across_workers'
// ]),
allValues: data,
source: props.source
});
}
@@ -413,6 +414,9 @@ const AddModal: FC<AddModalProps> = (props) => {
form.current?.getGPUOptionList?.({
clusterId: initClusterId()
});
form.current?.getBackendOptions?.({
cluster_id: initClusterId()
});
} else {
cancelEvaluate();
clearCahceFormValues();
@@ -542,7 +546,6 @@ const AddModal: FC<AddModalProps> = (props) => {
onOk={handleOnOk}
ref={form}
isGGUF={isGGUF}
backendOptions={props.backendOptions}
onBackendChange={handleBackendChange}
onValuesChange={onValuesChange}
></DataForm>
+1 -6
View File
@@ -42,7 +42,6 @@ import {
modelCategoriesMap,
modelSourceMap
} from '../config';
import { backendOptionsMap } from '../config/backend-parameters';
import {
ButtonList,
categoryToPathMap,
@@ -57,7 +56,6 @@ import {
} from '../config/types';
import useFormInitialValues from '../hooks/use-form-initial-values';
import useModelsColumns from '../hooks/use-models-columns';
import useQueryBackends from '../hooks/use-query-backends';
import APIAccessInfoModal from './api-access-info';
import DeployModal from './deploy-modal';
import Instances from './instances';
@@ -124,7 +122,6 @@ const Models: React.FC<ModelsProps> = ({
loadend,
total
}) => {
const { backendOptions } = useQueryBackends();
const { generateFormValues, clusterList, getClusterList } =
useFormInitialValues();
const { saveScrollHeight, restoreScrollHeight } = useBodyScroll();
@@ -401,7 +398,7 @@ const Models: React.FC<ModelsProps> = ({
const initialValues = generateFormValues(row, []);
setUpdateFormInitials({
data: initialValues,
isGGUF: row.backend === backendOptionsMap.llamaBox
isGGUF: false
});
setCurrentData(row);
setOpenAddModal(true);
@@ -693,7 +690,6 @@ const Models: React.FC<ModelsProps> = ({
clusterList={clusterList}
onCancel={handleModalCancel}
onOk={handleModalOk}
backendOptions={backendOptions}
></UpdateModelModal>
<DeployModal
open={openDeployModal.show}
@@ -704,7 +700,6 @@ const Models: React.FC<ModelsProps> = ({
isGGUF={openDeployModal.isGGUF}
hasLinuxWorker={openDeployModal.hasLinuxWorker}
clusterList={clusterList}
backendOptions={backendOptions}
onCancel={handleDeployModalCancel}
onOk={handleCreateModel}
></DeployModal>
@@ -12,7 +12,7 @@ import {
updateIgnoreFields
} from '../config';
import { backendOptionsMap } from '../config/backend-parameters';
import { BackendOption, FormData } from '../config/types';
import { FormData } from '../config/types';
import { generateGPUSelector } from '../config/utils';
import DataForm from '../forms';
import { useCheckCompatibility } from '../hooks';
@@ -26,7 +26,6 @@ type AddModalProps = {
data: FormData;
isGGUF: boolean;
};
backendOptions: BackendOption[];
clusterList: Global.BaseOption<
number,
{ provider: string; state: string | number }
@@ -326,7 +325,6 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
onOk={handleOk}
ref={formRef}
isGGUF={isGGUF}
backendOptions={props.backendOptions}
onBackendChange={handleAsyncBackendChange}
onValuesChange={handleManulOnValuesChange}
></DataForm>
@@ -4,9 +4,9 @@ import vllmParameters from './vllm-parameters';
export const backendOptionsMap = {
llamaBox: 'llama-box',
vllm: 'vllm',
vllm: 'vLLM',
voxBox: 'vox-box',
ascendMindie: 'ascend-mindie',
ascendMindie: 'MindIE',
custom: 'custom'
};
+6 -2
View File
@@ -22,6 +22,7 @@ import CatalogFrom from './catalog';
import LocalPathSource from './local-path-source';
import OnlineSource from './online-source';
// import AdvanceConfig from './advance-config';
import useQueryBackends from '../hooks/use-query-backends';
import AdvanceConfig from './advance-config';
import Performance from './performance';
@@ -33,7 +34,6 @@ interface DataFormProps {
isGGUF: boolean;
formKey: DeployFormKey;
sourceDisable?: boolean;
backendOptions: BackendOption[];
sourceList?: Global.BaseOption<string>[];
clusterList: Global.BaseOption<number>[];
fields?: string[];
@@ -50,7 +50,6 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
formKey,
initialValues,
sourceDisable = true,
backendOptions = [],
sourceList,
clusterList = [],
fields = ['source'],
@@ -58,6 +57,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
onValuesChange,
onOk
} = props;
const { backendOptions, getBackendOptions } = useQueryBackends();
const { getGPUOptionList, gpuOptions } = useGenerateGPUOptions();
const { getRuleMessage } = useAppUtils();
const [form] = Form.useForm();
@@ -111,6 +111,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
const handleClusterChange = (value: number) => {
getGPUOptionList({ clusterId: value });
getBackendOptions({ cluster_id: value });
};
const handleOnValuesChange = async (changedValues: any, allValues: any) => {
@@ -147,6 +148,9 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
},
getGPUOptionList: async (params: { clusterId: number }) => {
return await getGPUOptionList(params);
},
getBackendOptions: async (params?: { cluster_id: number }) => {
getBackendOptions(params);
}
};
});
@@ -1,14 +1,13 @@
import { backendOptionsAtom } from '@/atoms/models';
import { useAtom } from 'jotai';
import { useEffect } from 'react';
import { queryBackendList } from '../apis';
export default function useQueryBackends() {
const [backendOptions, setBackendOptions] = useAtom(backendOptionsAtom);
const getBackendOptions = async () => {
const getBackendOptions = async (params?: { cluster_id: number }) => {
try {
const res = await queryBackendList();
const res = await queryBackendList(params);
const list = res?.items?.map((item) => {
return {
value: item.backend_name,
@@ -30,10 +29,6 @@ export default function useQueryBackends() {
}
};
useEffect(() => {
getBackendOptions();
}, []);
return {
backendOptions,
getBackendOptions