fix: benchmark issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import SealInput from '@/components/seal-form/seal-input';
|
||||
import SealSelect from '@/components/seal-form/seal-select';
|
||||
import { PageAction } from '@/config';
|
||||
import { modelNameReg, PageAction } from '@/config';
|
||||
import useAppUtils from '@/hooks/use-app-utils';
|
||||
import { ClusterStatusValueMap } from '@/pages/cluster-management/config';
|
||||
import { useBenchmarkTargetInstance } from '@/pages/llmodels/hooks/use-run-benchmark';
|
||||
@@ -53,6 +53,10 @@ const BasicForm: React.FC = () => {
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage('input', 'common.table.name')
|
||||
},
|
||||
{
|
||||
pattern: modelNameReg,
|
||||
message: intl.formatMessage({ id: 'models.form.rules.name' })
|
||||
}
|
||||
]}
|
||||
>
|
||||
|
||||
@@ -9,26 +9,13 @@ import React, { useEffect } from 'react';
|
||||
import { ProfileValueMap } from '../config';
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { FormData } from '../config/types';
|
||||
import useQueryDataset from '../services/use-query-dataset';
|
||||
import useQueryProfiles from '../services/use-query-profiles';
|
||||
import RandomSettingsForm from './random-settings';
|
||||
|
||||
const DatasetForm: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const form = Form.useFormInstance();
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
const { action, open } = useFormContext();
|
||||
const {
|
||||
datasetList,
|
||||
loading: datasetLoading,
|
||||
fetchDatasetData,
|
||||
cancelRequest: cancelDatasetRequest
|
||||
} = useQueryDataset();
|
||||
const {
|
||||
profilesOptions,
|
||||
fetchProfilesData,
|
||||
cancelRequest: cancelProfilesRequest
|
||||
} = useQueryProfiles();
|
||||
const { action, open, profilesOptions, datasetList } = useFormContext();
|
||||
|
||||
const handleProfileChange = (value: string, option: any) => {
|
||||
if (value !== ProfileValueMap.Custom) {
|
||||
@@ -43,6 +30,8 @@ const DatasetForm: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const labelRender = (label: string) => {};
|
||||
|
||||
// Initialize profile when open form
|
||||
const initProfile = (
|
||||
value: string,
|
||||
@@ -63,28 +52,28 @@ const DatasetForm: React.FC = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
cancelDatasetRequest();
|
||||
cancelProfilesRequest();
|
||||
}
|
||||
|
||||
if (open) {
|
||||
const init = async () => {
|
||||
const profiles = await fetchProfilesData();
|
||||
const datasets = await fetchDatasetData();
|
||||
// set default profile
|
||||
if (profiles?.length > 0) {
|
||||
const throughputProfile = profiles.find(
|
||||
if (
|
||||
profilesOptions &&
|
||||
profilesOptions.length > 0 &&
|
||||
action === PageAction.CREATE
|
||||
) {
|
||||
const throughputProfile = profilesOptions.find(
|
||||
(item) => item.value === ProfileValueMap.ThroughputMedium
|
||||
);
|
||||
if (throughputProfile) {
|
||||
initProfile(throughputProfile.value, throughputProfile, datasets);
|
||||
initProfile(
|
||||
throughputProfile.value,
|
||||
throughputProfile,
|
||||
datasetList
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
init();
|
||||
}
|
||||
}, [open]);
|
||||
}, [open, action, profilesOptions, datasetList]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -127,10 +116,7 @@ const DatasetForm: React.FC = () => {
|
||||
</SealSelect>
|
||||
</Form.Item>
|
||||
|
||||
<RandomSettingsForm
|
||||
datasetList={datasetList}
|
||||
datasetLoading={datasetLoading}
|
||||
></RandomSettingsForm>
|
||||
<RandomSettingsForm datasetList={datasetList}></RandomSettingsForm>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -24,6 +24,8 @@ interface ProviderFormProps {
|
||||
currentData?: ListItem; // Used when action is EDIT
|
||||
open?: boolean;
|
||||
clusterList?: Global.BaseOption<number>[];
|
||||
datasetList: Global.BaseOption<number | string>[];
|
||||
profilesOptions: Global.BaseOption<string>[];
|
||||
onFinish: (values: FormData) => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -34,7 +36,15 @@ const TABKeysMap = {
|
||||
};
|
||||
|
||||
const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
const { action, currentData, onFinish, open, clusterList } = props;
|
||||
const {
|
||||
action,
|
||||
currentData,
|
||||
onFinish,
|
||||
open,
|
||||
clusterList,
|
||||
profilesOptions,
|
||||
datasetList
|
||||
} = props;
|
||||
const intl = useIntl();
|
||||
const [form] = Form.useForm();
|
||||
const { getScrollElementScrollableHeight } = useWrapperContext();
|
||||
@@ -102,7 +112,9 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
value={{
|
||||
action,
|
||||
open,
|
||||
clusterList: clusterList
|
||||
clusterList: clusterList,
|
||||
profilesOptions: profilesOptions,
|
||||
datasetList: datasetList
|
||||
}}
|
||||
>
|
||||
<Form
|
||||
|
||||
@@ -5,18 +5,19 @@ import useAppUtils from '@/hooks/use-app-utils';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import React, { useMemo } from 'react';
|
||||
import { DatasetValueMap } from '../config';
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { FormData } from '../config/types';
|
||||
|
||||
const RandomSettingsForm: React.FC<{
|
||||
datasetList: Global.BaseOption<number | string>[];
|
||||
datasetLoading: boolean;
|
||||
}> = (props) => {
|
||||
const { datasetList, datasetLoading } = props;
|
||||
const { datasetList } = props;
|
||||
const intl = useIntl();
|
||||
const { action, open } = useFormContext();
|
||||
const form = Form.useFormInstance();
|
||||
const profile = Form.useWatch('profile', form);
|
||||
const datasetName = Form.useWatch('dataset_name', form);
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
|
||||
const disabled = useMemo(() => {
|
||||
@@ -43,58 +44,66 @@ const RandomSettingsForm: React.FC<{
|
||||
label: item.label,
|
||||
value: item.label
|
||||
}))}
|
||||
loading={datasetLoading}
|
||||
label={intl.formatMessage({ id: 'benchmark.table.dataset' })}
|
||||
required
|
||||
></SealSelect>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="dataset_input_tokens"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage('input', 'benchmark.table.inputTokenLength')
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealInputNumber
|
||||
min={0}
|
||||
disabled={disabled}
|
||||
label={intl.formatMessage({ id: 'benchmark.table.inputTokenLength' })}
|
||||
required
|
||||
></SealInputNumber>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="dataset_output_tokens"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage(
|
||||
'input',
|
||||
'benchmark.table.outputTokenLength'
|
||||
)
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealInputNumber
|
||||
min={0}
|
||||
disabled={disabled}
|
||||
label={intl.formatMessage({
|
||||
id: 'benchmark.table.outputTokenLength'
|
||||
})}
|
||||
required
|
||||
></SealInputNumber>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="dataset_seed"
|
||||
getValueProps={(value) => ({ value: value || null })}
|
||||
>
|
||||
<SealInputNumber
|
||||
min={0}
|
||||
disabled={disabled}
|
||||
label={intl.formatMessage({ id: 'playground.image.params.seed' })}
|
||||
></SealInputNumber>
|
||||
</Form.Item>
|
||||
{datasetName === DatasetValueMap.Random && (
|
||||
<>
|
||||
<Form.Item<FormData>
|
||||
name="dataset_input_tokens"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage(
|
||||
'input',
|
||||
'benchmark.table.inputTokenLength'
|
||||
)
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealInputNumber
|
||||
min={0}
|
||||
disabled={disabled}
|
||||
label={intl.formatMessage({
|
||||
id: 'benchmark.table.inputTokenLength'
|
||||
})}
|
||||
required
|
||||
></SealInputNumber>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="dataset_output_tokens"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage(
|
||||
'input',
|
||||
'benchmark.table.outputTokenLength'
|
||||
)
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealInputNumber
|
||||
min={0}
|
||||
disabled={disabled}
|
||||
label={intl.formatMessage({
|
||||
id: 'benchmark.table.outputTokenLength'
|
||||
})}
|
||||
required
|
||||
></SealInputNumber>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="dataset_seed"
|
||||
getValueProps={(value) => ({ value: value || null })}
|
||||
>
|
||||
<SealInputNumber
|
||||
min={0}
|
||||
disabled={disabled}
|
||||
label={intl.formatMessage({ id: 'playground.image.params.seed' })}
|
||||
></SealInputNumber>
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
<Form.Item<FormData>
|
||||
name="request_rate"
|
||||
getValueProps={(value) => ({ value: value < 0 ? 'Infinity' : value })}
|
||||
|
||||
Reference in New Issue
Block a user