130 lines
3.6 KiB
TypeScript
130 lines
3.6 KiB
TypeScript
import SealInputNumber from '@/components/seal-form/input-number';
|
|
import SealSelect from '@/components/seal-form/seal-select';
|
|
import useAppUtils from '@/hooks/use-app-utils';
|
|
import { useIntl } from '@umijs/max';
|
|
import { Form } from 'antd';
|
|
import React from 'react';
|
|
import { FormData } from '../config/types';
|
|
|
|
const RandomSettingsForm: React.FC<{
|
|
datasetList: Global.BaseOption<number | string>[];
|
|
datasetLoading: boolean;
|
|
handleOnDataSetChange: (value: any, option: any) => void;
|
|
}> = (props) => {
|
|
const { datasetList, datasetLoading, handleOnDataSetChange } = props;
|
|
const intl = useIntl();
|
|
const form = Form.useFormInstance();
|
|
const profile = Form.useWatch('profile', form);
|
|
const { getRuleMessage } = useAppUtils();
|
|
|
|
const disabled = profile !== 'Custom' && Boolean(profile);
|
|
|
|
return (
|
|
<>
|
|
<Form.Item<FormData>
|
|
name="dataset_name"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: getRuleMessage('select', 'benchmark.table.dataset')
|
|
}
|
|
]}
|
|
>
|
|
<SealSelect
|
|
disabled={disabled}
|
|
options={datasetList?.map((item) => ({
|
|
...item,
|
|
label: item.label,
|
|
value: item.label
|
|
}))}
|
|
loading={datasetLoading}
|
|
onChange={handleOnDataSetChange}
|
|
label={intl.formatMessage({ id: 'benchmark.table.dataset' })}
|
|
required
|
|
></SealSelect>
|
|
</Form.Item>
|
|
<Form.Item<FormData>
|
|
name="dataset_prompt_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"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: getRuleMessage('input', 'benchmark.table.requestRate')
|
|
}
|
|
]}
|
|
>
|
|
<SealInputNumber
|
|
min={0}
|
|
disabled={disabled}
|
|
label={intl.formatMessage({ id: 'benchmark.table.requestRate' })}
|
|
required
|
|
></SealInputNumber>
|
|
</Form.Item>
|
|
<Form.Item<FormData>
|
|
name="total_requests"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: getRuleMessage('input', 'benchmark.form.totalRequests')
|
|
}
|
|
]}
|
|
>
|
|
<SealInputNumber
|
|
min={0}
|
|
disabled={disabled}
|
|
label={intl.formatMessage({ id: 'benchmark.form.totalRequests' })}
|
|
required
|
|
></SealInputNumber>
|
|
</Form.Item>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default RandomSettingsForm;
|